fix(test): isolate atlas background-task-retry test to prevent setTimeout leak
The test overrides globalThis.setTimeout which conflicts with other atlas tests when batched by bun test. Adding mock.module forces run-ci-tests.ts to run this file in its own isolated process. Also added setSessionAgent for descendant session to fix null agent lookup in non-SQLite CI environments.
This commit is contained in:
@@ -6,7 +6,13 @@ import { randomUUID } from "node:crypto"
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
import { createAtlasHook } from "./atlas-hook"
|
||||
import { clearBoulderState, writeBoulderState } from "../../features/boulder-state"
|
||||
import { _resetForTesting, registerAgentName } from "../../features/claude-code-session-state"
|
||||
import { _resetForTesting, registerAgentName, setSessionAgent } from "../../features/claude-code-session-state"
|
||||
|
||||
// Force process isolation in CI runner (globalThis.setTimeout override conflicts with other atlas tests)
|
||||
mock.module("../../shared/opencode-storage-detection", () => ({
|
||||
isSqliteBackend: () => true,
|
||||
resetSqliteBackendCache: () => {},
|
||||
}))
|
||||
|
||||
type LongTimerCallback = (...args: unknown[]) => void | Promise<void>
|
||||
|
||||
@@ -342,6 +348,7 @@ describe("atlas background task retry", () => {
|
||||
test("#given a persisted descendant becomes ineligible before retry fires #when retry runs #then atlas re-checks descendant eligibility and does not inject", async () => {
|
||||
// given
|
||||
const descendantSessionID = "ses_descendant_retry_mismatch"
|
||||
setSessionAgent(descendantSessionID, "atlas")
|
||||
const planPath = join(testDir, "test-plan.md")
|
||||
writeFileSync(planPath, "# Plan\n- [ ] Task 1\n- [ ] Task 2")
|
||||
writeBoulderState(testDir, {
|
||||
|
||||
Reference in New Issue
Block a user