Skip to content

Commit a64075c

Browse files
committed
Fix WORKSPACE_EXECUTE_BASH API usage in test
- Use .data.output instead of .result.stdout (which doesn't exist) - Add .data.success checks as per API structure - Remove unused readStream() helper function - Remove timeout_secs param (not needed for WORKSPACE_EXECUTE_BASH) This matches the actual API used in other tests (e.g., executeBash.test.ts)
1 parent 9938231 commit a64075c

File tree

1 file changed

+9
-31
lines changed

1 file changed

+9
-31
lines changed

tests/ipcMain/createWorkspace.test.ts

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -116,25 +116,6 @@ async function commitChanges(repoPath: string, message: string): Promise<void> {
116116
});
117117
}
118118

119-
/**
120-
* Read a ReadableStream to a string
121-
*/
122-
async function readStream(stream: ReadableStream<Uint8Array>): Promise<string> {
123-
const reader = stream.getReader();
124-
const decoder = new TextDecoder();
125-
let result = "";
126-
try {
127-
while (true) {
128-
const { done, value } = await reader.read();
129-
if (done) break;
130-
result += decoder.decode(value, { stream: true });
131-
}
132-
} finally {
133-
reader.releaseLock();
134-
}
135-
return result;
136-
}
137-
138119
/**
139120
* Create workspace and handle cleanup on test failure
140121
* Returns result and cleanup function
@@ -344,34 +325,31 @@ describeIntegration("WORKSPACE_CREATE with both runtimes", () => {
344325
const checkTrunkFileResult = await env.mockIpcRenderer.invoke(
345326
IPC_CHANNELS.WORKSPACE_EXECUTE_BASH,
346327
result.metadata.id,
347-
`test -f trunk-file.txt && echo "exists" || echo "missing"`,
348-
{ timeout_secs: 10 }
328+
`test -f trunk-file.txt && echo "exists" || echo "missing"`
349329
);
350330
expect(checkTrunkFileResult.success).toBe(true);
351-
const trunkFileOutput = await readStream(checkTrunkFileResult.result.stdout);
352-
expect(trunkFileOutput.trim()).toBe("exists");
331+
expect(checkTrunkFileResult.data.success).toBe(true);
332+
expect(checkTrunkFileResult.data.output.trim()).toBe("exists");
353333

354334
// Check that other-file.txt does NOT exist (from other-branch)
355335
const checkOtherFileResult = await env.mockIpcRenderer.invoke(
356336
IPC_CHANNELS.WORKSPACE_EXECUTE_BASH,
357337
result.metadata.id,
358-
`test -f other-file.txt && echo "exists" || echo "missing"`,
359-
{ timeout_secs: 10 }
338+
`test -f other-file.txt && echo "exists" || echo "missing"`
360339
);
361340
expect(checkOtherFileResult.success).toBe(true);
362-
const otherFileOutput = await readStream(checkOtherFileResult.result.stdout);
363-
expect(otherFileOutput.trim()).toBe("missing");
341+
expect(checkOtherFileResult.data.success).toBe(true);
342+
expect(checkOtherFileResult.data.output.trim()).toBe("missing");
364343

365344
// Verify git log shows the custom trunk commit
366345
const gitLogResult = await env.mockIpcRenderer.invoke(
367346
IPC_CHANNELS.WORKSPACE_EXECUTE_BASH,
368347
result.metadata.id,
369-
`git log --oneline --all`,
370-
{ timeout_secs: 10 }
348+
`git log --oneline --all`
371349
);
372350
expect(gitLogResult.success).toBe(true);
373-
const logOutput = await readStream(gitLogResult.result.stdout);
374-
expect(logOutput).toContain("Custom trunk commit");
351+
expect(gitLogResult.data.success).toBe(true);
352+
expect(gitLogResult.data.output).toContain("Custom trunk commit");
375353

376354
await cleanup();
377355
} finally {

0 commit comments

Comments
 (0)