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:
@@ -32,6 +32,53 @@ export async function apiPage(browser: Browser) {
|
||||
return page
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a flow the way the app does, with a POST, under its key as a pinned
|
||||
* id, so a spec keeps addressing it by the name it chose. The suite signs in
|
||||
* as a superuser, who may pin. The answer is the request's own.
|
||||
*/
|
||||
export function createFlow(
|
||||
page: Page,
|
||||
doc: { name: string; [field: string]: unknown },
|
||||
) {
|
||||
return api(page, "/flows/", {
|
||||
method: "POST",
|
||||
data: { id: doc.name, ...doc },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* The same for a dashboard. Creating one takes only its key and title, so the
|
||||
* rest of `doc` is saved over the new draft, and the answer is that save's.
|
||||
*/
|
||||
export async function createDashboard(
|
||||
page: Page,
|
||||
doc: { name: string; title?: string; [field: string]: unknown },
|
||||
) {
|
||||
const made = await api(page, "/dashboards/", {
|
||||
method: "POST",
|
||||
data: { id: doc.name, name: doc.name, title: doc.title },
|
||||
})
|
||||
const rest = Object.keys(doc).filter(
|
||||
(key) => key !== "name" && key !== "title",
|
||||
)
|
||||
if (!made.ok() || rest.length === 0) return made
|
||||
const { version } = await made.json()
|
||||
return api(page, `/dashboards/${doc.name}`, {
|
||||
method: "PUT",
|
||||
data: { ...doc, version },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* The id the server issued a flow just created in the app, read off the
|
||||
* editor it opened: an opaque `f_` and eight characters, never the key.
|
||||
*/
|
||||
export async function openedFlowId(page: Page) {
|
||||
await page.waitForURL(/\/flows\/f_[a-z2-7]{8}$/)
|
||||
return new URL(page.url()).pathname.split("/").pop() ?? ""
|
||||
}
|
||||
|
||||
/** Delete the given API paths, whether or not they are still there. */
|
||||
export async function deleteAll(browser: Browser, paths: string[]) {
|
||||
const page = await apiPage(browser)
|
||||
|
||||
Reference in New Issue
Block a user