Skip to content

Commit 9d90d96

Browse files
committed
test(e2e): handle Grafana 13 What's-New modal and datasource picker overlay
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
1 parent 8db6373 commit 9d90d96

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

tests/quickwit.spec.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { test, expect } from '@grafana/plugin-e2e';
2+
import type { Page } from '@playwright/test';
23

34
// Grafana (inside Docker) reaches Quickwit via the docker service name.
45
// The test process (on the host) reaches the same Quickwit via localhost port mapping.
@@ -20,17 +21,22 @@ test.afterEach(async () => {
2021

2122
test('create datasource and explore logs', async ({ page }) => {
2223
let datasourceUid: string;
24+
const quickwitDatasourceButton = page.locator('button').filter({ hasText: /^Quickwit$/ }).first();
2325

2426
await test.step('look for the plugin in the list of datasources', async () => {
2527
await page.goto('/connections/datasources/new');
28+
await dismissWhatsNewModal(page);
2629
await page.getByPlaceholder('Filter by name or type').fill('quickwit');
27-
await expect(page.getByText('Quickwit', { exact: true })).toBeVisible();
30+
await expect(quickwitDatasourceButton).toBeVisible();
2831
});
2932

3033
await test.step('create datasource via UI', async () => {
3134
await page.goto('/connections/datasources/new');
35+
await dismissWhatsNewModal(page);
3236
await page.getByPlaceholder('Filter by name or type').fill('quickwit');
33-
await page.getByText('Quickwit', { exact: true }).click();
37+
// Grafana 13 sometimes leaves a portal overlay mounted above the picker.
38+
// Force the click once the correct button is resolved.
39+
await quickwitDatasourceButton.click({ force: true });
3440

3541
// Wait for the config form to load
3642
await expect(page.getByText('Index settings')).toBeVisible();
@@ -106,3 +112,15 @@ async function ingestDummyLogs(runId: string) {
106112
throw new Error('Ingest failed: no searchable logs');
107113
}
108114
}
115+
116+
async function dismissWhatsNewModal(page: Page) {
117+
const dialog = page.getByRole('dialog', { name: "What's new in Grafana" });
118+
const closeButton = dialog.getByRole('button', { name: 'Close' });
119+
120+
await closeButton.waitFor({ state: 'visible', timeout: 3000 }).catch(() => {});
121+
122+
if (await dialog.isVisible().catch(() => false)) {
123+
await closeButton.click({ force: true });
124+
await expect(dialog).toBeHidden({ timeout: 10000 });
125+
}
126+
}

0 commit comments

Comments
 (0)