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.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H7LwYgJfpkbLCTeiAf8U4A
This commit is contained in:
2026-08-16 16:46:07 +02:00
co-authored by Claude Fable 5
parent a733e0d582
commit 143395358a
6 changed files with 79 additions and 62 deletions
+6 -20
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"
/**
* Flows can be taken off the engine and put back, and what a node prints — or
@@ -11,8 +12,6 @@ test.use({ storageState: "playwright/.auth/user.json" })
test.describe.configure({ mode: "serial" })
const apiUrl = process.env.VITE_API_URL || "http://api.localhost"
const PRINTING_NODE = `def process(params):
print("sensor read 21.5 degrees")
return {"reading": 21.5}
@@ -21,23 +20,12 @@ const BROKEN_NODE = `def process(reading, params):
raise RuntimeError("downstream blew up")
`
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.afterAll(async ({ browser }) => {
await deleteAll(browser, [`/flows/${flowName}`])
})
test.beforeAll(async ({ browser }) => {
const page = await browser.newPage({
storageState: "playwright/.auth/user.json",
})
await page.goto("/")
const page = await apiPage(browser)
await api(page, `/flows/${flowName}`, {
method: "PUT",
data: {
@@ -123,6 +111,4 @@ test("a flow can be paused and let go again", async ({ page }) => {
await page.getByTestId("resume-flow").click()
await expect(page.getByTestId("pause-flow")).toBeVisible()
await api(page, `/flows/${flowName}`, { method: "DELETE" })
})