diff --git a/packages/bus/tests/person-task-verbs.test.mjs b/packages/bus/tests/person-task-verbs.test.mjs index 3bfd8d245..e8ad2fd97 100644 --- a/packages/bus/tests/person-task-verbs.test.mjs +++ b/packages/bus/tests/person-task-verbs.test.mjs @@ -1,6 +1,6 @@ import test from 'node:test'; import assert from 'node:assert/strict'; -import { mkdtempSync, rmSync } from 'node:fs'; +import { mkdtempSync, readFileSync, rmSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import * as bus from '../src/broker.mjs'; @@ -27,6 +27,12 @@ test('person task vocabulary pins exactly the five frozen store verbs', () => { assert.ok(Object.isFrozen(bus.PERSON_TASK_VERBS)); }); +test('every person task handler is declared in the vocabulary, even if the dispatch guard regresses', () => { + const source = readFileSync(new URL('../src/broker.mjs', import.meta.url), 'utf8'); + const handlers = [...source.matchAll(/^\s*case\s+(['"])(tasks\.[^'"]+)\1\s*:/gm)].map(match => match[2]); + assert.deepEqual(handlers.sort(), [...bus.PERSON_TASK_VERBS].sort()); +}); + test('every listed person task verb reaches its handler, while an unlisted verb is unknown', t => { const { broker, human } = fixture(t); assert.ok(Array.isArray(bus.PERSON_TASK_VERBS));