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): remove timing races from Windows unit tests

DavidShen3653b11793ef
diff --git a/apps/desktop/src/main/bot-import/__tests__/host.test.ts b/apps/desktop/src/main/bot-import/__tests__/host.test.ts
index 53c85a9c86..1ea5eb9092 100644
--- a/apps/desktop/src/main/bot-import/__tests__/host.test.ts
+++ b/apps/desktop/src/main/bot-import/__tests__/host.test.ts
@@ -1730,7 +1730,10 @@ it.each([false, true])('pages setup without vault reads after one-time legacy me
const requestId = 'fixture-setup-paging-12345';
const result = await startCompanionImport({ requestId, previewId: preview.id, name: 'Ada',
entryIds: h.snapshot.items.map(item => item.view.id), takeover: true, deferSetup: true }, 'fixture');
- await vi.waitFor(async () => expect((await getCompanionImportResult(requestId))?.status).toBe('needs-attention'));
+ // Acceptance precedes the 23 entries being saved. Join the existing write
+ // lock rather than imposing waitFor's 1s wall-clock limit on real filesystem IO.
+ const settled = await withBotProfileLocks([result.botId], () => getCompanionImportResult(requestId));
+ expect(settled?.status).toBe('needs-attention');
const receiptFile = path.join(h.root, 'companion-imports', `${requestId}.json`);
const bindingFile = path.join(h.root, 'bots', result.botId, 'environment.json');
const originalCheckpoint = (await h.store.read(h.root, result.botId, () => {}))!.pendingImport!.snapshotJson;
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexAuthInvalidation.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexAuthInvalidation.test.ts
index 93a4e59cdc..5bac378063 100644
--- a/apps/desktop/src/main/maker-host/__tests__/codexAuthInvalidation.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/codexAuthInvalidation.test.ts
@@ -5,6 +5,9 @@ import os from 'node:os';
import path from 'node:path';
import { afterEach, describe, expect, it, vi } from 'vitest';
+// Load the adapter graph during collection, not inside the first assertion
+// (cold transforms under the Windows CI pool are unrelated to file identity).
+import { haveSameStableFileIdentity } from '../auth-adapters.js';
import {
CODEX_USER_DISCONNECT_REASON,
currentCodexAuthFileFingerprint,
@@ -105,10 +108,7 @@ function expectPlatformSharedLink(systemAuth: string, localAuth: string): void {
});
}
-// The first dynamic import transforms the complete auth-adapter graph. On Linux
-// the cold transform can exceed the 5s default under the full desktop test pool.
-it('compares Codex hard-link identities without Windows number precision collisions', async () => {
- const { haveSameStableFileIdentity } = await import('../auth-adapters.js');
+it('compares Codex hard-link identities without Windows number precision collisions', () => {
expect(
haveSameStableFileIdentity(
{ dev: 0n, ino: 9_007_199_254_740_992n },
@@ -117,7 +117,7 @@ it('compares Codex hard-link identities without Windows number precision collisi
).toBe(false);
expect(haveSameStableFileIdentity({ dev: 0n, ino: 0n }, { dev: 0n, ino: 0n })).toBe(false);
expect(haveSameStableFileIdentity({ dev: 7n, ino: 11n }, { dev: 7n, ino: 11n })).toBe(true);
-}, 20_000);
+});
it.each([false, true])('preserves successful shared login and native files when presentation write fails=%s', async (failPresentation) => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'xdt-codex-shared-mode-'));