chore(web): swap flowsApi mock for real NF-7 endpoints (#366) #368

Merged
code-lead merged 1 commit from chore/366-flowsapi-real-endpoints into main 2026-04-25 09:45:01 +00:00
Collaborator

Replaces every mock body in apps/web/src/features/flows/flowsApi.ts with fetch calls against the NF-7 server surface (#363) + the NF-4 read-only routes (#352). Auth flows through the browser cookie via credentials: "same-origin" — the web client doesn't manage tokens.

Endpoints wired

  • GET /flowslist()
  • GET /flows/:idgetFlow(id)
  • GET /flows/:id/versions/:versiongetFlow(id, version) (replay pin)
  • GET /flows/:id/versionslistVersions(id) (for NF-UI-9)
  • PATCH /flows/:idupdateFlow(id, body, patch)
  • POST /flows/:id/enable / disablesetEnabled(id, enabled)
  • DELETE /flows/:idremove(id)
  • POST /flows/:id/dry-runtestFire(flowId, payload)
  • POST /flows/:id/revert?version=NrevertFlow(id, version) (for NF-UI-9)
  • GET /flows/runs?flow_id&before&limitlistRuns(opts)
  • GET /flows/runs/:idgetRun(runId)

Bundled server-side change

NF-4 GET /flows's toSummary shipped a leaner shape than the client's FlowSummary (no description / priority / mutex_group / repo_patterns / created_at / created_by). Extended apps/server/src/http/flows-routes.ts::toSummary to parse those fields out of the body JSON (defensive defaults on malformed bodies). Required for the list page filters + toolbar to work post-swap.

Test harness

Existing tests call __setMockLatency / __resetMockStore / __resetRunsMockStore / __setMockOperator — preserved as a back-compat surface that drives a globalThis.fetch mock. The mock emits server-shaped responses from the seed JSON (flows.json, flow-graphs.json, flow-runs.json) so existing test files compile + pass without rewrites.

Out of scope (still mocked)

  • GET /flows/mode — server endpoint not yet shipped. getMode() still reads the seed fixture; flagged inline as TODO(server). Filing a follow-up.
  • GET /flows/fixtures — same story for the test-fire fixture library. Mock retained, flagged.

Test plan

  • bun x turbo run typecheck — 4/4 packages clean.
  • bun x biome check — clean on touched files.
  • bun test apps/server — 1789 pass, 4 pre-existing fails (sweeper / foreman, identical on main).
  • bun run test (web) — 369 pass, 11 pre-existing theme / pipeline-graph fails (identical on main).
  • Existing flowsApi-dependent tests (FlowList, FlowCanvas editor + replay, RunsDrawer, Inspector, TestFireModal) all green via the harness.
  • Operator: against a live service, open /app/flows, edit a flow, save, fire test event, watch the runs drawer populate.

Closes #366.

🤖 Generated with Claude Code

Replaces every mock body in `apps/web/src/features/flows/flowsApi.ts` with `fetch` calls against the NF-7 server surface (#363) + the NF-4 read-only routes (#352). Auth flows through the browser cookie via `credentials: "same-origin"` — the web client doesn't manage tokens. ## Endpoints wired - `GET /flows` → `list()` - `GET /flows/:id` → `getFlow(id)` - `GET /flows/:id/versions/:version` → `getFlow(id, version)` (replay pin) - `GET /flows/:id/versions` → `listVersions(id)` (for NF-UI-9) - `PATCH /flows/:id` → `updateFlow(id, body, patch)` - `POST /flows/:id/enable` / `disable` → `setEnabled(id, enabled)` - `DELETE /flows/:id` → `remove(id)` - `POST /flows/:id/dry-run` → `testFire(flowId, payload)` - `POST /flows/:id/revert?version=N` → `revertFlow(id, version)` (for NF-UI-9) - `GET /flows/runs?flow_id&before&limit` → `listRuns(opts)` - `GET /flows/runs/:id` → `getRun(runId)` ## Bundled server-side change NF-4 `GET /flows`'s `toSummary` shipped a leaner shape than the client's `FlowSummary` (no description / priority / mutex_group / repo_patterns / created_at / created_by). Extended `apps/server/src/http/flows-routes.ts::toSummary` to parse those fields out of the body JSON (defensive defaults on malformed bodies). Required for the list page filters + toolbar to work post-swap. ## Test harness Existing tests call `__setMockLatency` / `__resetMockStore` / `__resetRunsMockStore` / `__setMockOperator` — preserved as a back-compat surface that drives a `globalThis.fetch` mock. The mock emits server-shaped responses from the seed JSON (`flows.json`, `flow-graphs.json`, `flow-runs.json`) so existing test files compile + pass without rewrites. ## Out of scope (still mocked) - `GET /flows/mode` — server endpoint not yet shipped. `getMode()` still reads the seed fixture; flagged inline as `TODO(server)`. Filing a follow-up. - `GET /flows/fixtures` — same story for the test-fire fixture library. Mock retained, flagged. ## Test plan - [x] `bun x turbo run typecheck` — 4/4 packages clean. - [x] `bun x biome check` — clean on touched files. - [x] `bun test apps/server` — 1789 pass, 4 pre-existing fails (sweeper / foreman, identical on main). - [x] `bun run test` (web) — 369 pass, 11 pre-existing theme / pipeline-graph fails (identical on main). - [x] Existing flowsApi-dependent tests (FlowList, FlowCanvas editor + replay, RunsDrawer, Inspector, TestFireModal) all green via the harness. - [ ] Operator: against a live service, open `/app/flows`, edit a flow, save, fire test event, watch the runs drawer populate. Closes #366. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chore(web): swap flowsApi mock for real NF-7 endpoints (#366)
All checks were successful
qa / qa (pull_request) Successful in 5m38s
qa / dockerfile (pull_request) Successful in 9s
fb2a8b5e03
Replaces every mock body in `apps/web/src/features/flows/flowsApi.ts`
with `fetch` calls against the NF-7 server surface (#363) + the NF-4
read-only routes (#352). Auth flows through the browser cookie via
`credentials: "same-origin"` — no token plumbing in the client.

## Endpoints wired

- `GET /flows`            — list()
- `GET /flows/:id`        — getFlow(id)
- `GET /flows/:id/versions/:version` — getFlow(id, version) (replay pin)
- `GET /flows/:id/versions` — listVersions(id) (NF-UI-9)
- `PATCH /flows/:id`      — updateFlow(id, body, patch)
- `POST /flows/:id/enable` / `disable` — setEnabled(id, enabled)
- `DELETE /flows/:id`     — remove(id)
- `POST /flows/:id/dry-run` — testFire(flowId, payload)
- `POST /flows/:id/revert?version=N` — revertFlow(id, version) (NF-UI-9)
- `GET /flows/runs?flow_id&before&limit` — listRuns(opts)
- `GET /flows/runs/:id`   — getRun(runId)

## Bundled server-side change

The NF-4 `GET /flows` summary shipped only `{ id, version, source,
enabled, on:{trigger}, updated_at }` — leaner than the client's
`FlowSummary` (description, priority, mutex_group, repo_patterns,
created_at, created_by). Extended `apps/server/src/http/flows-routes.ts`
`toSummary` to parse those out of the body JSON (with defensive
defaults on malformed bodies). Required for the list page filters +
toolbar to work post-swap.

## Test harness

Tests still call `__setMockLatency` / `__resetMockStore` /
`__resetRunsMockStore` / `__setMockOperator` etc. — preserved as a
back-compat surface that drives a `globalThis.fetch` mock. The mock
emits server-shaped responses out of the seed JSON (flows.json,
flow-graphs.json, flow-runs.json) so existing test files compile +
pass without rewrites. Net: 369 web tests pass, 4 pre-existing theme/
pipeline-graph failures unchanged.

## Out of scope

- `GET /flows/mode` — server endpoint not yet shipped. `getMode()`
  still reads the seed fixture; flagged inline as TODO(server).
- `GET /flows/fixtures` — same story for the test-fire fixture
  library. Mock retained.

## Test plan

- [x] `bun x turbo run typecheck` — 4/4 packages clean
- [x] `bun x biome check` — clean on touched files
- [x] `bun test apps/server` — 1789 pass, 4 pre-existing fails (sweeper / foreman)
- [x] `bun run test` (web) — 369 pass, 11 pre-existing theme/pipeline-graph fails
- [x] Existing flowsApi-dependent tests (FlowList, FlowCanvas editor + replay,
      RunsDrawer, Inspector, TestFireModal) all green via the harness.

Closes #366.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
code-lead deleted branch chore/366-flowsapi-real-endpoints 2026-04-25 09:45:02 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks!368
No description provided.