ktg-plugin-marketplace/plugins/voyage/tests/validators/architecture-discovery.test.mjs
Kjell Tore Guttormsen 7a90d348ad feat(voyage)!: marketplace handoff — rename plugins/ultraplan-local to plugins/voyage [skip-docs]
Session 5 of voyage-rebrand (V6). Operator-authorized cross-plugin scope.

- git mv plugins/ultraplan-local plugins/voyage (rename detected, history preserved)
- .claude-plugin/marketplace.json: voyage entry replaces ultraplan-local
- CLAUDE.md: voyage row in plugin list, voyage in design-system consumer list
- README.md: bulk rename ultra*-local commands -> trek* commands; ultraplan-local refs -> voyage; type discriminators (type: trekbrief/trekreview); session-title pattern (voyage:<command>:<slug>); v4.0.0 release-note paragraph
- plugins/voyage/.claude-plugin/plugin.json: homepage/repository URLs point to monorepo voyage path
- plugins/voyage/verify.sh: drop URL whitelist exception (no longer needed)

Closes voyage-rebrand. bash plugins/voyage/verify.sh PASS 7/7. npm test 361/361.
2026-05-05 15:37:52 +02:00

81 lines
3 KiB
JavaScript

import { test } from 'node:test';
import { strict as assert } from 'node:assert';
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { discoverArchitecture } from '../../lib/validators/architecture-discovery.mjs';
function setup(structure) {
const root = mkdtempSync(join(tmpdir(), 'trekplan-arch-'));
for (const [path, content] of Object.entries(structure)) {
const full = join(root, path);
mkdirSync(join(full, '..'), { recursive: true });
writeFileSync(full, content);
}
return root;
}
test('discoverArchitecture — canonical overview.md found cleanly', () => {
const root = setup({ 'architecture/overview.md': '# Overview\n' });
try {
const r = discoverArchitecture(root);
assert.equal(r.found, true);
assert.match(r.overview, /architecture\/overview\.md$/);
assert.equal(r.warnings.length, 0);
assert.equal(r.firstHeading, 'Overview');
} finally { rmSync(root, { recursive: true, force: true }); }
});
test('discoverArchitecture — no architecture dir = not found, no warnings', () => {
const root = setup({ 'brief.md': 'b' });
try {
const r = discoverArchitecture(root);
assert.equal(r.found, false);
assert.equal(r.warnings.length, 0);
} finally { rmSync(root, { recursive: true, force: true }); }
});
test('discoverArchitecture — non-canonical name discovered with warning (drift-WARN)', () => {
const root = setup({ 'architecture/architecture-overview.md': '# Drifted\n' });
try {
const r = discoverArchitecture(root);
assert.equal(r.found, true);
assert.ok(r.warnings.find(w => w.code === 'ARCH_NON_CANONICAL_OVERVIEW'));
} finally { rmSync(root, { recursive: true, force: true }); }
});
test('discoverArchitecture — loose unknown files surfaced as drift warning', () => {
const root = setup({
'architecture/overview.md': '# OK\n',
'architecture/random-note.md': 'x',
'architecture/another.md': 'y',
});
try {
const r = discoverArchitecture(root);
assert.equal(r.found, true);
assert.ok(r.warnings.find(w => w.code === 'ARCH_LOOSE_FILES'));
assert.equal(r.looseFiles.length, 2);
} finally { rmSync(root, { recursive: true, force: true }); }
});
test('discoverArchitecture — gaps.md detected when present', () => {
const root = setup({
'architecture/overview.md': '# OK\n',
'architecture/gaps.md': '# Gaps\n',
});
try {
const r = discoverArchitecture(root);
assert.match(r.gaps, /architecture\/gaps\.md$/);
} finally { rmSync(root, { recursive: true, force: true }); }
});
test('discoverArchitecture — never reads body beyond first heading', () => {
const root = setup({
'architecture/overview.md': '# Overview\n\n## Components\n\nlots of detail that we MUST NOT validate\n',
});
try {
const r = discoverArchitecture(root);
assert.equal(r.firstHeading, 'Overview');
// Validator does not assert on Components section — that's the contract.
} finally { rmSync(root, { recursive: true, force: true }); }
});