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: satisfy hygiene gate for legacy suites

MagicLizic262d9677d69
diff --git a/apps/desktop/src/main/device-link/__tests__/providerShareApprovalWindows.test.ts b/apps/desktop/src/main/device-link/__tests__/providerShareApprovalWindows.test.ts
index f283ee5424..ae51ea2248 100644
--- a/apps/desktop/src/main/device-link/__tests__/providerShareApprovalWindows.test.ts
+++ b/apps/desktop/src/main/device-link/__tests__/providerShareApprovalWindows.test.ts
@@ -36,6 +36,7 @@ const filePath = () => path.join(dir, state.scope, 'provider-share-approval-wind
const assertCurrent = () => { if (state.boundaryPending) throw new Error('account boundary'); };
async function loadProcess() {
+ // reset-modules: each case starts a fresh Electron main-process runtime so retained ownership cannot leak between accounts.
vi.resetModules();
windows = await import('../providerShareApprovalWindows');
windows.configureProviderShareApprovalWindows({ filePath, scopeKey: () => state.scope });
diff --git a/apps/desktop/src/main/provider-group/__tests__/stores.test.ts b/apps/desktop/src/main/provider-group/__tests__/stores.test.ts
index 71f5bf8e03..c21814eab2 100644
--- a/apps/desktop/src/main/provider-group/__tests__/stores.test.ts
+++ b/apps/desktop/src/main/provider-group/__tests__/stores.test.ts
@@ -68,6 +68,7 @@ describe('provider group store', () => {
expect(store.readProviderGroup(providerId)).toEqual(next);
// 模拟请求被账号边界拒绝,IPC 根本没有执行 pruneBindings;切回后先把成员加回来。
await store.writeProviderGroup(providerId, initial);
+ // reset-modules: verify binding cleanup survives a fresh process after the account boundary.
vi.resetModules();
const restarted = await import('../bindings.js');
expect(restarted.readProviderGroupBinding(sessionId)).toBeNull();
@@ -159,6 +160,7 @@ describe('provider group store', () => {
const file = path.join(tmpDir, 'provider-group-prefs.json');
expect(JSON.parse(fs.readFileSync(file, 'utf8'))).toMatchObject({ reshareCleanups: { 'share:a1': token } });
// 重新创建存储实例,不复用缓存,证明清理来自磁盘。
+ // reset-modules: reload the store to prove the cleanup token is restored from disk.
vi.resetModules();
const restarted = await import('../store.js');
expect(restarted.listProviderGroupReshareCleanups()['share:a1']).toBe(token);
@@ -267,6 +269,7 @@ describe('provider group store', () => {
label: 'legacy-provider-group',
});
legacy.writePatch({ groups: { ...legacy.read().groups, [providerId]: config } });
+ // reset-modules: reload bindings after a legacy writer changes the on-disk schema.
vi.resetModules();
const restarted = await import('../bindings.js');
expect(store.listProviderGroupBindingCleanups()[providerId]).toEqual(pending);
@@ -423,6 +426,7 @@ describe('provider group bindings', () => {
expect(bindings.readProviderGroupBinding('scope-task')).toBeNull();
expect(bindings.isProviderGroupReleased('scope-task', { providerId: 'anthropic' })).toBe(true);
// 切回原账号并重建运行时,解除记录仍须保留,不能把任务重新自动纳入。
+ // reset-modules: account switch must be observed by a newly loaded bindings runtime.
vi.resetModules();
const restarted = await import('../bindings.js');
expect(restarted.readProviderGroupBinding('scope-task')).toBeNull();
@@ -523,6 +527,7 @@ describe('provider group bindings', () => {
log: { info: () => {}, warn: () => {} },
});
legacy.writePatch({ sessions: { ...legacy.read().sessions, 'legacy-release': { providerId: 'legacy-group', memberKey: 'local', at: 20 } } });
+ // reset-modules: reload bindings to exercise compatibility with the older writer's persisted shape.
vi.resetModules();
const restarted = await import('../bindings.js');
expect(restarted.readProviderGroupBinding('legacy-release')).toBeNull();
diff --git a/scripts/test-workspaces.config.mjs b/scripts/test-workspaces.config.mjs
index 34c4ab65bd..5eac852f18 100644
--- a/scripts/test-workspaces.config.mjs
+++ b/scripts/test-workspaces.config.mjs
@@ -107,6 +107,10 @@ const desktopGuardInclude = [
'src/main/__tests__/gitContextIpcSecurity.test.ts',
'src/main/__tests__/isolatedOnProductionProfileStartup.test.ts',
'src/main/__tests__/windowThemeVibrancyIpcSecurity.test.ts',
+ // This contract executes the exported close-generation functions in isolation because importing
+ // the full device-link singleton would start Electron runtime wiring. Keep it in the explicit
+ // guard tier rather than letting its source extraction enter ordinary unit tests.
+ 'src/main/mcp-apps/__tests__/remoteViews.test.ts',
'src/main/cindy-brain/__tests__/forgeOidcInstallEntry.test.ts',
'src/main/cindy-brain/__tests__/ghostDevRuntimeContract.test.ts',
'src/main/cindy-brain/__tests__/ghostIpcMutationLease.test.ts',