task-loop-rrule-store.test.mjs
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠ breaking
10 days ago
| 1 | /** |
| 2 | * Tier 2 — INTEGRATION: Store read with rrule recurrence + trigger_bindings on school-trip. |
| 3 | */ |
| 4 | import { describe, it, beforeEach, afterEach } from 'node:test'; |
| 5 | import assert from 'node:assert/strict'; |
| 6 | import fs from 'node:fs'; |
| 7 | import path from 'node:path'; |
| 8 | import { fileURLToPath } from 'node:url'; |
| 9 | import { getRepoRoot } from '../lib/repo-root.mjs'; |
| 10 | import { getTaskLoop, listTaskLoops } from '../lib/task/task-loop-store.mjs'; |
| 11 | |
| 12 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 13 | const tmpRoot = path.join(__dirname, 'fixtures', 'tmp-task-loop-rrule-store'); |
| 14 | const loopStarterDir = path.join(getRepoRoot(), 'task-loops/starter'); |
| 15 | const graphStarterDir = path.join(getRepoRoot(), 'orchestrator-graphs/starter'); |
| 16 | const instancesDir = path.join(getRepoRoot(), 'task-loops/starter/instances'); |
| 17 | const vaultId = 'vault-loop-rrule-store'; |
| 18 | |
| 19 | describe('Task loop RRULE — store integration', () => { |
| 20 | beforeEach(() => { |
| 21 | fs.rmSync(tmpRoot, { recursive: true, force: true }); |
| 22 | fs.mkdirSync(tmpRoot, { recursive: true }); |
| 23 | }); |
| 24 | |
| 25 | afterEach(() => { |
| 26 | fs.rmSync(tmpRoot, { recursive: true, force: true }); |
| 27 | }); |
| 28 | |
| 29 | it('listTaskLoops seeds loop_weekly_checkin with rrule recurrence', () => { |
| 30 | const dataDir = path.join(tmpRoot, 'data'); |
| 31 | fs.mkdirSync(dataDir, { recursive: true }); |
| 32 | |
| 33 | const result = listTaskLoops(dataDir, vaultId, { |
| 34 | visibleScopes: new Set(['personal', 'project', 'org']), |
| 35 | filterScopes: new Set(['personal', 'project', 'org']), |
| 36 | effectiveScope: 'org', |
| 37 | starterDir: loopStarterDir, |
| 38 | graphsDir: graphStarterDir, |
| 39 | instancesDir, |
| 40 | }); |
| 41 | |
| 42 | assert.equal(result.loops.length, 6); |
| 43 | assert.ok(result.loops.some((row) => row.loop_id === 'loop_weekly_checkin')); |
| 44 | }); |
| 45 | |
| 46 | it('getTaskLoop returns rrule recurrence for loop_weekly_checkin', () => { |
| 47 | const dataDir = path.join(tmpRoot, 'data-get'); |
| 48 | fs.mkdirSync(dataDir, { recursive: true }); |
| 49 | |
| 50 | listTaskLoops(dataDir, vaultId, { |
| 51 | visibleScopes: new Set(['personal', 'project', 'org']), |
| 52 | filterScopes: new Set(['personal', 'project', 'org']), |
| 53 | effectiveScope: 'org', |
| 54 | starterDir: loopStarterDir, |
| 55 | graphsDir: graphStarterDir, |
| 56 | instancesDir, |
| 57 | }); |
| 58 | |
| 59 | const row = getTaskLoop(dataDir, vaultId, 'loop_weekly_checkin', { |
| 60 | visibleScopes: new Set(['personal', 'project', 'org']), |
| 61 | }); |
| 62 | assert.ok(row); |
| 63 | if (!row) return; |
| 64 | assert.equal(row.recurrence.kind, 'rrule'); |
| 65 | assert.equal(row.recurrence.rrule, 'FREQ=WEEKLY;BYDAY=MO'); |
| 66 | }); |
| 67 | |
| 68 | it('getTaskLoop returns trigger_bindings on loop_school_trip', () => { |
| 69 | const dataDir = path.join(tmpRoot, 'data-bindings'); |
| 70 | fs.mkdirSync(dataDir, { recursive: true }); |
| 71 | |
| 72 | listTaskLoops(dataDir, vaultId, { |
| 73 | visibleScopes: new Set(['personal', 'project', 'org']), |
| 74 | filterScopes: new Set(['personal', 'project', 'org']), |
| 75 | effectiveScope: 'org', |
| 76 | starterDir: loopStarterDir, |
| 77 | graphsDir: graphStarterDir, |
| 78 | instancesDir, |
| 79 | }); |
| 80 | |
| 81 | const row = getTaskLoop(dataDir, vaultId, 'loop_school_trip', { |
| 82 | visibleScopes: new Set(['personal', 'project', 'org']), |
| 83 | }); |
| 84 | assert.ok(row); |
| 85 | if (!row) return; |
| 86 | assert.ok(Array.isArray(row.trigger_bindings)); |
| 87 | assert.equal(row.trigger_bindings.length, 1); |
| 88 | assert.equal(row.trigger_bindings[0].signal_kind, 'note_edit'); |
| 89 | }); |
| 90 | }); |
File History
1 commit
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠
10 days ago