fix: resolve test isolation failures in task-continuation-enforcer and config-handler tests
- Change BackgroundManager import to type-only to prevent global process listener pollution across parallel test files - Replace real BackgroundManager construction with createMockBackgroundManager - Fix nested spyOn in config-handler tests to reuse beforeEach spy via mockResolvedValue instead of re-spying inside test bodies
This commit is contained in:
parent
f3f6ba47fe
commit
caf08af88b
@ -4,7 +4,7 @@ import { mkdtempSync, rmSync, writeFileSync } from "node:fs"
|
|||||||
import { tmpdir } from "node:os"
|
import { tmpdir } from "node:os"
|
||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
|
|
||||||
import { BackgroundManager } from "../features/background-agent"
|
import type { BackgroundManager } from "../features/background-agent"
|
||||||
import { setMainSession, subagentSessions, _resetForTesting } from "../features/claude-code-session-state"
|
import { setMainSession, subagentSessions, _resetForTesting } from "../features/claude-code-session-state"
|
||||||
import type { OhMyOpenCodeConfig } from "../config/schema"
|
import type { OhMyOpenCodeConfig } from "../config/schema"
|
||||||
import { TaskObjectSchema } from "../tools/task/types"
|
import { TaskObjectSchema } from "../tools/task/types"
|
||||||
@ -244,7 +244,7 @@ describe("task-continuation-enforcer", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const hook = createTaskContinuationEnforcer(createMockPluginInput(), createConfig(taskDir), {
|
const hook = createTaskContinuationEnforcer(createMockPluginInput(), createConfig(taskDir), {
|
||||||
backgroundManager: new BackgroundManager(createMockPluginInput()),
|
backgroundManager: createMockBackgroundManager(false),
|
||||||
})
|
})
|
||||||
|
|
||||||
// when - session goes idle
|
// when - session goes idle
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
/// <reference path="../../node_modules/bun-types/test.d.ts" />
|
||||||
|
|
||||||
import { describe, test, expect, spyOn, beforeEach, afterEach } from "bun:test"
|
import { describe, test, expect, spyOn, beforeEach, afterEach } from "bun:test"
|
||||||
import { resolveCategoryConfig, createConfigHandler } from "./config-handler"
|
import { resolveCategoryConfig, createConfigHandler } from "./config-handler"
|
||||||
import type { CategoryConfig } from "../config/schema"
|
import type { CategoryConfig } from "../config/schema"
|
||||||
@ -949,7 +951,10 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
|
|||||||
|
|
||||||
test("denies todowrite and todoread for primary agents when task_system is enabled", async () => {
|
test("denies todowrite and todoread for primary agents when task_system is enabled", async () => {
|
||||||
//#given
|
//#given
|
||||||
spyOn(agents, "createBuiltinAgents" as any).mockResolvedValue({
|
const createBuiltinAgentsMock = agents.createBuiltinAgents as unknown as {
|
||||||
|
mockResolvedValue: (value: Record<string, unknown>) => void
|
||||||
|
}
|
||||||
|
createBuiltinAgentsMock.mockResolvedValue({
|
||||||
sisyphus: { name: "sisyphus", prompt: "test", mode: "primary" },
|
sisyphus: { name: "sisyphus", prompt: "test", mode: "primary" },
|
||||||
hephaestus: { name: "hephaestus", prompt: "test", mode: "primary" },
|
hephaestus: { name: "hephaestus", prompt: "test", mode: "primary" },
|
||||||
atlas: { name: "atlas", prompt: "test", mode: "primary" },
|
atlas: { name: "atlas", prompt: "test", mode: "primary" },
|
||||||
@ -987,7 +992,10 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
|
|||||||
|
|
||||||
test("does not deny todowrite/todoread when task_system is disabled", async () => {
|
test("does not deny todowrite/todoread when task_system is disabled", async () => {
|
||||||
//#given
|
//#given
|
||||||
spyOn(agents, "createBuiltinAgents" as any).mockResolvedValue({
|
const createBuiltinAgentsMock = agents.createBuiltinAgents as unknown as {
|
||||||
|
mockResolvedValue: (value: Record<string, unknown>) => void
|
||||||
|
}
|
||||||
|
createBuiltinAgentsMock.mockResolvedValue({
|
||||||
sisyphus: { name: "sisyphus", prompt: "test", mode: "primary" },
|
sisyphus: { name: "sisyphus", prompt: "test", mode: "primary" },
|
||||||
hephaestus: { name: "hephaestus", prompt: "test", mode: "primary" },
|
hephaestus: { name: "hephaestus", prompt: "test", mode: "primary" },
|
||||||
})
|
})
|
||||||
@ -1021,7 +1029,10 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
|
|||||||
|
|
||||||
test("does not deny todowrite/todoread when task_system is undefined", async () => {
|
test("does not deny todowrite/todoread when task_system is undefined", async () => {
|
||||||
//#given
|
//#given
|
||||||
spyOn(agents, "createBuiltinAgents" as any).mockResolvedValue({
|
const createBuiltinAgentsMock = agents.createBuiltinAgents as unknown as {
|
||||||
|
mockResolvedValue: (value: Record<string, unknown>) => void
|
||||||
|
}
|
||||||
|
createBuiltinAgentsMock.mockResolvedValue({
|
||||||
sisyphus: { name: "sisyphus", prompt: "test", mode: "primary" },
|
sisyphus: { name: "sisyphus", prompt: "test", mode: "primary" },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user