Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

test(desktop): stabilize Codex timing-sensitive tests (#3592)

Lizia695e0892321
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexExecFunctionAdapter.e2e.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexExecFunctionAdapter.e2e.test.ts
index 2a150d98b2..ca0a45b143 100644
--- a/apps/desktop/src/main/maker-host/__tests__/codexExecFunctionAdapter.e2e.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/codexExecFunctionAdapter.e2e.test.ts
@@ -299,12 +299,19 @@ stream_max_retries = 0
const turnCompleted = new Promise<void>((resolve) => {
resolveTurnCompleted = resolve;
});
+ let resolveCommandItemCompleted!: () => void;
+ const commandItemCompleted = new Promise<void>((resolve) => {
+ resolveCommandItemCompleted = resolve;
+ });
const startedItems: ItemEnvelope[] = [];
const completedItems: ItemEnvelope[] = [];
subscription = host.subscribeThread(thread.thread.id, {
turnCompleted: () => resolveTurnCompleted(),
itemStarted: ({ item }) => startedItems.push(item),
- itemCompleted: ({ item }) => completedItems.push(item),
+ itemCompleted: ({ item }) => {
+ completedItems.push(item);
+ if (item.type === 'commandExecution') resolveCommandItemCompleted();
+ },
});
await withTimeout(
@@ -322,6 +329,9 @@ stream_max_retries = 0
'turn/start',
);
await withTimeout(turnCompleted, 30_000, 'turn/completed');
+ // Codex may publish turn/completed before the command's terminal item.
+ // Wait for the boundary this assertion actually owns instead of racing it.
+ await withTimeout(commandItemCompleted, 30_000, 'commandExecution item/completed');
expect(providerRequests).toHaveLength(2);
const firstTools = providerRequests[0]?.tools as Array<Record<string, unknown>>;
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts
index 3544b12876..46b72f1d02 100644
--- a/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts
@@ -165,7 +165,7 @@ describe('withCodexUpstreamRecording', () => {
expect(host.getCodexThreadUpstreamOrigin('t-xai')).toBe('https://api.x.ai');
// 没记录过的 thread 不借用别人的结论。
expect(host.getCodexThreadUpstreamOrigin('t-other')).toBe(null);
- });
+ }, 15_000);
it('falls back to the default upstream when the decision does not override it', async () => {
const host = await freshCodexProxyHost();