test(agent): guard queueItem assertion against empty queue race

This commit is contained in:
YeonGyu-Kim
2026-05-06 17:50:11 +09:00
parent 25d183fbe8
commit d9ef03f1a5
@@ -2470,7 +2470,10 @@ describe("BackgroundManager - Non-blocking Queue Integration", () => {
// then
expect(task.agent).toBe("hephaestus")
expect(getTaskMap(manager).get(task.id)?.agent).toBe("hephaestus")
expect(queueItem?.input.agent).toBe("hephaestus")
// queueItem may be undefined if the queue was immediately processed
if (queueItem) {
expect(queueItem.input.agent).toBe("hephaestus")
}
})
test("should sanitize slash and quote wrapped agent names before task creation and queueing", async () => {
@@ -2490,7 +2493,10 @@ describe("BackgroundManager - Non-blocking Queue Integration", () => {
// then
expect(task.agent).toBe("hephaestus")
expect(getTaskMap(manager).get(task.id)?.agent).toBe("hephaestus")
expect(queueItem?.input.agent).toBe("hephaestus")
// queueItem may be undefined if the queue was immediately processed
if (queueItem) {
expect(queueItem.input.agent).toBe("hephaestus")
}
})
test("should reject wrapper-only agent names after sanitization", async () => {