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(companions): await bulk import transaction before assertions

zqchris9bf57259ea30
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 ab9f08f02a..c5702908ed 100644
--- a/apps/desktop/src/main/bot-import/__tests__/host.test.ts
+++ b/apps/desktop/src/main/bot-import/__tests__/host.test.ts
@@ -733,8 +733,13 @@ it.each(['count', 'entrypoint', 'projected-entrypoint', 'captured-entrypoint'])(
const [source] = await listCompanionImportSources('fixture');
const preview = await previewCompanionImport(source!.id, 'fixture');
const selection = { requestId: `fixture-skill-limit-${mode}`, previewId: preview.id, name: 'Ada', entryIds: h.snapshot.items.map(item => item.view.id), takeover: false };
- await startCompanionImport(selection, 'fixture');
- await vi.waitFor(async () => expect((await getCompanionImportResult(selection.requestId))?.status).toBe('complete'));
+ const accepted = await startCompanionImport(selection, 'fixture');
+ // Acceptance can precede the 142 real filesystem writes. Join the existing
+ // profile transaction instead of racing vi.waitFor's one-second deadline.
+ const result = await withBotProfileLocks([accepted.botId], () => getCompanionImportResult(selection.requestId));
+ expect(result?.status).toBe('complete');
+ expect(result?.savedEntryIds).toEqual(expect.arrayContaining(selection.entryIds));
+ expect(await fs.readdir(path.join(h.root, 'bots', accepted.botId, 'skills'))).toHaveLength(count);
expect(createBotProfile).toHaveBeenCalledOnce();
});