Skip to content

Commit 202c8ac

Browse files
fix: broken grafana tests (#2696)
## Description - Fixes nightly EKS and HA k3d CI failures introduced by the Grafana 12 → 13 upgrade (#2584) - `validate namespace dashboard` and `validate loki dashboard` both timed out waiting for template variable dropdown options to populate - Grafana 13 lazy-loads variable values, which means clicking a dropdown no longer reliably triggers the Prometheus query to populate options, so tests waiting on `authservice-sidecar-test-app` to appear would time out - Fix: after navigating to each dashboard, re-navigate with `var-namespace` set directly in the URL; Grafana resolves explicit URL params synchronously with no query required ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide](https://github.com/defenseunicorns/uds-core/blob/main/CONTRIBUTING.md) followed
1 parent 0aaf351 commit 202c8ac

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

test/playwright/grafana.test.ts

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,14 @@ test("validate namespace dashboard", async ({ page }) => {
6969
await test.step("check dashboard", async () => {
7070
await gotoGrafana(page, `/dashboards`);
7171
await page.click('text="Kubernetes / Compute Resources / Namespace (Pods)"');
72-
await page
73-
.getByTestId(
74-
"data-testid Dashboard template variables Variable Value DropDown value link text authservice",
75-
)
76-
.click();
77-
if (!fullCore) {
78-
// Check grafana if not a full core deploy
79-
await page.getByRole("option", { name: "grafana" }).click();
80-
return;
81-
}
82-
await page.getByRole("option", { name: "authservice-sidecar-test-app" }).click();
72+
// Grafana 13+ does not eagerly load dropdown options even when a variable has a
73+
// preselected value. Re-navigate with the namespace set in the URL to bypass this.
74+
await page.waitForURL(/\/d\//);
75+
const url = new URL(page.url());
76+
url.searchParams.set("var-namespace", fullCore ? "authservice-sidecar-test-app" : "grafana");
77+
await page.goto(url.toString());
78+
await closeGrafanaModals(page);
79+
await expect(page.locator('[data-testid="data-testid dashboard controls"]')).toBeVisible();
8380
});
8481
});
8582

@@ -90,17 +87,14 @@ test("validate loki dashboard", async ({ page }) => {
9087
await gotoGrafana(page, `/dashboards`);
9188
await page.getByPlaceholder("Search for dashboards and folders").fill("Loki");
9289
await page.click('text="Loki Dashboard quick search"');
93-
await page
94-
.getByTestId(
95-
"data-testid Dashboard template variables Variable Value DropDown value link text authservice",
96-
)
97-
.click();
98-
if (!fullCore) {
99-
// Check grafana if not a full core deploy
100-
await page.getByRole("option", { name: "grafana" }).click();
101-
} else {
102-
await page.getByRole("option", { name: "authservice-sidecar-test-app" }).click();
103-
}
90+
// Grafana 13+ lazy-loads variables with no saved current value — clicking the empty
91+
// dropdown does not reliably trigger the Prometheus query to populate options.
92+
// Re-navigate with the namespace set in the URL to bypass lazy loading entirely.
93+
await page.waitForURL(/\/d\//);
94+
const url = new URL(page.url());
95+
url.searchParams.set("var-namespace", "authservice-sidecar-test-app");
96+
await page.goto(url.toString());
97+
await closeGrafanaModals(page);
10498
await expect(
10599
page
106100
.getByTestId("data-testid Panel header Logs Panel")

0 commit comments

Comments
 (0)