Files
msd-core/tests/import-command.test.cjs
Jakub Zych a9a7a328e6 refactor: hard-fork GSD -> MSD (Make Software Done)
Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD
across contents and paths, upstream package/repo coordinates -> @golem15/msd-core
and golem15com/msd-core. Deep links into upstream history, sibling upstream
packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is.

Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line,
package/plugin identity, regenerated lockfile, install-tree fixtures, derived
registries and benchmark baseline; migration checksum baseline re-locked
(MSD keeps its own install state, so no install had applied the old sums);
sort-order and regex-escaped expectations in tests adjusted.
2026-10-06 01:47:40 +02:00

127 lines
4.7 KiB
JavaScript

// allow-test-rule: source-text-is-the-product
// Workflow .md / agent .md / command .md / reference .md files — their text
// IS what the runtime loads. Testing text content tests the deployed contract.
// Per CONTRIBUTING.md exception matrix.
/**
* Import Command Tests — import-command.test.cjs
*
* Structural assertions for the /msd-import command and workflow files.
*/
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const CMD_PATH = path.join(__dirname, '..', 'commands', 'msd', 'import.md');
const WF_PATH = path.join(__dirname, '..', 'msd-core', 'workflows', 'import.md');
// ─── File Existence ────────────────────────────────────────────────────────────
describe('import command file structure', () => {
test('command file exists', () => {
assert.ok(fs.existsSync(CMD_PATH), 'commands/msd/import.md should exist');
});
test('workflow file exists', () => {
assert.ok(fs.existsSync(WF_PATH), 'msd-core/workflows/import.md should exist');
});
});
// ─── Command Frontmatter ───────────────────────────────────────────────────────
describe('import command frontmatter', () => {
const content = fs.readFileSync(CMD_PATH, 'utf-8');
test('has name field', () => {
assert.match(content, /^name:\s*msd:import$/m);
});
test('has description field', () => {
assert.match(content, /^description:\s*.+$/m);
});
test('has argument-hint with --from', () => {
assert.match(content, /^argument-hint:.*--from/m);
});
});
// ─── Command References Workflow ───────────────────────────────────────────────
describe('import command references', () => {
const content = fs.readFileSync(CMD_PATH, 'utf-8');
test('references the import workflow', () => {
assert.ok(
content.includes('@~/.claude/msd-core/workflows/import.md'),
'command should reference the workflow via @~/.claude/msd-core/workflows/import.md'
);
});
});
// ─── Workflow Content ──────────────────────────────────────────────────────────
describe('import workflow content', () => {
const content = fs.readFileSync(WF_PATH, 'utf-8');
test('contains --from mode handling', () => {
assert.ok(
content.includes('--from'),
'workflow should contain --from mode handling'
);
});
test('does NOT contain --prd implementation', () => {
// --prd should be mentioned as deferred/future only, not implemented
assert.ok(
content.includes('--prd'),
'workflow should mention --prd exists'
);
assert.ok(
content.includes('not yet implemented') || content.includes('follow-up PR') || content.includes('future release'),
'workflow should defer --prd to a future release'
);
// Should not have a full "Path B: MODE=prd" implementation section
assert.ok(
!content.includes('## Path B: MODE=prd'),
'workflow should NOT have a Path B implementation for --prd'
);
});
test('references path validation for --from argument', () => {
// After fix: inline path check instead of security.cjs CLI invocation
assert.ok(
content.includes('traversal') || content.includes('validatePath') || content.includes('..'),
'workflow should validate the file path'
);
});
test('includes REQUIREMENTS.md in conflict detection context loading', () => {
assert.ok(
content.includes('REQUIREMENTS.md'),
'workflow should load REQUIREMENTS.md for conflict detection'
);
});
test('includes BLOCKER/WARNING/INFO conflict severity model', () => {
assert.ok(content.includes('[BLOCKER]'), 'workflow should include BLOCKER severity');
assert.ok(content.includes('[WARNING]'), 'workflow should include WARNING severity');
assert.ok(content.includes('[INFO]'), 'workflow should include INFO severity');
});
test('includes plan-checker validation gate', () => {
assert.ok(
content.includes('msd-plan-checker'),
'workflow should delegate validation to msd-plan-checker'
);
});
test('no-args usage display is present', () => {
assert.ok(
content.includes('Usage: /msd:import') || content.includes('Usage: /msd-import'),
'workflow should display usage when no arguments provided'
);
});
});