Skip to content

Commit a7808d3

Browse files
authored
🤖 fix: resolve flaky integration tests (#720)
Fixes flaky tests in `resumeStream`, `queuedMessages`, and `ollama` integration suites by improving event waiting logic and fixing timeouts. _Generated with `mux`_
1 parent 085f22c commit a7808d3

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

tests/ipcMain/ollama.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describeOllama("IpcMain Ollama integration tests", () => {
9696

9797
// Ensure Ollama model is available (idempotent - fast if cached)
9898
await ensureOllamaModel(OLLAMA_MODEL);
99-
}, 150000); // 150s timeout for tokenizer loading + potential model pull
99+
}); // 150s timeout handling managed internally or via global config
100100

101101
test("should successfully send message to Ollama and receive response", async () => {
102102
// Setup test environment
@@ -115,9 +115,9 @@ describeOllama("IpcMain Ollama integration tests", () => {
115115

116116
// Collect and verify stream events
117117
const collector = createEventCollector(env.sentEvents, workspaceId);
118-
const streamEnd = await collector.waitForEvent("stream-end", 30000);
118+
const streamEnd = await collector.waitForEvent("stream-end", 60000);
119119

120-
expect(streamEnd).toBeDefined();
120+
expect(streamEnd).not.toBeNull();
121121
assertStreamSuccess(collector);
122122

123123
// Verify we received deltas

tests/ipcMain/queuedMessages.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ describeIntegration("IpcMain queuedMessages integration tests", () => {
204204
await sendMessage(env.mockIpcRenderer, workspaceId, "Message 3");
205205

206206
// Verify all messages queued
207+
// Wait until we have 3 messages in the queue state
208+
const success = await waitFor(async () => {
209+
const msgs = await getQueuedMessages(collector1, 500);
210+
return msgs.length === 3;
211+
}, 5000);
212+
expect(success).toBe(true);
213+
207214
const queued = await getQueuedMessages(collector1);
208215
expect(queued).toEqual(["Message 1", "Message 2", "Message 3"]);
209216

tests/ipcMain/resumeStream.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describeIntegration("IpcMain resumeStream integration tests", () => {
3232
// Wait for stream to start
3333
const collector1 = createEventCollector(env.sentEvents, workspaceId);
3434
const streamStartEvent = await collector1.waitForEvent("stream-start", 5000);
35-
expect(streamStartEvent).toBeDefined();
35+
expect(streamStartEvent).not.toBeNull();
3636

3737
// Wait for at least some content or tool call to start
3838
await waitFor(() => {
@@ -87,11 +87,11 @@ describeIntegration("IpcMain resumeStream integration tests", () => {
8787

8888
// Wait for new stream to start
8989
const resumeStreamStart = await collector2.waitForEvent("stream-start", 5000);
90-
expect(resumeStreamStart).toBeDefined();
90+
expect(resumeStreamStart).not.toBeNull();
9191

9292
// Wait for stream to complete
9393
const streamEnd = await collector2.waitForEvent("stream-end", 30000);
94-
expect(streamEnd).toBeDefined();
94+
expect(streamEnd).not.toBeNull();
9595

9696
// Verify no new user message was created
9797
collector2.collect();
@@ -174,11 +174,11 @@ describeIntegration("IpcMain resumeStream integration tests", () => {
174174

175175
// Wait for stream to start
176176
const streamStart = await collector.waitForEvent("stream-start", 10000);
177-
expect(streamStart).toBeDefined();
177+
expect(streamStart).not.toBeNull();
178178

179179
// Wait for stream to complete
180180
const streamEnd = await collector.waitForEvent("stream-end", 30000);
181-
expect(streamEnd).toBeDefined();
181+
expect(streamEnd).not.toBeNull();
182182

183183
// Verify no user message was created (resumeStream should not add one)
184184
collector.collect();

0 commit comments

Comments
 (0)