Skip to content

Commit 4eda2a4

Browse files
thymikeeclaude
andcommitted
refactor: migrate session.ts orchestrator to vitest + drop node:test (#284)
Remove all test-only DI parameters from handleSessionCommands (signature drops from ~30 params to 5: req, sessionName, logPath, sessionStore, invoke) and from the remaining sub-handlers (session-inventory, session-observability, session-replay, session-close, session-state). Migrate all 89 remaining node:test unit test files to vitest. Tests that passed DI overrides now use vi.mock instead. Update vitest.config.ts to include *.test.ts alongside *.vitest.ts, and remove the dual-runner node --test from package.json scripts. Add a permanent CI lint guard that fails if optional typeof DI seams reappear in production code. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent fa21248 commit 4eda2a4

119 files changed

Lines changed: 545 additions & 688 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ jobs:
2929
exit 1
3030
fi
3131
32+
no-test-di-seams:
33+
name: No test-only DI seams
34+
runs-on: ubuntu-latest
35+
timeout-minutes: 5
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
39+
40+
- name: Fail if test-only DI seams reappear in production code
41+
run: |
42+
if rg '\?\s*:\s*typeof\s+' src/ --glob '!**/__tests__/**' --glob '!*.test.ts'; then
43+
echo "Found test-only DI seams (optional typeof params) in production code."
44+
exit 1
45+
fi
46+
3247
unit:
3348
name: Unit Tests
3449
runs-on: ubuntu-latest

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"format": "prettier --write src test skills",
3434
"prepack": "pnpm build:all",
3535
"typecheck": "tsc -p tsconfig.json",
36-
"test": "node --test && vitest run",
37-
"test:unit": "node --test src/__tests__/*.test.ts src/core/__tests__/*.test.ts src/daemon/__tests__/*.test.ts src/daemon/handlers/__tests__/*.test.ts src/platforms/**/__tests__/*.test.ts src/utils/**/__tests__/*.test.ts && vitest run",
36+
"test": "vitest run",
37+
"test:unit": "vitest run",
3838
"test:smoke": "node --test test/integration/smoke-*.test.ts",
3939
"test:integration": "node --test test/integration/*.test.ts",
4040
"test:replay:ios": "node --experimental-strip-types src/bin.ts test test/integration/replays/ios/simulator",

‎src/__tests__/cli-batch.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from 'node:test';
1+
import { test } from 'vitest';
22
import assert from 'node:assert/strict';
33
import fs from 'node:fs';
44
import os from 'node:os';

‎src/__tests__/cli-client-commands.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs';
22
import os from 'node:os';
33
import path from 'node:path';
4-
import test from 'node:test';
4+
import { test } from 'vitest';
55
import assert from 'node:assert/strict';
66
import { tryRunClientBackedCommand } from '../cli-client-commands.ts';
77
import type {

‎src/__tests__/cli-clipboard.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from 'node:test';
1+
import { test } from 'vitest';
22
import assert from 'node:assert/strict';
33
import { runCli } from '../cli.ts';
44
import type { DaemonRequest, DaemonResponse } from '../daemon-client.ts';

‎src/__tests__/cli-close.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from 'node:test';
1+
import { test } from 'vitest';
22
import assert from 'node:assert/strict';
33
import { runCli } from '../cli.ts';
44
import { AppError } from '../utils/errors.ts';

‎src/__tests__/cli-config.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from 'node:test';
1+
import { test } from 'vitest';
22
import assert from 'node:assert/strict';
33
import fs from 'node:fs';
44
import os from 'node:os';

‎src/__tests__/cli-diagnostics.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from 'node:test';
1+
import { test } from 'vitest';
22
import assert from 'node:assert/strict';
33
import fs from 'node:fs';
44
import os from 'node:os';

‎src/__tests__/cli-diff.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, test } from 'node:test';
1+
import { describe, test } from 'vitest';
22
import assert from 'node:assert/strict';
33
import fs from 'node:fs';
44
import os from 'node:os';
@@ -131,7 +131,7 @@ async function runCliCapture(
131131
}
132132

133133
// Tests must run serially because they monkey-patch process.exit and process.stdout.write.
134-
describe('cli diff commands', { concurrency: false }, () => {
134+
describe('cli diff commands', () => {
135135
test('diff snapshot renders human-readable unified diff text', async () => {
136136
const result = await runCliCapture(['diff', 'snapshot']);
137137
assert.equal(result.code, null);

‎src/__tests__/cli-help.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from 'node:test';
1+
import { test } from 'vitest';
22
import assert from 'node:assert/strict';
33
import { runCli } from '../cli.ts';
44
import type { DaemonResponse } from '../daemon-client.ts';

0 commit comments

Comments
 (0)