Skip to content

Commit 88639af

Browse files
committed
bench: optimize integration tests
- Split sendMessage.test.ts into 5 smaller files to improve parallelism and prevent timeouts - Optimize setupWorkspace to support shared git repo reuse across tests - Optimize buildLargeHistory to write directly to disk instead of using HistoryService loop - Fix flexible image description matching in image tests
1 parent 790ef06 commit 88639af

File tree

8 files changed

+2029
-1644
lines changed

8 files changed

+2029
-1644
lines changed

tests/ipcMain/helpers.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ export function modelString(provider: string, model: string): string {
4545
return `${provider}:${model}`;
4646
}
4747

48+
/**
49+
* Configure global test retries using Jest
50+
* This helper isolates Jest-specific globals so they don't break other runners (like Bun)
51+
*/
52+
export function configureTestRetries(retries = 3): void {
53+
if (process.env.CI && typeof jest !== "undefined" && jest.retryTimes) {
54+
jest.retryTimes(retries, { logErrorsBeforeRetry: true });
55+
}
56+
}
57+
4858
/**
4959
* Send a message via IPC
5060
*/
@@ -769,29 +779,31 @@ export async function buildLargeHistory(
769779
textPrefix?: string;
770780
} = {}
771781
): Promise<void> {
772-
const { HistoryService } = await import("../../src/node/services/historyService");
782+
const fs = await import("fs/promises");
783+
const path = await import("path");
773784
const { createMuxMessage } = await import("../../src/common/types/message");
774785

775-
// HistoryService only needs getSessionDir, so we can cast the partial config
776-
const historyService = new HistoryService(config as any);
777-
778786
const messageSize = options.messageSize ?? 50_000;
779787
const messageCount = options.messageCount ?? 80;
780788
const textPrefix = options.textPrefix ?? "";
781789

782790
const largeText = textPrefix + "A".repeat(messageSize);
791+
const sessionDir = config.getSessionDir(workspaceId);
792+
const chatPath = path.join(sessionDir, "chat.jsonl");
793+
794+
let content = "";
783795

784796
// Build conversation history with alternating user/assistant messages
785797
for (let i = 0; i < messageCount; i++) {
786798
const isUser = i % 2 === 0;
787799
const role = isUser ? "user" : "assistant";
788800
const message = createMuxMessage(`history-msg-${i}`, role, largeText, {});
789-
790-
const result = await historyService.appendToHistory(workspaceId, message);
791-
if (!result.success) {
792-
throw new Error(`Failed to append message ${i} to history: ${result.error}`);
793-
}
801+
content += JSON.stringify(message) + "\n";
794802
}
803+
804+
// Ensure session directory exists and write file directly for performance
805+
await fs.mkdir(sessionDir, { recursive: true });
806+
await fs.writeFile(chatPath, content, "utf-8");
795807
}
796808

797809
/**

0 commit comments

Comments
 (0)