flow-store-e2e.test.mjs
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
11 hours ago
| 1 | /** |
| 2 | * Tier 3 — E2E: empty vault seed walkthrough and scope-filtered list/get. |
| 3 | * |
| 4 | * @see docs/FLOW-STORE-CONTRACT-7A-10.md §9 |
| 5 | */ |
| 6 | import { describe, it, beforeEach, afterEach } from 'node:test'; |
| 7 | import assert from 'node:assert/strict'; |
| 8 | import fs from 'node:fs'; |
| 9 | import path from 'node:path'; |
| 10 | import { fileURLToPath } from 'node:url'; |
| 11 | import { handleFlowListRequest, handleFlowGetRequest } from '../lib/flow/flow-handlers.mjs'; |
| 12 | import { getRepoRoot } from '../lib/repo-root.mjs'; |
| 13 | |
| 14 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 15 | const tmpRoot = path.join(__dirname, 'fixtures', 'tmp-flow-e2e'); |
| 16 | const starterDir = path.join(getRepoRoot(), 'flows/starter'); |
| 17 | |
| 18 | describe('E2E — Flow read walkthrough', () => { |
| 19 | const dataDir = path.join(tmpRoot, 'data'); |
| 20 | const vaultId = 'default'; |
| 21 | |
| 22 | beforeEach(() => { |
| 23 | fs.rmSync(tmpRoot, { recursive: true, force: true }); |
| 24 | fs.mkdirSync(dataDir, { recursive: true }); |
| 25 | }); |
| 26 | |
| 27 | afterEach(() => { |
| 28 | fs.rmSync(tmpRoot, { recursive: true, force: true }); |
| 29 | }); |
| 30 | |
| 31 | it('empty vault → first list seeds six starters → get handover returns six ordered steps', () => { |
| 32 | const list = handleFlowListRequest({ |
| 33 | dataDir, |
| 34 | vaultId, |
| 35 | role: 'admin', |
| 36 | starterDir, |
| 37 | }); |
| 38 | assert.equal(list.ok, true); |
| 39 | assert.equal(list.payload.flows.length, 6); |
| 40 | |
| 41 | const got = handleFlowGetRequest({ |
| 42 | dataDir, |
| 43 | vaultId, |
| 44 | flowId: 'flow_overseer_handover', |
| 45 | role: 'admin', |
| 46 | starterDir, |
| 47 | }); |
| 48 | assert.equal(got.ok, true); |
| 49 | assert.equal(got.payload.steps.length, 6); |
| 50 | const kinds = new Set(got.payload.steps.map((s) => s.verification.kind)); |
| 51 | assert.ok(kinds.has('human_review')); |
| 52 | assert.ok(kinds.has('artifact_exists')); |
| 53 | }); |
| 54 | |
| 55 | it('list --scope personal returns exactly four personal flows', () => { |
| 56 | handleFlowListRequest({ dataDir, vaultId, role: 'admin', starterDir }); |
| 57 | const personal = handleFlowListRequest({ |
| 58 | dataDir, |
| 59 | vaultId, |
| 60 | role: 'admin', |
| 61 | scope: 'personal', |
| 62 | starterDir, |
| 63 | }); |
| 64 | assert.equal(personal.ok, true); |
| 65 | assert.equal(personal.payload.flows.length, 4); |
| 66 | assert.ok(personal.payload.flows.every((f) => f.scope === 'personal')); |
| 67 | }); |
| 68 | |
| 69 | it('pinned version returns that version; absent returns latest', () => { |
| 70 | handleFlowListRequest({ dataDir, vaultId, role: 'admin', starterDir }); |
| 71 | const latest = handleFlowGetRequest({ |
| 72 | dataDir, |
| 73 | vaultId, |
| 74 | flowId: 'flow_capture_to_note', |
| 75 | role: 'admin', |
| 76 | starterDir, |
| 77 | }); |
| 78 | assert.equal(latest.ok, true); |
| 79 | assert.equal(latest.payload.flow.version, '0.1.0'); |
| 80 | |
| 81 | const pinned = handleFlowGetRequest({ |
| 82 | dataDir, |
| 83 | vaultId, |
| 84 | flowId: 'flow_capture_to_note', |
| 85 | version: '0.1.0', |
| 86 | role: 'admin', |
| 87 | starterDir, |
| 88 | }); |
| 89 | assert.equal(pinned.ok, true); |
| 90 | assert.equal(pinned.payload.flow.version, '0.1.0'); |
| 91 | }); |
| 92 | }); |
File History
1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
11 hours ago