From 835747a44de786879d63f23c63f20c883a2f7b10 Mon Sep 17 00:00:00 2001 From: Adam Yeats Date: Wed, 19 Aug 2026 22:44:32 +0100 Subject: [PATCH 1/3] fix(plugin-e2e): correct dashboard toolbar version thresholds --- .../src/models/pages/DashboardPage.test.ts | 44 +++++++++++++++++++ .../src/models/pages/DashboardPage.ts | 20 ++++++--- 2 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 packages/plugin-e2e/src/models/pages/DashboardPage.test.ts diff --git a/packages/plugin-e2e/src/models/pages/DashboardPage.test.ts b/packages/plugin-e2e/src/models/pages/DashboardPage.test.ts new file mode 100644 index 0000000000..cfa128c6f5 --- /dev/null +++ b/packages/plugin-e2e/src/models/pages/DashboardPage.test.ts @@ -0,0 +1,44 @@ +import { describe, it, expect, vi } from 'vitest'; +import { DashboardPage } from './DashboardPage'; +import { PluginTestCtx } from '../../types'; + +const NAV_TOOLBAR = 'data-testid Nav toolbar'; +const DASHBOARD_CONTROLS = 'data-testid dashboard controls'; + +/** + * Returns the selector `toolbar` passes to `page.locator`, by standing in a locator factory that + * hands back the selector it was given. + */ +function resolveToolbarSelector(grafanaVersion: string): string { + const ctx = { + page: { locator: vi.fn((selector: string) => selector) }, + grafanaVersion, + selectors: { + components: { NavToolbar: { container: NAV_TOOLBAR } }, + pages: { Dashboard: { Controls: DASHBOARD_CONTROLS } }, + }, + } as unknown as PluginTestCtx; + + return new DashboardPage(ctx).toolbar as unknown as string; +} + +describe('DashboardPage.toolbar', () => { + // Each threshold is the version at which that toolbar became the default, not the version at + // which its selector first existed. Both toolbars shipped behind a feature toggle that stayed + // off by default for two more minor releases, so gating on first availability resolved to an + // element Grafana never renders, and a scoped locator then waited out the whole test timeout. + it.each([ + ['8.5.27', '.page-toolbar'], + // topnav exists from 9.4.0 but is only default-on from 9.5.0 + ['9.4.17', '.page-toolbar'], + ['9.5.0', `[data-testid="${NAV_TOOLBAR}"]`], + ['11.0.11', `[data-testid="${NAV_TOOLBAR}"]`], + // dashboardScene exists from 11.1.0 but is only default-on from 11.3.0 + ['11.1.13', `[data-testid="${NAV_TOOLBAR}"]`], + ['11.2.10', `[data-testid="${NAV_TOOLBAR}"]`], + ['11.3.0', `[data-testid="${DASHBOARD_CONTROLS}"]`], + ['13.2.0', `[data-testid="${DASHBOARD_CONTROLS}"]`], + ])('resolves the toolbar on Grafana %s to %s', (grafanaVersion, expected) => { + expect(resolveToolbarSelector(grafanaVersion)).toBe(expected); + }); +}); diff --git a/packages/plugin-e2e/src/models/pages/DashboardPage.ts b/packages/plugin-e2e/src/models/pages/DashboardPage.ts index 0c6672ff4a..9c0c903d50 100644 --- a/packages/plugin-e2e/src/models/pages/DashboardPage.ts +++ b/packages/plugin-e2e/src/models/pages/DashboardPage.ts @@ -57,16 +57,26 @@ export class DashboardPage extends GrafanaPage { /** * Returns a locator for the dashboard toolbar area that contains the time range controls. * - * - Grafana ≥ 11.1.0: resolves to `Dashboard.Controls` (scenes-based dashboard controls bar) - * - Grafana 9.4.0–11.0.x: resolves to `NavToolbar.container` - * - Grafana < 9.4.0: falls back to `.page-toolbar` + * The thresholds are the versions at which each toolbar became the *default*, not the versions + * at which its selector first existed. Both toolbars shipped behind a feature toggle that was + * still off by default for two minor releases, so gating on first availability resolves to an + * element that Grafana never renders: + * + * - `dashboard controls` is declared from 11.1.0 but belongs to the scenes dashboard, and + * `dashboardScene` is only default-on from 11.3.0. + * - `Nav toolbar` is declared from 9.4.0 but belongs to the top nav, and `topnav` is only + * default-on from 9.5.0 — the same threshold `addPanel` already uses below. + * + * - Grafana ≥ 11.3.0: resolves to `Dashboard.Controls` (scenes-based dashboard controls bar) + * - Grafana 9.5.0–11.2.x: resolves to `NavToolbar.container` + * - Grafana < 9.5.0: falls back to `.page-toolbar` */ get toolbar() { const { components, pages } = this.ctx.selectors; - if (gte(this.ctx.grafanaVersion, '11.1.0')) { + if (gte(this.ctx.grafanaVersion, '11.3.0')) { return this.getByGrafanaSelector(pages.Dashboard.Controls); } - return gte(this.ctx.grafanaVersion, '9.4.0') + return gte(this.ctx.grafanaVersion, '9.5.0') ? this.getByGrafanaSelector(components.NavToolbar.container) : this.ctx.page.locator('.page-toolbar'); } From 39007888cc61e0820492b3966f971d53a34a417e Mon Sep 17 00:00:00 2001 From: Adam Yeats Date: Thu, 20 Aug 2026 18:36:33 +0100 Subject: [PATCH 2/3] ci: temporarily run plugin-e2e against every supported Grafana version --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 03197e2e92..d6c8c51132 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -28,7 +28,7 @@ jobs: version-resolver-type: plugin-grafana-dependency grafana-dependency: '>=8.5.0' skip-grafana-dev-image: false - # limit: 0 # Uncomment to test all versions since 8.5.0. Useful when testing compatibility for new APIs. + limit: 0 # TEMPORARY (do not merge): verifying the toolbar thresholds against every supported version. playwright-tests: needs: resolve-versions From f2c7b7d8c1393fc66b7f89bb518d8c15963269ba Mon Sep 17 00:00:00 2001 From: Adam Yeats Date: Thu, 20 Aug 2026 21:50:27 +0100 Subject: [PATCH 3/3] Revert "ci: temporarily run plugin-e2e against every supported Grafana version" This reverts commit 39007888cc61e0820492b3966f971d53a34a417e. --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index d6c8c51132..03197e2e92 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -28,7 +28,7 @@ jobs: version-resolver-type: plugin-grafana-dependency grafana-dependency: '>=8.5.0' skip-grafana-dev-image: false - limit: 0 # TEMPORARY (do not merge): verifying the toolbar thresholds against every supported version. + # limit: 0 # Uncomment to test all versions since 8.5.0. Useful when testing compatibility for new APIs. playwright-tests: needs: resolve-versions