Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix e2e tests #3950

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ test('from_time and to_time for "Continue escalation if current UTC time is in r
await page.reload();
await page.waitForLoadState('networkidle');

expect(_getFromTimeInput()).toHaveValue(FROM_TIME);
expect(_getToTimeInput()).toHaveValue(TO_TIME);
await expect(_getFromTimeInput()).toHaveValue(FROM_TIME);
await expect(_getToTimeInput()).toHaveValue(TO_TIME);
});
2 changes: 1 addition & 1 deletion grafana-plugin/e2e-tests/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const configureOnCallPlugin = async (page: Page): Promise<void> => {
* go to the oncall plugin configuration page and wait for the page to be loaded
*/
await goToGrafanaPage(page, '/plugins/grafana-oncall-app');
await page.waitForTimeout(2000);
await page.waitForTimeout(3000);

// if plugin is configured, go to OnCall
const isConfigured = (await page.getByText('Connected to OnCall').count()) >= 1;
Expand Down
8 changes: 2 additions & 6 deletions grafana-plugin/e2e-tests/schedules/quality.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ test('check schedule quality for simple 1-user schedule', async ({ adminRolePage
const scheduleQualityDetailsElement = page.getByTestId('schedule-quality-details');
await scheduleQualityDetailsElement.waitFor({ state: 'visible' });

await expect(scheduleQualityDetailsElement.locator('span[class*="Text"] >> nth=2 ')).toHaveText(
'Schedule has no gaps'
);
await expect(scheduleQualityDetailsElement.locator('span[class*="Text"] >> nth=3 ')).toHaveText(
'Schedule is perfectly balanced'
);
await expect(scheduleQualityDetailsElement).toHaveText(/Schedule has no gaps/);
await expect(scheduleQualityDetailsElement).toHaveText(/Schedule is perfectly balanced/);
});
4 changes: 2 additions & 2 deletions grafana-plugin/e2e-tests/utils/schedule.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Page } from '@playwright/test';
import dayjs from 'dayjs';

import { clickButton, fillInInput, selectDropdownValue } from './forms';
import { clickButton, selectDropdownValue } from './forms';
import { goToOnCallPage } from './navigation';

export const createOnCallSchedule = async (page: Page, scheduleName: string, userName: string): Promise<void> => {
Expand All @@ -13,7 +13,7 @@ export const createOnCallSchedule = async (page: Page, scheduleName: string, use
(await page.waitForSelector('button >> text=Create >> nth=0')).click();

// fill in the name input
await fillInInput(page, 'div[class*="ScheduleForm"] input[name="name"]', scheduleName);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my guess is that the css class names were changed in #3837 (I'm guessing because of the @emotion/css dependency being added?)

nevertheless, selecting locators based on css class names is fragile and we should prefer data-testid whenever possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree, selecting by aria roles, text and/or testids is recommended

await page.getByTestId('schedule-form').locator('input[name="name"]').fill(scheduleName);

// Add a new layer w/ the current user to it
await clickButton({ page, buttonText: 'Create Schedule' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const ScheduleForm = observer((props: ScheduleFormProps) => {
onClose={onHide}
closeOnMaskClick={false}
>
<div className={cx('content')}>
<div className={cx('content')} data-testid="schedule-form">
<VerticalGroup>
<GForm form={formConfig} data={data} onSubmit={handleSubmit} />
<div className="buttons">
Expand Down
3 changes: 0 additions & 3 deletions grafana-plugin/src/state/rootBaseStore/RootBaseStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { locationService } from '@grafana/runtime';
import { contextSrv } from 'grafana/app/core/core';
import { action, computed, makeObservable, observable, runInAction } from 'mobx';
import qs from 'query-string';
Expand Down Expand Up @@ -40,7 +39,6 @@ import {
getOnCallApiUrl,
GRAFANA_LICENSE_CLOUD,
GRAFANA_LICENSE_OSS,
PLUGIN_ROOT,
} from 'utils/consts';
import { FaroHelper } from 'utils/faro';

Expand Down Expand Up @@ -233,7 +231,6 @@ export class RootBaseStore {
* therefore there is no need to trigger an additional/separate sync, nor poll a status
*/
await PluginState.installPlugin();
locationService.push(PLUGIN_ROOT);
} catch (e) {
return this.setupPluginError(
PluginState.getHumanReadableErrorFromOnCallError(e, this.onCallApiUrl, 'install')
Expand Down
Loading