Panel spec keeps the installation's other panels
Saving panels replaces the whole list, so the spec's setup deleted every panel it had not created — and with it the credential of the screen on it. It now appends to the stored list and puts the original back in teardown, which also removes its own panel. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Gf7WaExcJ9bs3kfJXB3nK
This commit is contained in:
@@ -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}`,
|
||||
|
||||
Reference in New Issue
Block a user