refactor: replace try/finally with beforeEach/afterEach + add CONTRIBUTING.md
Test suite modernization: - Converted all try/finally cleanup patterns to beforeEach/afterEach hooks across 11 test files (core, copilot-install, config, workstream, milestone-summary, forensics, state, antigravity, profile-pipeline, workspace) - Consolidated 40 inline mkdtempSync calls to use centralized helpers - Added createTempDir() helper for bare temp directories - Added optional prefix parameter to createTempProject/createTempGitProject - Fixed config test HOME sandboxing (was reading global defaults.json) New CONTRIBUTING.md: - Test standards: hooks over try/finally, centralized helpers, HOME sandboxing - Node 22/24 compatibility requirements with Node 26 forward-compat - Code style, PR guidelines, security practices - File structure overview All 1382 tests pass, 0 failures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* Workstream Tests — CRUD, env-var routing, collision detection
|
||||
*/
|
||||
|
||||
const { describe, test, before, after } = require('node:test');
|
||||
const { describe, test, before, after, beforeEach, afterEach } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
@@ -162,16 +162,23 @@ describe('workstream list', () => {
|
||||
assert.deepStrictEqual(names, ['alpha', 'beta']);
|
||||
});
|
||||
|
||||
test('reports flat mode when no workstreams exist', () => {
|
||||
const flatDir = createTempProject();
|
||||
try {
|
||||
describe('flat mode', () => {
|
||||
let flatDir;
|
||||
|
||||
beforeEach(() => {
|
||||
flatDir = createTempProject();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup(flatDir);
|
||||
});
|
||||
|
||||
test('reports flat mode when no workstreams exist', () => {
|
||||
const result = runGsdTools(['workstream', 'list', '--raw'], flatDir);
|
||||
assert.ok(result.success);
|
||||
const data = JSON.parse(result.output);
|
||||
assert.strictEqual(data.mode, 'flat');
|
||||
} finally {
|
||||
cleanup(flatDir);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user