The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(e2e): browser coverage for the Flows routes and back-compat slugs\n\nExisting coverage is thin and indirect: skill-lifecycle.spec.ts only checks the\nflows_list RPC is reachable, and top-level-functional-flows.spec.ts drives the\nLEGACY SKILL.md /workflows CRUD page, a different surface. Nothing opened\n/flows/:id.\n\nCovers the list surface, an existing flow's canvas (created through\nflows_create), the not-found state for an unknown id, the back button, the\nunsaved-draft route, and the three back-compat slugs.\n\nTwo scope facts pinned rather than papered over:\n - /flows/draft cannot be opened by URL. The draft graph rides in\n location.state, so a direct hit renders an empty state on purpose "rather\n than a broken canvas". The test asserts that, and a second test pins the\n route-order guarantee that "draft" is never captured as an :id.\n - /webhooks is a TWO-hop redirect: AppRoutes.tsx:238 -> /settings/integrations\n -> settingsRouteElements.tsx:129 -> /connections. The intermediate target is\n itself a redirect, and no #webhooks fragment survives either hop, so an old\n bookmark lands on generic Connections. Recorded in the bug list.\n\nThree assertions were rewritten after proving vacuous:\n - /workflows and /routines asserted only "body non-empty, some button\n visible" — which the CHAT surface satisfies, and chat is where they were,\n because bootAuthenticatedPage races its own /home -> /chat redirect when\n given any other hash. They now assert distinct destinations, and /workflows\n additionally asserts flows-new-workflow is ABSENT so the two surfaces\n cannot be conflated.\n - flow-canvas-title is an <input>, so toContainText compares against text\n content and always sees "". Now toHaveValue.\nAlso: flows_create answers a CLI envelope {result, logs}; reading .id off the\nraw result yields undefined while the core logs "flows_create -> ok".\n\nRevert-proofed with two swap mutations (swaps, not deletions, so every import\nstays used and TS6133 cannot leave a stale dist-web), each rebuilt before the\nrun:\n - /routines and /webhooks redirect targets swapped -> both those tests fail,\n untouched /workflows passes.\n - canvas title forced to a fixed string -> the title test fails naming\n 'unexpected value "pw-wrong-title"', the other two canvas tests pass.\nFlowCanvasPage.tsx and AppRoutes.tsx restored (git diff --quiet verified).\n\n9/9, and 27/27 across all three of my specs, on the assigned ports\n(18403/17703/4403). No production code changed.\n
M3gA-Mind7a066ceeb2d2
diff --git a/app/test/playwright/specs/flows-canvas-routes.spec.ts b/app/test/playwright/specs/flows-canvas-routes.spec.tsnew file mode 100644index 0000000000..8beb5410f8--- /dev/null+++ b/app/test/playwright/specs/flows-canvas-routes.spec.ts@@ -0,0 +1,221 @@+import { expect, test } from '@playwright/test';++import {+ bootAuthenticatedPage,+ callCoreRpc,+ dismissWalkthroughIfPresent,+ waitForAppReady,+} from '../helpers/core-rpc';++/**+ * The Flows routes, driven in a real browser: the list, an existing flow's+ * canvas, the unsaved-draft route, and the two back-compat slugs.+ *+ * Existing coverage is thin and indirect — `skill-lifecycle.spec.ts` only+ * checks that the `flows_list` RPC is reachable, and+ * `top-level-functional-flows.spec.ts` drives the *legacy* SKILL.md+ * `/workflows` CRUD page, which is a different surface from the `flows::`+ * canvas. Nothing opens `/flows/:id`.+ *+ * A note on `/flows/draft`, because the brief expected it to open a canvas and+ * it deliberately does not: the draft graph rides in `location.state`+ * (`FlowCanvasPage.tsx:1536-1546`), so a direct URL hit or a hard reload has no+ * draft and the route renders an empty state on purpose — "rather than a broken+ * canvas". That is the behaviour pinned below. Reaching the draft canvas needs+ * the chat WorkflowProposalCard's "Open in canvas" action, which is a chat-side+ * entry point outside this brief's routes.+ */++const currentHash = (page: import('@playwright/test').Page) =>+ page.evaluate(() => window.location.hash);++/**+ * `flows_create` answers a CLI envelope — `{ result, logs }` — not the flow+ * directly; `flowsApi.createFlow` unwraps it with its own `unwrapCliEnvelope`.+ * Reading `.id` off the raw RPC result yields undefined while the core happily+ * logs `flows_create -> ok`, which is a confusing pair to debug.+ */+async function createFlow(name: string): Promise<string> {+ const payload = await callCoreRpc<unknown>('openhuman.flows_create', {+ name,+ graph: simpleGraph('Manual start'),+ });+ const rec = payload as Record<string, unknown>;+ const flow = (rec && 'result' in rec ? rec.result : rec) as { id?: string };+ const id = flow?.id;+ expect(id, `flows_create returned no id (payload: ${JSON.stringify(payload)})`).toBeTruthy();+ return id as string;+}++/**+ * The create affordance. On an empty account `/flows` renders a marketing empty+ * state whose button carries no testid; once flows exist the list header's+ * `flows-new-workflow` appears. Match on the accessible name so the assertion+ * holds in both states — which is what a user actually sees either way.+ */+const newWorkflowButton = (page: import('@playwright/test').Page) =>+ page.getByRole('button', { name: /new workflow/i }).first();++/**+ * A minimal graph the core accepts. tinyflows nodes are+ * `{ id, kind, name, config }` — `kind` is the discriminator (`NodeKindContract`+ * in `vendor/tinyflows`), NOT the ReactFlow-shaped `{type, position, data}` the+ * canvas components use. Passing the canvas shape here fails validation with+ * `missing field 'kind'`.+ */+function simpleGraph(name: string) {+ return {+ nodes: [{ id: 'trigger', kind: 'trigger', name, config: {} }],+ edges: [],+ };+}++async function goto(page: import('@playwright/test').Page, route: string) {+ await page.evaluate(target => {+ window.location.hash = target;+ }, route);+ await waitForAppReady(page);+ await dismissWalkthroughIfPresent(page);+}++test.describe('Flows — the list page', () => {+ test('renders the list surface with its create affordance', async ({ page }) => {+ // Boot to /home and let its redirect to /chat settle FIRST. Passing '/flows'+ // straight to bootAuthenticatedPage races that redirect, which lands the+ // page back on chat — the failure looks like a missing testid.+ await bootAuthenticatedPage(page, 'pw-flows-list', '/home');+ await dismissWalkthroughIfPresent(page);+ await goto(page, '/flows');++ await expect(newWorkflowButton(page)).toBeVisible({ timeout: 20_000 });+ // And the page is the Flows surface, not some other page that happens to+ // have a similarly named button.+ expect(await currentHash(page)).toContain('/flows');+ });+});++test.describe('Flows — an existing flow opens its canvas', () => {+ test('/flows/:id loads the saved flow and shows its title', async ({ page }) => {+ const name = `pw-flow-${Date.now()}`;+ const flowId = await createFlow(name);++ await bootAuthenticatedPage(page, 'pw-flows-canvas', '/home');+ await dismissWalkthroughIfPresent(page);+ await goto(page, `/flows/${flowId}`);++ // The canvas header carries the flow name; `flow-canvas-not-found` is the+ // negative case and must NOT be what renders.+ await expect(page.getByTestId('flow-canvas-title')).toBeVisible({ timeout: 20_000 });+ // `flow-canvas-title` is an <input> (the rename field, FlowCanvasPage:1145-1150),+ // so the name is its VALUE. `toContainText` reads text content and would+ // always see "" here — a green-looking assertion that checks nothing.+ await expect(page.getByTestId('flow-canvas-title')).toHaveValue(name);+ await expect(page.getByTestId('flow-canvas-not-found')).toHaveCount(0);+ });++ test('an unknown flow id shows the not-found state, not a blank canvas', async ({ page }) => {+ await bootAuthenticatedPage(page, 'pw-flows-404', '/home');+ await dismissWalkthroughIfPresent(page);+ await goto(page, '/flows/pw-definitely-not-a-real-flow-id');++ await expect(+ page.getByTestId('flow-canvas-not-found').or(page.getByTestId('flow-canvas-error')).first()+ ).toBeVisible({ timeout: 20_000 });+ // A back affordance must exist so the user is not stranded.+ await expect(page.getByTestId('flow-canvas-back')).toBeVisible();+ });++ test('the canvas back button returns to the list', async ({ page }) => {+ const name = `pw-flow-back-${Date.now()}`;+ const flowId = await createFlow(name);++ await bootAuthenticatedPage(page, 'pw-flows-back', '/home');+ await dismissWalkthroughIfPresent(page);+ await goto(page, `/flows/${flowId}`);+ await expect(page.getByTestId('flow-canvas-title')).toBeVisible({ timeout: 20_000 });++ await page.getByTestId('flow-canvas-back').click();+ await expect.poll(() => currentHash(page), { timeout: 15_000 }).toContain('/flows');+ await expect(newWorkflowButton(page)).toBeVisible({ timeout: 20_000 });+ });+});++test.describe('Flows — the unsaved draft route', () => {+ test('/flows/draft hit directly shows an empty state, not a broken canvas', async ({ page }) => {+ // Pinning documented behaviour: the draft graph lives in `location.state`,+ // so a direct hit or a reload legitimately has nothing to render+ // (FlowCanvasPage.tsx:1541-1545).+ await bootAuthenticatedPage(page, 'pw-flows-draft', '/home');+ await dismissWalkthroughIfPresent(page);+ await goto(page, '/flows/draft');++ // No canvas, and no crash: the back affordance is what proves we landed on+ // the deliberate empty state rather than a blank screen.+ await expect(page.getByTestId('flow-canvas-back')).toBeVisible({ timeout: 20_000 });+ await expect(page.getByTestId('flow-canvas-title')).toHaveCount(0);+ });++ test('"draft" is not treated as a flow id', async ({ page }) => {+ // The route order matters: `/flows/draft` is declared before `/flows/:id`+ // (AppRoutes.tsx:119-131) precisely so `:id` cannot capture "draft" and+ // fire `flows_get('draft')`. If that order regressed, the not-found state+ // would render instead of the draft empty state.+ await bootAuthenticatedPage(page, 'pw-flows-draft-order', '/home');+ await dismissWalkthroughIfPresent(page);+ await goto(page, '/flows/draft');++ await expect(page.getByTestId('flow-canvas-back')).toBeVisible({ timeout: 20_000 });+ await expect(page.getByTestId('flow-canvas-not-found')).toHaveCount(0);+ });+});++test.describe('Flows — the back-compat slugs resolve distinctly', () => {+ // These three are NOT interchangeable, and an earlier draft of this file+ // asserted only "body is non-empty and some button is visible" — which the+ // chat surface satisfies, so it passed without ever reaching the right page.+ // Each now asserts the specific surface it must land on.++ test('/routines redirects to the Flows list', async ({ page }) => {+ // AppRoutes.tsx:215 — <Navigate to="/flows" replace />.+ await bootAuthenticatedPage(page, 'pw-slug-routines', '/home');+ await dismissWalkthroughIfPresent(page);+ await goto(page, '/routines');++ await expect.poll(() => currentHash(page), { timeout: 15_000 }).toContain('/flows');+ await expect(newWorkflowButton(page)).toBeVisible({ timeout: 20_000 });+ });++ test('/workflows keeps the legacy hub and does NOT redirect to Flows', async ({ page }) => {+ // AppRoutes.tsx:229 renders <Activity />, deliberately: the comment there+ // says "Keep the legacy top-level hub reachable". Conflating it with /flows+ // is the mistake this test exists to catch.+ await bootAuthenticatedPage(page, 'pw-slug-workflows', '/home');+ await dismissWalkthroughIfPresent(page);+ await goto(page, '/workflows');++ expect(await currentHash(page)).toContain('/workflows');+ expect(await currentHash(page)).not.toContain('/flows');+ // Its own create affordance, not the Flows one.+ await expect(page.getByTestId('workflows-create-btn')).toBeVisible({ timeout: 20_000 });+ await expect(page.getByTestId('flows-new-workflow')).toHaveCount(0);+ });++ test('/webhooks resolves through two hops and lands on Connections', async ({ page }) => {+ // Two redirects, not one: AppRoutes.tsx:238 sends /webhooks to+ // /settings/integrations, and settingsRouteElements.tsx:129 sends THAT to+ // /connections. The intermediate target no longer exists as a page.+ //+ // Worth knowing when reading the code: the repo docs describe this hop as+ // landing on `/settings/integrations#webhooks`, but no `#webhooks` fragment+ // survives either hop, so an old webhooks bookmark arrives at the generic+ // Connections page with nothing pointing at where webhooks went. Recorded+ // in W3-ui-bugs.md; this test pins the CURRENT destination.+ await bootAuthenticatedPage(page, 'pw-slug-webhooks', '/home');+ await dismissWalkthroughIfPresent(page);+ await goto(page, '/webhooks');++ await expect.poll(() => currentHash(page), { timeout: 15_000 }).toContain('/connections');+ // And it does not strand the user mid-hop on a route with no page.+ expect(await currentHash(page)).not.toContain('/settings/integrations');+ });+});