test(server): preserve accepted turn stream order

The manager-owned accepted turn boundary intentionally precedes coalesced output. Assert that lifecycle event explicitly while retaining the timeline-before-terminal ordering contract.
This commit is contained in:
Mohamed Boudra
2026-08-01 02:40:01 +02:00
parent 718ee1e5fc
commit 02642c5d91
@@ -1248,6 +1248,10 @@ describe("target coalesced behavior", () => {
await waitForSessionEventQueue();
await expect(firstEvent).resolves.toEqual({
done: false,
value: { type: "turn_started", provider: "codex", turnId: "turn-1" },
});
await expect(stream.next()).resolves.toEqual({
done: false,
value: {
type: "timeline",
@@ -1267,14 +1271,20 @@ describe("target coalesced behavior", () => {
expect(getTimelineItems(rows)).toEqual([{ type: "assistant_message", text: "hello world" }]);
expect(streamEvents[0]).toMatchObject({
type: "agent_stream",
event: {
type: "timeline",
item: { type: "assistant_message", text: "hello world" },
},
event: { type: "turn_started", provider: "codex", turnId: "turn-1" },
});
expect(streamEvents[1]).toMatchObject({
type: "agent_stream",
event: { type: "turn_completed" },
event: {
type: "timeline",
provider: "codex",
turnId: "turn-1",
item: { type: "assistant_message", text: "hello world" },
},
});
expect(streamEvents[2]).toMatchObject({
type: "agent_stream",
event: { type: "turn_completed", provider: "codex", turnId: "turn-1" },
});
} finally {
harness.cleanup();