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): 稳定插件发布确认配额用例

DavidShenf8b4f8fe9870
diff --git a/apps/desktop/src/main/plugin-publisher/__tests__/orchestrator.test.ts b/apps/desktop/src/main/plugin-publisher/__tests__/orchestrator.test.ts
index 8db0602db7..640d7e9266 100644
--- a/apps/desktop/src/main/plugin-publisher/__tests__/orchestrator.test.ts
+++ b/apps/desktop/src/main/plugin-publisher/__tests__/orchestrator.test.ts
@@ -168,16 +168,26 @@ describe('PluginPublisherOrchestrator', () => {
});
const first = orch.start(filePath);
+ await vi.waitFor(() => expect(confirmations).toHaveLength(1));
orch.start(filePath);
await vi.waitFor(() => expect(confirmations).toHaveLength(2));
- if (outcome === 'accepted') confirmations[0].resolve(true);
- else if (outcome === 'rejected') confirmations[0].resolve(false);
+ if (outcome === 'accepted') {
+ confirmations[0].resolve(true);
+ // Acceptance continues through hashing and prepare in the background. The
+ // quota under test is released as soon as the transfer leaves confirmation,
+ // so do not couple this assertion to the duration of those later stages.
+ await vi.waitFor(() =>
+ expect(orch.snapshot(first.transferId)?.stage).not.toBe('confirming'),
+ );
+ } else if (outcome === 'rejected') confirmations[0].resolve(false);
else if (outcome === 'aborted') {
expect(orch.cancel(first.transferId)).toEqual({ cancelled: true });
} else confirmations[0].reject(new Error('confirmation failed'));
- await vi.waitFor(() =>
- expect(orch.snapshot(first.transferId)?.stage).toMatch(/^(failed|cancelled)$/),
- );
+ if (outcome !== 'accepted') {
+ await vi.waitFor(() =>
+ expect(orch.snapshot(first.transferId)?.stage).toMatch(/^(failed|cancelled)$/),
+ );
+ }
const next = orch.start(filePath);
// Excludes a leaked counter on the accept, reject, and abort exits respectively.