fix(server): make /compact slash-command test mock yield session.idle
The empty event-stream mock added in #597 races with the summarize-success path: consumeEventStream sees the empty stream end immediately and emits a "stream ended before terminal event" turn_failed which gets buffered before session.run has assigned its local turnId. The buffered event replays after startTurn returns, marks settled = true, and rejects completion — but session.run skips await completion because settled is true, leaving the rejection unhandled and tripping vitest. Yield session.idle so the stream resolves the turn the same way real OpenCode SSE does.
This commit is contained in:
+6
-1
@@ -91,7 +91,12 @@ describe("OpenCodeAgentSession slash command timeout handling", () => {
|
||||
},
|
||||
event: {
|
||||
subscribe: vi.fn().mockResolvedValue({
|
||||
stream: (async function* () {})(),
|
||||
stream: (async function* () {
|
||||
yield {
|
||||
type: "session.idle",
|
||||
properties: { sessionID: "session-1" },
|
||||
};
|
||||
})(),
|
||||
}),
|
||||
},
|
||||
command: {
|
||||
|
||||
Reference in New Issue
Block a user