Skip to content

Commit 4209c3a

Browse files
authored
🤖 fix: resolve flaky integration tests in bash runtime and stream resumption (#729)
Generated with `mux` Fixes two independent flakes: ### 1. `tests/ipcMain/runtimeExecuteBash.test.ts` **Issue:** The test was flaky because it expected the AI model to explicitly describe the output in its text response, which is non-deterministic. **Fix:** Prioritized verifying the actual tool output (which is deterministic and proves the runtime works) and made the text response check optional. ### 2. `tests/ipcMain/resumeStream.test.ts` **Issue:** The test relied on a `setTimeout(100)` to wait for IPC subscription, which caused race conditions in CI/loaded environments. **Fix:** Replaced the sleep with `collector.waitForEvent('caught-up')`, which is the correct synchronization signal from the backend.
1 parent 7ba4d15 commit 4209c3a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

‎tests/ipcMain/createWorkspace.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,8 @@ exit 1
818818

819819
try {
820820
// Set up a real origin remote in the test repo
821-
const originUrl = "https://github.com/example/test-repo.git";
821+
// Use example.com to avoid global git config rewrites (e.g. insteadOf https://github.com/)
822+
const originUrl = "https://example.com/example/test-repo.git";
822823
await execAsync(`git remote add origin ${originUrl}`, {
823824
cwd: tempGitRepo,
824825
});

‎tests/ipcMain/resumeStream.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ describeIntegration("IpcMain resumeStream integration tests", () => {
161161
// Subscribe to chat channel to receive events
162162
env.mockIpcRenderer.send("workspace:chat:subscribe", workspaceId);
163163

164-
// Wait a moment for subscription to complete
165-
await new Promise((resolve) => setTimeout(resolve, 100));
164+
// Wait for subscription to complete by waiting for caught-up event
165+
const caughtUpEvent = await collector.waitForEvent("caught-up", 5000);
166+
expect(caughtUpEvent).toBeDefined();
166167

167168
// Resume the stream (should continue from the summary message)
168169
const resumeResult = (await env.mockIpcRenderer.invoke(

‎tests/ipcMain/runtimeExecuteBash.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,16 @@ describeIntegration("Runtime Bash Execution", () => {
296296
const responseText = extractTextFromEvents(events);
297297

298298
// Verify command completed successfully (not timeout)
299-
expect(responseText).toContain("test");
299+
// We primarily check bashOutput to ensure the tool executed and didn't hang
300300
const bashOutput = collectToolOutputs(events, "bash");
301301
expect(bashOutput).toContain('"test": "data"');
302302

303+
// responseText might be empty if the model decides not to comment on the output
304+
// so we make this check optional or less strict if the tool output is correct
305+
if (responseText) {
306+
expect(responseText).toContain("test");
307+
}
308+
303309
// Verify command completed quickly (not hanging until timeout)
304310
expect(toolDuration).toBeGreaterThan(0);
305311
const maxDuration = 10000;

0 commit comments

Comments
 (0)