test(background): fix variant propagation test to match parent-context resolution
This commit is contained in:
@@ -1063,18 +1063,7 @@ describe("BackgroundManager.notifyParentSession - aborted parent", () => {
|
|||||||
prompt: promptMock,
|
prompt: promptMock,
|
||||||
promptAsync: promptMock,
|
promptAsync: promptMock,
|
||||||
abort: async () => ({}),
|
abort: async () => ({}),
|
||||||
messages: async () => ({
|
messages: async () => ({ data: [] }),
|
||||||
data: [{
|
|
||||||
info: {
|
|
||||||
agent: "explore",
|
|
||||||
model: {
|
|
||||||
providerID: "anthropic",
|
|
||||||
modelID: "claude-opus-4-6",
|
|
||||||
variant: "high",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const manager = new BackgroundManager({ client, directory: tmpdir() } as unknown as PluginInput)
|
const manager = new BackgroundManager({ client, directory: tmpdir() } as unknown as PluginInput)
|
||||||
@@ -1159,7 +1148,18 @@ describe("BackgroundManager.notifyParentSession - notifications toggle", () => {
|
|||||||
prompt: promptMock,
|
prompt: promptMock,
|
||||||
promptAsync: promptMock,
|
promptAsync: promptMock,
|
||||||
abort: async () => ({}),
|
abort: async () => ({}),
|
||||||
messages: async () => ({ data: [] }),
|
messages: async () => ({
|
||||||
|
data: [{
|
||||||
|
info: {
|
||||||
|
agent: "explore",
|
||||||
|
model: {
|
||||||
|
providerID: "anthropic",
|
||||||
|
modelID: "claude-opus-4-6",
|
||||||
|
variant: "high",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const manager = new BackgroundManager(
|
const manager = new BackgroundManager(
|
||||||
@@ -1193,47 +1193,6 @@ describe("BackgroundManager.notifyParentSession - notifications toggle", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("BackgroundManager.notifyParentSession - variant propagation", () => {
|
describe("BackgroundManager.notifyParentSession - variant propagation", () => {
|
||||||
test("should propagate variant in parent notification promptAsync body", async () => {
|
|
||||||
//#given
|
|
||||||
const promptCalls: Array<{ body: Record<string, unknown> }> = []
|
|
||||||
const client = {
|
|
||||||
session: {
|
|
||||||
prompt: async () => ({}),
|
|
||||||
promptAsync: async (args: { path: { id: string }; body: Record<string, unknown> }) => {
|
|
||||||
promptCalls.push({ body: args.body })
|
|
||||||
return {}
|
|
||||||
},
|
|
||||||
abort: async () => ({}),
|
|
||||||
messages: async () => ({ data: [] }),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
const manager = new BackgroundManager({ client, directory: tmpdir() } as unknown as PluginInput)
|
|
||||||
const task: BackgroundTask = {
|
|
||||||
id: "task-variant-test",
|
|
||||||
sessionID: "session-child",
|
|
||||||
parentSessionID: "session-parent",
|
|
||||||
parentMessageID: "msg-parent",
|
|
||||||
description: "task with variant",
|
|
||||||
prompt: "test",
|
|
||||||
agent: "explore",
|
|
||||||
status: "completed",
|
|
||||||
startedAt: new Date(),
|
|
||||||
completedAt: new Date(),
|
|
||||||
model: { providerID: "anthropic", modelID: "claude-opus-4-6", variant: "high" },
|
|
||||||
}
|
|
||||||
getPendingByParent(manager).set("session-parent", new Set([task.id]))
|
|
||||||
|
|
||||||
//#when
|
|
||||||
await (manager as unknown as { notifyParentSession: (task: BackgroundTask) => Promise<void> })
|
|
||||||
.notifyParentSession(task)
|
|
||||||
|
|
||||||
//#then
|
|
||||||
expect(promptCalls).toHaveLength(1)
|
|
||||||
expect(promptCalls[0].body.variant).toBe("high")
|
|
||||||
|
|
||||||
manager.shutdown()
|
|
||||||
})
|
|
||||||
|
|
||||||
test("should prefer parent session variant over child task variant in parent notification promptAsync body", async () => {
|
test("should prefer parent session variant over child task variant in parent notification promptAsync body", async () => {
|
||||||
//#given
|
//#given
|
||||||
const promptCalls: Array<{ body: Record<string, unknown> }> = []
|
const promptCalls: Array<{ body: Record<string, unknown> }> = []
|
||||||
@@ -1588,6 +1547,7 @@ describe("BackgroundManager.tryCompleteTask", () => {
|
|||||||
|
|
||||||
const task = createMockTask({
|
const task = createMockTask({
|
||||||
id: "task-zombie-session",
|
id: "task-zombie-session",
|
||||||
|
sessionID: "session-zombie-placeholder",
|
||||||
parentSessionID: "parent-zombie",
|
parentSessionID: "parent-zombie",
|
||||||
status: "pending",
|
status: "pending",
|
||||||
agent: "explore",
|
agent: "explore",
|
||||||
|
|||||||
Reference in New Issue
Block a user