From 18f5f99e7d736d4aeac11cd1d4d7e31166ca8398 Mon Sep 17 00:00:00 2001 From: James Feng <47167674+GhostDragon124@users.noreply.github.com> Date: Fri, 5 Jun 2026 01:17:04 +0800 Subject: [PATCH] fix: resolve all 14 test failures to 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove duplicate notifyAutomationStateChanged that shadowed real impl (sessionState 3→0) - Fix messages.ts stub: re-export instead of type-only (ExecuteTool/VaultHttpFetch mock leaks) - Fix CWD-dependent paths in queryModelOpenAI and VaultHttpFetch tests (use import.meta.url) - Add missing logger.ts stub for remote-control-server - CI: add --isolate flag, baseline 14→0 - Tests: 3643 pass,14 fail → 3857 pass,0 fail (--isolate) --- .github/workflows/ci.yml | 6 ++--- .../__tests__/VaultHttpFetchTool.test.ts | 5 +++- packages/remote-control-server/src/logger.ts | 5 ++++ .../openai/__tests__/queryModelOpenAI.test.ts | 11 +++++--- src/services/api/src/utils/messages.ts | 10 +++++--- src/utils/sessionState.ts | 25 ------------------- 6 files changed, 26 insertions(+), 36 deletions(-) create mode 100644 packages/remote-control-server/src/logger.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d1695b33..4f77ac03b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,14 +31,14 @@ jobs: - name: Test run: | set +e - bun test > /tmp/ci-test.log 2>&1 + bun test --isolate > /tmp/ci-test.log 2>&1 TEST_EXIT=$? FAILS=$(grep -oE '[0-9]+ fail' /tmp/ci-test.log | tail -1 | grep -oE '[0-9]+') if [ -z "$FAILS" ]; then FAILS=0; fi - echo "Failures: $FAILS (baseline: 14) | bun test exit: $TEST_EXIT" + echo "Failures: $FAILS (baseline: 0) | bun test exit: $TEST_EXIT" # Show last 30 lines of test output tail -30 /tmp/ci-test.log - if [ "$FAILS" -le 14 ]; then + if [ "$FAILS" -le 0 ]; then echo "✅ Test baseline OK" else echo "❌ Test regressions detected" diff --git a/packages/builtin-tools/src/tools/VaultHttpFetchTool/__tests__/VaultHttpFetchTool.test.ts b/packages/builtin-tools/src/tools/VaultHttpFetchTool/__tests__/VaultHttpFetchTool.test.ts index 7144086c9..d3d74a045 100644 --- a/packages/builtin-tools/src/tools/VaultHttpFetchTool/__tests__/VaultHttpFetchTool.test.ts +++ b/packages/builtin-tools/src/tools/VaultHttpFetchTool/__tests__/VaultHttpFetchTool.test.ts @@ -607,7 +607,10 @@ describe('AC18: VaultHttpFetch is in ALL_AGENT_DISALLOWED_TOOLS', () => { test('subagent gate layer 1 registration is wired', async () => { const fs = await import('node:fs') const path = await import('node:path') - const file = path.resolve('src/constants/tools.ts') + const url = await import('node:url') + // Resolve relative to this test file, not CWD (--isolate changes CWD) + const testDir = path.dirname(url.fileURLToPath(import.meta.url)) + const file = path.resolve(testDir, '../../../../../../src/constants/tools.ts') const src = fs.readFileSync(file, 'utf8') // (a) constant is imported expect(src).toContain('VAULT_HTTP_FETCH_TOOL_NAME') diff --git a/packages/remote-control-server/src/logger.ts b/packages/remote-control-server/src/logger.ts new file mode 100644 index 000000000..2d5a2a668 --- /dev/null +++ b/packages/remote-control-server/src/logger.ts @@ -0,0 +1,5 @@ +// Stub logger for remote-control-server (tests don't need real logging) +export function log(...args: unknown[]): void {} +export function error(...args: unknown[]): void {} +export function warn(...args: unknown[]): void {} +export function debug(...args: unknown[]): void {} diff --git a/src/services/api/openai/__tests__/queryModelOpenAI.test.ts b/src/services/api/openai/__tests__/queryModelOpenAI.test.ts index 47a43f0df..440e129c4 100644 --- a/src/services/api/openai/__tests__/queryModelOpenAI.test.ts +++ b/src/services/api/openai/__tests__/queryModelOpenAI.test.ts @@ -1,8 +1,13 @@ import { describe, expect, test } from 'bun:test' +import { resolve, dirname } from 'node:path' +import { fileURLToPath } from 'node:url' -async function runIsolatedTestFile(path: string) { - const proc = Bun.spawn([process.execPath, 'test', path], { - cwd: process.cwd(), +const testDir = dirname(fileURLToPath(import.meta.url)) +const projectRoot = resolve(testDir, '../../../../..') + +async function runIsolatedTestFile(relativePath: string) { + const proc = Bun.spawn([process.execPath, 'test', relativePath], { + cwd: projectRoot, env: process.env, stdout: 'pipe', stderr: 'pipe', diff --git a/src/services/api/src/utils/messages.ts b/src/services/api/src/utils/messages.ts index 27c84668c..034dbbfd8 100644 --- a/src/services/api/src/utils/messages.ts +++ b/src/services/api/src/utils/messages.ts @@ -1,4 +1,6 @@ -// Auto-generated type stub — replace with real implementation -export type createAssistantAPIErrorMessage = any; -export type NO_RESPONSE_REQUESTED = any; -export type createSystemAPIErrorMessage = any; +// Stub — re-exports from the canonical implementation +export { + createAssistantAPIErrorMessage, + NO_RESPONSE_REQUESTED, + createSystemAPIErrorMessage, +} from '../../../../utils/messages.js' diff --git a/src/utils/sessionState.ts b/src/utils/sessionState.ts index 95f7c1a27..82d7588f6 100644 --- a/src/utils/sessionState.ts +++ b/src/utils/sessionState.ts @@ -255,31 +255,6 @@ export function notifyPermissionModeChanged(mode: PermissionMode): void { permissionModeListener?.(mode) } -// ── Automation state (PROACTIVE / KAIROS) ────────────────────── -// Pushed by SleepTool when the autonomous agent enters/leaves sleep. -// Consumers (CCR sidebar, PromptInput footer) render a status indicator -// so the user knows the agent is intentionally idle, not crashed. - -export type AutomationState = { - enabled: boolean - phase: string | null // 'sleeping' | null - next_tick_at: number | null - sleep_until: number | null -} | null - -type AutomationStateChangedListener = (state: AutomationState) => void -let automationStateListener: AutomationStateChangedListener | null = null - -export function setAutomationStateChangedListener( - cb: AutomationStateChangedListener | null, -): void { - automationStateListener = cb -} - -export function notifyAutomationStateChanged(state: AutomationState): void { - automationStateListener?.(state) -} - export function resetSessionStateForTests(): void { stateListener = null metadataListener = null