test(integration): split autonomous-chain.spec.ts into per-scenario files
The original tests/integration/autonomous-chain.spec.ts was ~1400 lines and 50 KB, covering 19 describe blocks across 10 orthogonal scenarios. Physically extract each describe (or closely related group) into its own file inside tests/integration/autonomous-chain/ so each file stays under the project's 500-line ceiling and failures point at the scenario that regressed. Shared beforeEach / afterEach / createAgent / buildCtx helpers move to autonomous-chain/shared-setup.ts, which exposes installSharedSetup() as a factory that each spec calls at module load. The tests themselves are moved byte-for-byte; only module-level references (`db`, `companyId`, `workspaceId`, `tempDirs`) are rewritten to go through the shared handle. No assertions, it() calls, or behavior are changed. Split layout: role-detection.spec.ts — Step 1: CEO role detection ceo-phased-prompts.spec.ts — Step 2: phased prompts + approvals wakeup-queue.spec.ts — Step 3: deferred wake queue approval-decisions.spec.ts — Step 4: hire approval decisions task-propagation.spec.ts — Step 5: task/comment wake propagation run-failure.spec.ts — Step 6: run failure escalation crash-recovery.spec.ts — Step 7: worker crash recovery wake-reason.spec.ts — Step 8: wake reason injection e2e-flows.spec.ts — full-chain + review-fix regressions automation-messages.spec.ts — automation/messages/assignment/workflows Test count stays at 363 passing; typecheck stays at 156 errors.
This commit is contained in:
1 parent
6e4fd078d9
commit
0f1b7c0b33
12 files changed
+1517
-1409
No files matched your search
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Step 3: Deferred wake queue lifecycle.
|
||||
* Physically extracted from autonomous-chain.spec.ts without behavior changes.
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { installSharedSetup } from "./shared-setup";
|
||||
|
||||
const shared = installSharedSetup();
|
||||
const { createAgent } = shared;
|
||||
|
||||
describe("Step 3: Wakeup request lifecycle (database)", () => {
|
||||
it("enqueue and list wakeup requests with coalescing", () => {
|
||||
const agentId = createAgent({ name: "TestAgent" });
|
||||
|
||||
// Enqueue two wakes for the same busy agent. Coalesced into one row
|
||||
// with trigger_detail JSON array containing both triggers.
|
||||
shared.db.enqueueWakeupRequest(shared.companyId, agentId, "subtask_completed", "subtask_completed");
|
||||
shared.db.enqueueWakeupRequest(shared.companyId, agentId, "comment", "comment");
|
||||
|
||||
// List returns the coalesced wake
|
||||
const wakes = shared.db.listWakeupRequests(shared.companyId, { agentId, status: "queued" });
|
||||
expect(wakes).toHaveLength(1);
|
||||
expect(wakes[0].companyId).toBe(shared.companyId);
|
||||
expect(wakes[0].coalescedCount).toBe(1);
|
||||
|
||||
const triggers = JSON.parse(wakes[0].triggerDetail!);
|
||||
expect(triggers).toHaveLength(2);
|
||||
expect(triggers[0].trigger).toBe("subtask_completed");
|
||||
expect(triggers[1].trigger).toBe("comment");
|
||||
});
|
||||
|
||||
it("returns empty array when no wakeup requests exist", () => {
|
||||
const agentId = createAgent({ name: "TestAgent" });
|
||||
const wakes = shared.db.listWakeupRequests(shared.companyId, { agentId, status: "queued" });
|
||||
expect(wakes).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("does not return wakes for other agents", () => {
|
||||
const agent1 = createAgent({ name: "Agent1" });
|
||||
const agent2 = createAgent({ name: "Agent2" });
|
||||
|
||||
shared.db.enqueueWakeupRequest(shared.companyId, agent1, "comment", "comment");
|
||||
shared.db.enqueueWakeupRequest(shared.companyId, agent2, "subtask_completed", "subtask_completed");
|
||||
|
||||
const wakes1 = shared.db.listWakeupRequests(shared.companyId, { agentId: agent1, status: "queued" });
|
||||
expect(wakes1).toHaveLength(1);
|
||||
expect(wakes1[0].source).toBe("comment");
|
||||
|
||||
// Agent2's wake should still be there
|
||||
const wakes2 = shared.db.listWakeupRequests(shared.companyId, { agentId: agent2, status: "queued" });
|
||||
expect(wakes2).toHaveLength(1);
|
||||
expect(wakes2[0].source).toBe("subtask_completed");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user