From 182ee2fad76f9551fbf350f4f2acf075f3989e85 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Thu, 22 Feb 2024 19:41:21 +0000 Subject: [PATCH] fix e2e tests (#3950) # Which issue(s) this PR fixes Fix failing e2e tests on `dev` ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) --------- Co-authored-by: Dominik --- .../e2e-tests/escalationChains/escalationPolicy.test.ts | 4 ++-- grafana-plugin/e2e-tests/globalSetup.ts | 2 +- grafana-plugin/e2e-tests/schedules/quality.test.ts | 8 ++------ grafana-plugin/e2e-tests/utils/schedule.ts | 4 ++-- .../src/containers/ScheduleForm/ScheduleForm.tsx | 2 +- grafana-plugin/src/state/rootBaseStore/RootBaseStore.ts | 3 --- 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/grafana-plugin/e2e-tests/escalationChains/escalationPolicy.test.ts b/grafana-plugin/e2e-tests/escalationChains/escalationPolicy.test.ts index fd07ef2d..0b178717 100644 --- a/grafana-plugin/e2e-tests/escalationChains/escalationPolicy.test.ts +++ b/grafana-plugin/e2e-tests/escalationChains/escalationPolicy.test.ts @@ -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); }); diff --git a/grafana-plugin/e2e-tests/globalSetup.ts b/grafana-plugin/e2e-tests/globalSetup.ts index cd60e39a..dd10d953 100644 --- a/grafana-plugin/e2e-tests/globalSetup.ts +++ b/grafana-plugin/e2e-tests/globalSetup.ts @@ -74,7 +74,7 @@ const configureOnCallPlugin = async (page: Page): Promise => { * 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; diff --git a/grafana-plugin/e2e-tests/schedules/quality.test.ts b/grafana-plugin/e2e-tests/schedules/quality.test.ts index b5de7461..82d84212 100644 --- a/grafana-plugin/e2e-tests/schedules/quality.test.ts +++ b/grafana-plugin/e2e-tests/schedules/quality.test.ts @@ -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/); }); diff --git a/grafana-plugin/e2e-tests/utils/schedule.ts b/grafana-plugin/e2e-tests/utils/schedule.ts index 9c5257f6..3d76541a 100644 --- a/grafana-plugin/e2e-tests/utils/schedule.ts +++ b/grafana-plugin/e2e-tests/utils/schedule.ts @@ -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 => { @@ -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); + 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' }); diff --git a/grafana-plugin/src/containers/ScheduleForm/ScheduleForm.tsx b/grafana-plugin/src/containers/ScheduleForm/ScheduleForm.tsx index b34c0172..f60fcae6 100644 --- a/grafana-plugin/src/containers/ScheduleForm/ScheduleForm.tsx +++ b/grafana-plugin/src/containers/ScheduleForm/ScheduleForm.tsx @@ -77,7 +77,7 @@ export const ScheduleForm = observer((props: ScheduleFormProps) => { onClose={onHide} closeOnMaskClick={false} > -
+
diff --git a/grafana-plugin/src/state/rootBaseStore/RootBaseStore.ts b/grafana-plugin/src/state/rootBaseStore/RootBaseStore.ts index 1677355a..d3986ca1 100644 --- a/grafana-plugin/src/state/rootBaseStore/RootBaseStore.ts +++ b/grafana-plugin/src/state/rootBaseStore/RootBaseStore.ts @@ -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'; @@ -40,7 +39,6 @@ import { getOnCallApiUrl, GRAFANA_LICENSE_CLOUD, GRAFANA_LICENSE_OSS, - PLUGIN_ROOT, } from 'utils/consts'; import { FaroHelper } from 'utils/faro'; @@ -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')