Files
get-shit-done/tests/autonomous-interactive.test.cjs
Tom Boucher 2703422be8 refactor(tests): standardize to node:assert/strict and t.after() per CONTRIBUTING.md (#1675)
* refactor(tests): standardize to node:assert/strict and t.after() per CONTRIBUTING.md

- Replace require('node:assert') with require('node:assert/strict') across
  all 73 test files to enforce strict equality (no type coercion)
- Replace try/finally cleanup blocks with t.after() hooks in core.test.cjs
  and hooks-opt-in.test.cjs per the test lifecycle standards
- Utility functions in codex-config and security-scan retain try/finally
  as that is appropriate for per-function resource guards, not lifecycle hooks

Closes #1674

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

* perf(tests): add --test-concurrency=4 to test runner for parallel file execution

Node.js --test-concurrency controls how many test files run as parallel child
processes. Set to 4 by default, configurable via TEST_CONCURRENCY env var.
Fixes tests at a known level rather than inheriting os.availableParallelism()
which varies across CI environments.

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

* fix(security): allowlist verify.test.cjs in prompt-injection scanner

tests/verify.test.cjs uses <human>...</human> as GSD phase task-type
XML (meaning "a human should verify this step"), which matches the
scanner's fake-message-boundary pattern for LLM APIs. This is a
false positive — add it to the allowlist alongside the other test files
that legitimately contain injection-adjacent patterns.

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

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 14:29:03 -04:00

85 lines
3.6 KiB
JavaScript

/**
* GSD Tools Tests - autonomous --interactive flag
*
* Validates that the autonomous workflow and command definition
* correctly document and support the --interactive flag.
*
* Closes: #1413
*/
const { test, describe } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
describe('autonomous --interactive flag (#1413)', () => {
const workflowPath = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'autonomous.md');
const commandPath = path.join(__dirname, '..', 'commands', 'gsd', 'autonomous.md');
test('command definition includes --interactive in argument-hint', () => {
const content = fs.readFileSync(commandPath, 'utf8');
assert.ok(content.includes('--interactive'), 'command should document --interactive flag');
assert.ok(content.includes('argument-hint:') && content.includes('--interactive'),
'argument-hint should include --interactive');
});
test('command definition describes interactive mode behavior', () => {
const content = fs.readFileSync(commandPath, 'utf8');
assert.ok(content.includes('discuss') && content.includes('inline'),
'command should describe discuss running inline');
assert.ok(content.includes('background'),
'command should mention background agents for plan+execute');
});
test('workflow parses --interactive flag', () => {
const content = fs.readFileSync(workflowPath, 'utf8');
assert.ok(content.includes("--interactive") && content.includes('INTERACTIVE'),
'workflow should parse --interactive into INTERACTIVE variable');
});
test('workflow uses discuss-phase skill in interactive mode', () => {
const content = fs.readFileSync(workflowPath, 'utf8');
assert.ok(
content.includes('gsd:discuss-phase') && content.includes('INTERACTIVE'),
'workflow should invoke gsd:discuss-phase when INTERACTIVE is set'
);
});
test('workflow dispatches plan as background agent in interactive mode', () => {
const content = fs.readFileSync(workflowPath, 'utf8');
// Should have Agent() with run_in_background for plan
assert.ok(
content.includes('run_in_background') && content.includes('plan-phase'),
'workflow should dispatch plan-phase as background agent in interactive mode'
);
});
test('workflow dispatches execute as background agent in interactive mode', () => {
const content = fs.readFileSync(workflowPath, 'utf8');
assert.ok(
content.includes('run_in_background') && content.includes('execute-phase'),
'workflow should dispatch execute-phase as background agent in interactive mode'
);
});
test('workflow describes pipeline parallelism in interactive mode', () => {
const content = fs.readFileSync(workflowPath, 'utf8');
assert.ok(
content.includes('pipeline parallelism') || content.includes('Phase N+1'),
'workflow should describe overlapping discuss/execute between phases'
);
});
test('success criteria include --interactive requirements', () => {
const content = fs.readFileSync(workflowPath, 'utf8');
const criteriaMatch = content.match(/<success_criteria>([\s\S]*?)<\/success_criteria>/);
const criteria = criteriaMatch ? criteriaMatch[1] : '';
assert.ok(criteria.includes('--interactive'),
'success criteria should include --interactive requirements');
assert.ok(criteria.includes('discuss inline'),
'success criteria should mention discuss inline');
assert.ok(criteria.includes('background agents'),
'success criteria should mention background agents');
});
});