Files
get-shit-done/tests/import-command.test.cjs
Tom Boucher 73c1af5168 fix(#2543): replace legacy /gsd-<cmd> syntax with /gsd:<cmd> across all source files (#2595)
Commands are now installed as commands/gsd/<name>.md and invoked as
/gsd:<name> in Claude Code. The old hyphen form /gsd-<name> was still
hardcoded in hundreds of places across workflows, references, templates,
lib modules, and command files — causing "Unknown command" errors
whenever GSD suggested a command to the user.

Replace all /gsd-<cmd> occurrences where <cmd> is a known command name
(derived at runtime from commands/gsd/*.md) using a targeted Node.js
script. Agent names, tool names (gsd-sdk, gsd-tools), directory names,
and path fragments are not touched.

Adds regression test tests/bug-2543-gsd-slash-namespace.test.cjs that
enforces zero legacy occurrences going forward. Removes inverted
tests/stale-colon-refs.test.cjs (bug #1748) which enforced the now-obsolete
hyphen form; the new bug-2543 test supersedes it. Updates 5 assertion
tests that hardcoded the old hyphen form to accept the new colon form.

Closes #2543

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 12:04:25 -04:00

122 lines
4.4 KiB
JavaScript

/**
* Import Command Tests — import-command.test.cjs
*
* Structural assertions for the /gsd-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', 'gsd', 'import.md');
const WF_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'import.md');
// ─── File Existence ────────────────────────────────────────────────────────────
describe('import command file structure', () => {
test('command file exists', () => {
assert.ok(fs.existsSync(CMD_PATH), 'commands/gsd/import.md should exist');
});
test('workflow file exists', () => {
assert.ok(fs.existsSync(WF_PATH), 'get-shit-done/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*gsd: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/get-shit-done/workflows/import.md'),
'command should reference the workflow via @~/.claude/get-shit-done/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('gsd-plan-checker'),
'workflow should delegate validation to gsd-plan-checker'
);
});
test('no-args usage display is present', () => {
assert.ok(
content.includes('Usage: /gsd:import') || content.includes('Usage: /gsd-import'),
'workflow should display usage when no arguments provided'
);
});
});