refactor(tests): consolidate Milestone Module — 10 files → 4 (#3754)

* refactor(tests): consolidate Milestone Module — 10 files → 4

Closes #3753

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(changeset): correct fragment format for 3753-consolidate-milestone-tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(changeset): add required frontmatter to 3753 changeset fragment

Adds `type: Fixed` and `pr: 3753` frontmatter so docs-lint passes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(tests): bug-2943 execFileSync timeout 5s→15s for Windows starvation

PR #3754's milestone consolidation reshuffles run-tests.cjs chunk
composition. On Windows/Node 22 under --test-concurrency=4, bug-2943
subprocesses now share concurrency slots with bug-2760-codex-install
subtests (8–15s each), starving past the 5000ms timeout. 15s covers
the observed 13.5s worst case with headroom.

Refs #3753

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-05-20 20:38:53 -04:00
committed by GitHub
parent f955bf872c
commit 9f57f7488e
13 changed files with 1015 additions and 1614 deletions

View File

@@ -2,12 +2,16 @@
// Tracked in #2974 for migration to typed-IR assertions per CONTRIBUTING.md
// "Prohibited: Raw Text Matching on Test Outputs". Per-file review may
// reclassify some entries as source-text-is-the-product during migration.
// allow-test-rule: source-text-is-the-product
// Reads .md/.json/.yml product files whose deployed text IS what the
// runtime loads — testing text content tests the deployed contract.
/**
* GSD Milestone Summary Tests
* GSD Milestone Summary + Audit Tests
*
* Validates the milestone-summary command and workflow files exist
* and follow expected patterns. Tests artifact discovery logic.
* Validates the milestone-summary command, milestone-audit module (#2158),
* workflow audit gates (complete-milestone, verify-work), and STATE.md template.
* Also tests artifact discovery logic.
*/
const { test, describe, beforeEach, afterEach } = require('node:test');
@@ -318,3 +322,150 @@ describe('milestone-summary git stats resilience', () => {
);
});
});
// ─────────────────────────────────────────────────────────────────────────────
// audit.cjs module (#2158)
// ─────────────────────────────────────────────────────────────────────────────
describe('audit.cjs module (#2158)', () => {
const { createTempProject: createTP, cleanup: cleanTP, runGsdTools: run } = require('./helpers.cjs');
let tmpDir;
beforeEach(() => { tmpDir = createTP('audit-test'); });
afterEach(() => { cleanTP(tmpDir); });
test('auditOpenArtifacts returns structured result with counts', () => {
const { auditOpenArtifacts } = require('../get-shit-done/bin/lib/audit.cjs');
const result = auditOpenArtifacts(tmpDir);
assert.ok(typeof result === 'object');
assert.ok(typeof result.counts === 'object');
assert.ok(typeof result.counts.total === 'number');
assert.ok(typeof result.has_open_items === 'boolean');
});
test('auditOpenArtifacts handles missing planning directories gracefully', () => {
const { auditOpenArtifacts } = require('../get-shit-done/bin/lib/audit.cjs');
const result = auditOpenArtifacts(tmpDir);
assert.strictEqual(result.counts.total, 0);
assert.strictEqual(result.has_open_items, false);
});
test('auditOpenArtifacts detects open debug sessions', () => {
const { auditOpenArtifacts } = require('../get-shit-done/bin/lib/audit.cjs');
const debugDir = path.join(tmpDir, '.planning', 'debug');
fs.mkdirSync(debugDir, { recursive: true });
fs.writeFileSync(path.join(debugDir, 'test-bug.md'), [
'---', 'status: investigating', 'trigger: login fails', 'updated: 2026-04-10', '---',
'# Debug: test-bug',
].join('\n'));
const result = auditOpenArtifacts(tmpDir);
assert.strictEqual(result.counts.debug_sessions, 1);
assert.ok(result.has_open_items);
});
test('auditOpenArtifacts ignores resolved debug sessions', () => {
const { auditOpenArtifacts } = require('../get-shit-done/bin/lib/audit.cjs');
const resolvedDir = path.join(tmpDir, '.planning', 'debug', 'resolved');
fs.mkdirSync(resolvedDir, { recursive: true });
fs.writeFileSync(path.join(resolvedDir, 'old-bug.md'), ['---', 'status: resolved', '---', '# Resolved'].join('\n'));
const result = auditOpenArtifacts(tmpDir);
assert.strictEqual(result.counts.debug_sessions, 0);
});
test('formatAuditReport returns string with header', () => {
const { auditOpenArtifacts, formatAuditReport } = require('../get-shit-done/bin/lib/audit.cjs');
const report = formatAuditReport(auditOpenArtifacts(tmpDir));
assert.ok(typeof report === 'string');
assert.ok(report.includes('Artifact Audit') || report.includes('artifact audit') || report.includes('All artifact'));
});
test('formatAuditReport shows all clear when no open items', () => {
const { auditOpenArtifacts, formatAuditReport } = require('../get-shit-done/bin/lib/audit.cjs');
const report = formatAuditReport(auditOpenArtifacts(tmpDir));
assert.ok(report.includes('clear') || report.includes('0 items') || report.includes('no open'));
});
});
describe('complete-milestone workflow has pre-close audit gate (#2158)', () => {
const completeMilestoneContent = fs.readFileSync(
path.join(__dirname, '..', 'get-shit-done', 'workflows', 'complete-milestone.md'),
'utf8',
);
test('complete-milestone has pre_close_artifact_audit step', () => {
assert.ok(
completeMilestoneContent.includes('pre_close_artifact_audit') ||
completeMilestoneContent.includes('audit-open'),
);
});
test('complete-milestone surfaces deferred items to STATE.md', () => {
assert.ok(completeMilestoneContent.includes('Deferred Items'));
});
test('complete-milestone has security note for audit output', () => {
assert.ok(
completeMilestoneContent.includes('sanitiz') || completeMilestoneContent.includes('SECURITY'),
);
});
});
describe('verify-work workflow has phase artifact check (#2157)', () => {
const verifyWorkContent = fs.readFileSync(
path.join(__dirname, '..', 'get-shit-done', 'workflows', 'verify-work.md'),
'utf8',
);
test('verify-work has scan_phase_artifacts step', () => {
assert.ok(
verifyWorkContent.includes('scan_phase_artifacts') || verifyWorkContent.includes('audit-open'),
);
});
test('verify-work prompts user on open UAT gaps', () => {
assert.ok(verifyWorkContent.includes('gaps') && verifyWorkContent.includes('Proceed'));
});
});
describe('state.md template has Deferred Items section (#2158)', () => {
const stateTemplate = fs.readFileSync(
path.join(__dirname, '..', 'get-shit-done', 'templates', 'state.md'),
'utf8',
);
test('state.md template includes Deferred Items section', () => {
assert.ok(stateTemplate.includes('Deferred Items'));
});
});
describe('audit-open CLI command — ReferenceError regression (#2236)', () => {
const { createTempProject: createTP, cleanup: cleanTP, runGsdTools: run } = require('./helpers.cjs');
let tmpDir;
beforeEach(() => { tmpDir = createTP('audit-open-cli-test'); });
afterEach(() => { cleanTP(tmpDir); });
test('audit-open exits without error on an empty project', () => {
const result = run(['audit-open'], tmpDir);
assert.ok(result.success, `audit-open crashed: ${result.error}`);
});
test('audit-open --json exits without error and returns valid JSON', () => {
const result = run(['audit-open', '--json'], tmpDir);
assert.ok(result.success, `audit-open --json crashed: ${result.error}`);
let parsed;
assert.doesNotThrow(() => { parsed = JSON.parse(result.output); });
assert.ok(typeof parsed === 'object');
assert.ok(typeof parsed.counts === 'object');
});
test('audit-open error is not ReferenceError: output is not defined', () => {
const result = run(['audit-open'], tmpDir);
assert.ok(
!String(result.error).includes('output is not defined'),
`ReferenceError regression: ${result.error}`,
);
});
});