Delete the flows and users the Playwright specs create

The specs run against a development stack, so every run left a test_flow_*
in someone's flow list. Each spec now tears down what it made in an afterAll,
which runs whether or not the tests passed, and the three copies of the API
helper move into tests/utils/api.ts.
This commit is contained in:
2026-08-16 16:46:07 +02:00
parent d82bba735e
commit 2c9171d415
6 changed files with 79 additions and 62 deletions
+7 -26
View File
@@ -1,4 +1,5 @@
import { expect, type Page, test } from "@playwright/test"
import { expect, test } from "@playwright/test"
import { api, apiPage, deleteAll } from "./utils/api"
/**
* Dashboards and other flows appear on the canvas but are not part of the flow.
@@ -16,25 +17,8 @@ test.use({ storageState: "playwright/.auth/user.json" })
test.describe.configure({ mode: "serial" })
const apiUrl = process.env.VITE_API_URL || "http://api.localhost"
async function api(
page: Page,
path: string,
init: Record<string, unknown> = {},
) {
const token = await page.evaluate(() => localStorage.getItem("access_token"))
return page.request.fetch(`${apiUrl}/api/v1${path}`, {
...init,
headers: { Authorization: `Bearer ${token}` },
})
}
test.beforeAll(async ({ browser }) => {
const page = await browser.newPage({
storageState: "playwright/.auth/user.json",
})
await page.goto("/")
const page = await apiPage(browser)
// A flow reading a message, and a dashboard control that sets it.
await api(page, `/flows/${flowName}`, {
@@ -82,13 +66,10 @@ test.beforeAll(async ({ browser }) => {
})
test.afterAll(async ({ browser }) => {
const page = await browser.newPage({
storageState: "playwright/.auth/user.json",
})
await page.goto("/")
await api(page, `/dashboards/${dashboardName}`, { method: "DELETE" })
await api(page, `/flows/${flowName}`, { method: "DELETE" })
await page.close()
await deleteAll(browser, [
`/dashboards/${dashboardName}`,
`/flows/${flowName}`,
])
})
test("a dashboard control is drawn on the flow it feeds", async ({ page }) => {