ktg-plugin-marketplace/plugins/voyage/tests/validators/research-validator.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

60 lines
1.9 KiB
JavaScript

import { test } from 'node:test';
import { strict as assert } from 'node:assert';
import { validateResearchContent } from '../../lib/validators/research-validator.mjs';
const GOOD = `---
type: trekresearch-brief
created: 2026-04-30
question: "How to do X?"
confidence: 0.8
dimensions: 3
---
## Executive Summary
3 sentences.
## Dimensions
### Dim A — Confidence: high
`;
test('validateResearch — happy path', () => {
const r = validateResearchContent(GOOD);
assert.equal(r.valid, true, JSON.stringify(r.errors));
});
test('validateResearch — wrong type', () => {
const t = GOOD.replace('type: trekresearch-brief', 'type: random');
const r = validateResearchContent(t);
assert.equal(r.valid, false);
assert.ok(r.errors.find(e => e.code === 'RESEARCH_WRONG_TYPE'));
});
test('validateResearch — confidence out of range', () => {
const t = GOOD.replace('confidence: 0.8', 'confidence: 1.5');
const r = validateResearchContent(t);
assert.equal(r.valid, false);
assert.ok(r.errors.find(e => e.code === 'RESEARCH_BAD_CONFIDENCE'));
});
test('validateResearch — missing confidence is warning, not error', () => {
const t = GOOD.replace(/^confidence: 0\.8\n/m, '');
const r = validateResearchContent(t);
assert.equal(r.valid, true);
assert.ok(r.warnings.find(w => w.code === 'RESEARCH_NO_CONFIDENCE'));
});
test('validateResearch — strict missing body section is error', () => {
const t = GOOD.replace(/## Dimensions\n\n### Dim A — Confidence: high\n/, '');
const r = validateResearchContent(t, { strict: true });
assert.equal(r.valid, false);
assert.ok(r.errors.find(e => e.code === 'RESEARCH_MISSING_SECTION'));
});
test('validateResearch — bad dimensions value', () => {
const t = GOOD.replace('dimensions: 3', 'dimensions: 0');
const r = validateResearchContent(t);
assert.equal(r.valid, false);
assert.ok(r.errors.find(e => e.code === 'RESEARCH_BAD_DIMENSIONS'));
});