mirror of
https://github.com/glittercowboy/get-shit-done
synced 2026-05-05 06:42:14 +02:00
Move 81 tests (18 describe blocks) from single monolithic test file into 7 domain-specific test files under tests/ with shared helpers. Test parity verified: 81/81 pass before and after split. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
99 lines
3.9 KiB
JavaScript
99 lines
3.9 KiB
JavaScript
/**
|
|
* GSD Tools Tests - Milestone
|
|
*/
|
|
|
|
const { test, describe, beforeEach, afterEach } = require('node:test');
|
|
const assert = require('node:assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { runGsdTools, createTempProject, cleanup } = require('./helpers.cjs');
|
|
|
|
describe('milestone complete command', () => {
|
|
let tmpDir;
|
|
|
|
beforeEach(() => {
|
|
tmpDir = createTempProject();
|
|
});
|
|
|
|
afterEach(() => {
|
|
cleanup(tmpDir);
|
|
});
|
|
|
|
test('archives roadmap, requirements, creates MILESTONES.md', () => {
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'ROADMAP.md'),
|
|
`# Roadmap v1.0 MVP\n\n### Phase 1: Foundation\n**Goal:** Setup\n`
|
|
);
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'REQUIREMENTS.md'),
|
|
`# Requirements\n\n- [ ] User auth\n- [ ] Dashboard\n`
|
|
);
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'STATE.md'),
|
|
`# State\n\n**Status:** In progress\n**Last Activity:** 2025-01-01\n**Last Activity Description:** Working\n`
|
|
);
|
|
|
|
const p1 = path.join(tmpDir, '.planning', 'phases', '01-foundation');
|
|
fs.mkdirSync(p1, { recursive: true });
|
|
fs.writeFileSync(
|
|
path.join(p1, '01-01-SUMMARY.md'),
|
|
`---\none-liner: Set up project infrastructure\n---\n# Summary\n`
|
|
);
|
|
|
|
const result = runGsdTools('milestone complete v1.0 --name MVP Foundation', tmpDir);
|
|
assert.ok(result.success, `Command failed: ${result.error}`);
|
|
|
|
const output = JSON.parse(result.output);
|
|
assert.strictEqual(output.version, 'v1.0');
|
|
assert.strictEqual(output.phases, 1);
|
|
assert.ok(output.archived.roadmap, 'roadmap should be archived');
|
|
assert.ok(output.archived.requirements, 'requirements should be archived');
|
|
|
|
// Verify archive files exist
|
|
assert.ok(
|
|
fs.existsSync(path.join(tmpDir, '.planning', 'milestones', 'v1.0-ROADMAP.md')),
|
|
'archived roadmap should exist'
|
|
);
|
|
assert.ok(
|
|
fs.existsSync(path.join(tmpDir, '.planning', 'milestones', 'v1.0-REQUIREMENTS.md')),
|
|
'archived requirements should exist'
|
|
);
|
|
|
|
// Verify MILESTONES.md created
|
|
assert.ok(
|
|
fs.existsSync(path.join(tmpDir, '.planning', 'MILESTONES.md')),
|
|
'MILESTONES.md should be created'
|
|
);
|
|
const milestones = fs.readFileSync(path.join(tmpDir, '.planning', 'MILESTONES.md'), 'utf-8');
|
|
assert.ok(milestones.includes('v1.0 MVP Foundation'), 'milestone entry should contain name');
|
|
assert.ok(milestones.includes('Set up project infrastructure'), 'accomplishments should be listed');
|
|
});
|
|
|
|
test('appends to existing MILESTONES.md', () => {
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'MILESTONES.md'),
|
|
`# Milestones\n\n## v0.9 Alpha (Shipped: 2025-01-01)\n\n---\n\n`
|
|
);
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'ROADMAP.md'),
|
|
`# Roadmap v1.0\n`
|
|
);
|
|
fs.writeFileSync(
|
|
path.join(tmpDir, '.planning', 'STATE.md'),
|
|
`# State\n\n**Status:** In progress\n**Last Activity:** 2025-01-01\n**Last Activity Description:** Working\n`
|
|
);
|
|
|
|
const result = runGsdTools('milestone complete v1.0 --name Beta', tmpDir);
|
|
assert.ok(result.success, `Command failed: ${result.error}`);
|
|
|
|
const milestones = fs.readFileSync(path.join(tmpDir, '.planning', 'MILESTONES.md'), 'utf-8');
|
|
assert.ok(milestones.includes('v0.9 Alpha'), 'existing entry should be preserved');
|
|
assert.ok(milestones.includes('v1.0 Beta'), 'new entry should be appended');
|
|
});
|
|
});
|
|
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
// validate consistency command
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|