# What this PR does There are the following tests added: - admin is allowed to edit other profiles - editor is not allowed to edit other profiles ## Which issue(s) this PR fixes https://github.com/grafana/oncall/issues/1586 ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [ ] Documentation added (or `pr:no public docs` PR label added if not required) - [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) --------- Co-authored-by: Rares Mardare <rares.mardare@grafana.com>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { Page } from '@playwright/test';
|
|
import { clickButton, fillInInput, selectDropdownValue } from './forms';
|
|
import { goToOnCallPage } from './navigation';
|
|
import dayjs from 'dayjs';
|
|
|
|
export const createOnCallSchedule = async (page: Page, scheduleName: string, userName: string): Promise<void> => {
|
|
// go to the schedules page
|
|
await goToOnCallPage(page, 'schedules');
|
|
|
|
// create an oncall-rotation schedule
|
|
await clickButton({ page, buttonText: 'New Schedule' });
|
|
(await page.waitForSelector('button >> text=Create >> nth=0')).click();
|
|
|
|
// fill in the name input
|
|
await fillInInput(page, 'div[class*="ScheduleForm"] input[name="name"]', scheduleName);
|
|
|
|
// Add a new layer w/ the current user to it
|
|
await clickButton({ page, buttonText: 'Create Schedule' });
|
|
|
|
await clickButton({ page, buttonText: 'Add rotation' });
|
|
|
|
await selectDropdownValue({
|
|
page,
|
|
selectType: 'grafanaSelect',
|
|
placeholderText: 'Add user',
|
|
value: userName,
|
|
});
|
|
|
|
await clickButton({ page, buttonText: 'Create' });
|
|
};
|
|
|
|
export interface OverrideFormDateInputs {
|
|
start: dayjs.Dayjs;
|
|
end: dayjs.Dayjs;
|
|
}
|
|
|
|
export const getOverrideFormDateInputs = async (page: Page): Promise<OverrideFormDateInputs> => {
|
|
const getInputValue = async (inputNumber: number): Promise<string> => {
|
|
const element = await page.waitForSelector(`div[data-testid=\"override-inputs\"] >> input >> nth=${inputNumber}`);
|
|
return await element.inputValue();
|
|
};
|
|
|
|
const startDate = await getInputValue(0);
|
|
const startTime = await getInputValue(1);
|
|
|
|
const endDate = await getInputValue(2);
|
|
const endTime = await getInputValue(3);
|
|
|
|
const startDateTime = dayjs(`${startDate} ${startTime}`, 'MM/DD/YYYY HH:mm');
|
|
const endDateTime = dayjs(`${endDate} ${endTime}`, 'MM/DD/YYYY HH:mm');
|
|
|
|
return {
|
|
start: startDateTime,
|
|
end: endDateTime,
|
|
};
|
|
};
|