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:
@@ -1,4 +1,5 @@
|
||||
import { expect, type Page, test } from "@playwright/test"
|
||||
import { expect, test } from "@playwright/test"
|
||||
import { api, deleteAll } from "./utils/api"
|
||||
|
||||
/**
|
||||
* Editing writes a draft; only publishing hands it to the engine. The two
|
||||
@@ -12,19 +13,9 @@ 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.afterAll(async ({ browser }) => {
|
||||
await deleteAll(browser, [`/flows/${flowName}`])
|
||||
})
|
||||
|
||||
test("a draft stays off the engine until it is published", async ({ page }) => {
|
||||
await page.goto("/flows")
|
||||
@@ -93,6 +84,4 @@ test("discarding a draft goes back to the published flow", async ({ page }) => {
|
||||
const detail = await (await api(page, `/flows/${flowName}`)).json()
|
||||
expect(detail.has_draft).toBe(false)
|
||||
expect(detail.definition.title).not.toBe("Theirs")
|
||||
|
||||
await api(page, `/flows/${flowName}`, { method: "DELETE" })
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user