Frontend addresses flows and dashboards by id: routes /flows/$flowId, /dashboards/$id and /view/$id, query keys, saves, lists, device pickers, search, brain and endpoint links and generated results dashboards go by id, while live values, issues, pauses and message names keep the key; tabs take the title from the document; creating uses POST and opens the issued id; the flow and dashboard panels show key and id with a copy button and a served HTTP or WebSocket node shows its hook URL under the flow id; specs create by POST and ids.spec.ts exercises issued ids
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from "@playwright/test"
|
||||
import { api, deleteAll } from "./utils/api"
|
||||
import { api, deleteAll, openedFlowId } from "./utils/api"
|
||||
|
||||
/**
|
||||
* Editing writes a draft; only publishing hands it to the engine. The two
|
||||
@@ -8,13 +8,15 @@ import { api, deleteAll } from "./utils/api"
|
||||
*/
|
||||
|
||||
const flowName = `test_draft_${Date.now().toString(36)}`
|
||||
/** Issued by the server when the first test creates it in the app. */
|
||||
let flowId = ""
|
||||
|
||||
test.use({ storageState: "playwright/.auth/user.json" })
|
||||
|
||||
test.describe.configure({ mode: "serial" })
|
||||
|
||||
test.afterAll(async ({ browser }) => {
|
||||
await deleteAll(browser, [`/flows/${flowName}`])
|
||||
await deleteAll(browser, [`/flows/${flowId}`])
|
||||
})
|
||||
|
||||
test("a draft stays off the engine until it is published", async ({ page }) => {
|
||||
@@ -22,7 +24,7 @@ test("a draft stays off the engine until it is published", async ({ page }) => {
|
||||
await page.getByTestId("new-flow").click()
|
||||
await page.getByTestId("new-flow-name").fill(flowName)
|
||||
await page.getByTestId("create-flow").click()
|
||||
await page.waitForURL(`/flows/${flowName}`)
|
||||
flowId = await openedFlowId(page)
|
||||
|
||||
await page.getByTestId("add-node").click()
|
||||
await page
|
||||
@@ -39,7 +41,7 @@ test("a draft stays off the engine until it is published", async ({ page }) => {
|
||||
|
||||
// Nothing of this flow is loaded while it is only a draft.
|
||||
await page.waitForTimeout(1500)
|
||||
const before = await (await api(page, `/flows/${flowName}/state`)).json()
|
||||
const before = await (await api(page, `/flows/${flowId}/state`)).json()
|
||||
expect(before.nodes).toHaveLength(0)
|
||||
|
||||
await page.getByTestId("publish-flow").click()
|
||||
@@ -49,26 +51,26 @@ test("a draft stays off the engine until it is published", async ({ page }) => {
|
||||
await expect(page.getByTestId("discard-draft")).toBeHidden()
|
||||
await expect(page.getByTestId("publish-flow")).toBeDisabled()
|
||||
|
||||
const after = await (await api(page, `/flows/${flowName}/state`)).json()
|
||||
const after = await (await api(page, `/flows/${flowId}/state`)).json()
|
||||
expect(after.nodes.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
test("a save against a version someone else moved on from is refused", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto(`/flows/${flowName}`)
|
||||
await page.goto(`/flows/${flowId}`)
|
||||
await page.waitForSelector(".react-flow__node")
|
||||
|
||||
const detail = await (await api(page, `/flows/${flowName}`)).json()
|
||||
const detail = await (await api(page, `/flows/${flowId}`)).json()
|
||||
|
||||
// Stand in for a second client that saved first.
|
||||
const first = await api(page, `/flows/${flowName}`, {
|
||||
const first = await api(page, `/flows/${flowId}`, {
|
||||
method: "PUT",
|
||||
data: { ...detail.definition, title: "Theirs" },
|
||||
})
|
||||
expect(first.ok()).toBeTruthy()
|
||||
|
||||
const stale = await api(page, `/flows/${flowName}`, {
|
||||
const stale = await api(page, `/flows/${flowId}`, {
|
||||
method: "PUT",
|
||||
data: { ...detail.definition, title: "Mine" },
|
||||
})
|
||||
@@ -79,7 +81,7 @@ test("a save against a version someone else moved on from is refused", async ({
|
||||
})
|
||||
|
||||
test("discarding a draft goes back to the published flow", async ({ page }) => {
|
||||
await page.goto(`/flows/${flowName}`)
|
||||
await page.goto(`/flows/${flowId}`)
|
||||
await page.waitForSelector(".react-flow__node")
|
||||
|
||||
await page.getByTestId("discard-draft").click()
|
||||
@@ -87,7 +89,7 @@ test("discarding a draft goes back to the published flow", async ({ page }) => {
|
||||
|
||||
await expect(page.getByTestId("discard-draft")).toBeHidden()
|
||||
await expect(page.getByTestId("publish-flow")).toBeDisabled()
|
||||
const detail = await (await api(page, `/flows/${flowName}`)).json()
|
||||
const detail = await (await api(page, `/flows/${flowId}`)).json()
|
||||
expect(detail.has_draft).toBe(false)
|
||||
expect(detail.definition.title).not.toBe("Theirs")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user