task-loop-store-e2e.test.mjs
69 lines 2.5 KB
Raw
sha256:c2dbf04d56308f3bbf2d06e6d2eb022b8948b1e827195fe525a44e5e18d5f9c0 feat(auth): Phase B Connect cloud agent (RFC 8628) + Hermes… Human minor ⚠ breaking 11 days ago
1 /**
2 * Tier 3 — E2E: School-trip fixture graph seed → instance task with loop_ref.
3 *
4 * @see docs/TASK-LOOP-STORE-CONTRACT-2G-c.md §6 — I-T-LOOP-01
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 { getRepoRoot } from '../lib/repo-root.mjs';
12 import { listTaskLoops } from '../lib/task/task-loop-store.mjs';
13 import { listTasks, getTask } from '../lib/task/task-store.mjs';
14
15 const __dirname = path.dirname(fileURLToPath(import.meta.url));
16 const tmpRoot = path.join(__dirname, 'fixtures', 'tmp-task-loop-e2e');
17 const loopStarterDir = path.join(getRepoRoot(), 'task-loops/starter');
18 const graphStarterDir = path.join(getRepoRoot(), 'orchestrator-graphs/starter');
19 const instancesDir = path.join(getRepoRoot(), 'task-loops/starter/instances');
20 const vaultId = 'vault-loop-e2e';
21
22 describe('Task loop store — e2e school-trip graph', () => {
23 beforeEach(() => {
24 fs.rmSync(tmpRoot, { recursive: true, force: true });
25 fs.mkdirSync(tmpRoot, { recursive: true });
26 });
27
28 afterEach(() => {
29 fs.rmSync(tmpRoot, { recursive: true, force: true });
30 });
31
32 it('seeds loops + graph + instance; getTask returns loop_ref and occurrence_key', () => {
33 const dataDir = path.join(tmpRoot, 'data');
34 fs.mkdirSync(dataDir, { recursive: true });
35
36 const loopList = listTaskLoops(dataDir, vaultId, {
37 visibleScopes: new Set(['personal']),
38 filterScopes: new Set(['personal']),
39 effectiveScope: 'personal',
40 starterDir: loopStarterDir,
41 graphsDir: graphStarterDir,
42 instancesDir,
43 });
44
45 assert.equal(loopList.loops.length, 6);
46 assert.ok(loopList.loops.some((l) => l.loop_id === 'loop_school_trip'));
47
48 const taskList = listTasks(dataDir, vaultId, {
49 visibleScopes: new Set(['personal']),
50 filterScopes: new Set(['personal']),
51 effectiveScope: 'personal',
52 loopRef: 'loop_school_trip',
53 starterDir: instancesDir,
54 });
55
56 assert.equal(taskList.tasks.length, 1);
57 assert.equal(taskList.tasks[0].task_id, 'task_school_trip_2026_w25');
58
59 const task = getTask(dataDir, vaultId, 'task_school_trip_2026_w25', {
60 visibleScopes: new Set(['personal']),
61 starterDir: instancesDir,
62 });
63
64 assert.ok(task);
65 assert.equal(task.loop_ref, 'loop_school_trip');
66 assert.equal(task.occurrence_key, '2026-W25');
67 assert.equal(task.run_ref, null);
68 });
69 });
File History 1 commit
sha256:93bcf8f9bd56d8c5b9339f4ec73b9ebd66571398d56262d38eedc2cfa9db9882 fix(test): align Band B landing assertion with desktop MCP … Human 11 days ago