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: use native AbortController in group archive router tests

MagicLizibc317dd74484
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botsFeatureLayout.archive.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botsFeatureLayout.archive.test.tsx
index 52d488d451..28e380d17e 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botsFeatureLayout.archive.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botsFeatureLayout.archive.test.tsx
@@ -1,4 +1,5 @@
// @vitest-environment jsdom
+import { transferableAbortController } from 'node:util';
import { act, cleanup, render, screen, waitFor } from '@testing-library/react';
import { createMemoryRouter, RouterProvider } from 'react-router-dom';
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
@@ -7,6 +8,9 @@ import { BotsFeatureLayout } from '../BotsFeatureLayout';
import { BotsListView } from '../BotsListView';
import { refreshBotGroups, resetBotGroupStoreForTests } from '../botGroupStore';
+// React Router uses Node's Request, so its signal must come from the same realm.
+const NativeAbortController = transferableAbortController().constructor;
+
vi.mock('../botStore', () => ({ useBotProfiles: () => [] }));
// The layout registers the shared task sidebar (with the teammates section); not under test here.
vi.mock('../../cc-agent/useRegisterCCAgentSidebar', () => ({ useRegisterCCAgentSidebar: vi.fn() }));
@@ -21,13 +25,18 @@ function group(id = 'room', archived = false): BotGroupSummary {
}
beforeEach(() => {
+ vi.stubGlobal('AbortController', NativeAbortController);
resetBotGroupStoreForTests();
groups = [group()];
Object.defineProperty(window, 'electronAPI', { configurable: true, value: { maker: {
listBotGroups: vi.fn(async () => ({ ok: true, groups })),
} } });
});
-afterEach(() => { cleanup(); resetBotGroupStoreForTests(); });
+afterEach(() => {
+ cleanup();
+ resetBotGroupStoreForTests();
+ vi.unstubAllGlobals();
+});
async function refresh() {
await act(async () => { refreshBotGroups(); });