diff --git a/frontend/tests/panel.spec.ts b/frontend/tests/panel.spec.ts index 1f17c95..d2dcaf9 100644 --- a/frontend/tests/panel.spec.ts +++ b/frontend/tests/panel.spec.ts @@ -1,4 +1,5 @@ import { expect, test } from "@playwright/test" +import type { PanelDef } from "../src/client" import { api, apiPage, deleteAll } from "./utils/api" /** @@ -16,6 +17,8 @@ import { api, apiPage, deleteAll } from "./utils/api" const flowName = `test_panel_${Date.now().toString(36)}` const first = `${flowName}_a` const second = `${flowName}_b` +/** The installation's own panels, put back by the teardown. */ +let panels: PanelDef[] | null = null test.use({ storageState: "playwright/.auth/user.json" }) test.describe.configure({ mode: "serial" }) @@ -69,16 +72,33 @@ test.beforeAll(async ({ browser }) => { }) } + // Saving is a whole-list replace, and a panel that disappears takes the + // credential of the screen hanging on it. So append to what is there, and + // keep the list for the teardown to put back. + const config = await (await api(page, "/panels/")).json() + const existing: PanelDef[] = (config.panels ?? []).filter( + (p: PanelDef) => p.id !== flowName, + ) + panels = existing await api(page, "/panels/", { method: "PUT", data: { - panels: [{ id: flowName, title: "Hall", dashboards: [first, second] }], + panels: [ + ...existing, + { id: flowName, title: "Hall", dashboards: [first, second] }, + ], }, }) await page.close() }) test.afterAll(async ({ browser }) => { + // Restoring the list is also what removes this spec's own panel. + if (panels) { + const page = await apiPage(browser) + await api(page, "/panels/", { method: "PUT", data: { panels } }) + await page.close() + } await deleteAll(browser, [ `/dashboards/${first}`, `/dashboards/${second}`,