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: 补齐调度启动的人工操作时间依赖

Cindy5fdca83b24ca
diff --git a/apps/desktop/src/main/scheduler-host/__tests__/schedulerQueueWiring.test.ts b/apps/desktop/src/main/scheduler-host/__tests__/schedulerQueueWiring.test.ts
index 079aecb4a2..a6333b0962 100644
--- a/apps/desktop/src/main/scheduler-host/__tests__/schedulerQueueWiring.test.ts
+++ b/apps/desktop/src/main/scheduler-host/__tests__/schedulerQueueWiring.test.ts
@@ -5,6 +5,7 @@ import type { StartSchedulerDeps } from '../index';
const mocks = vi.hoisted(() => ({
restore: vi.fn<(sessionId: string) => Promise<boolean>>(),
quotaWait: vi.fn<(scheduleId: string) => Promise<string | null>>(),
+ lastUserActionAt: vi.fn<(sessionId: string) => number | null>(),
runnerDeps: null as MakerScheduleRunnerDeps | null,
}));
@@ -27,6 +28,7 @@ vi.mock('../../notificationService.js', () => ({ getDesktopNotificationsEnabled:
vi.mock('../../maker-ipc/register.js', () => ({
ensureSchedulerQueueRestored: mocks.restore,
findSchedulerUsageLimitWait: mocks.quotaWait,
+ getSessionLastUserActionAt: mocks.lastUserActionAt,
applyPiImModelSelectionUnderLock: vi.fn(), acquirePendingAgentSwitchForDirectSend: vi.fn(),
prepareScheduledModelPreferencesUnderLock: vi.fn(), recordDispatchedModel: vi.fn(),
broadcastSessionCreated: vi.fn(), cancelSchedulerAutoResume: vi.fn(),
@@ -60,6 +62,7 @@ afterEach(async () => {
await resetScheduler();
mocks.restore.mockReset();
mocks.quotaWait.mockReset();
+ mocks.lastUserActionAt.mockReset();
mocks.runnerDeps = null;
});
@@ -80,5 +83,12 @@ describe('scheduler queue wiring', () => {
mocks.quotaWait.mockResolvedValue('old-quota-session');
await expect(mocks.runnerDeps?.findUsageLimitWait?.('schedule')).resolves.toBe('old-quota-session');
expect(mocks.quotaWait).toHaveBeenCalledExactlyOnceWith('schedule');
+ // #7104 / unit: runner tests inject this bridge directly; startup must also
+ // forward the live recovery clock so old messages still receive courtesy.
+ const actionAt = restored ? 1_000_000 : null;
+ mocks.lastUserActionAt.mockReturnValue(actionAt);
+ expect(mocks.runnerDeps?.schedulerQueue?.getLastUserActionAt?.('restored-session'))
+ .toBe(actionAt);
+ expect(mocks.lastUserActionAt).toHaveBeenCalledExactlyOnceWith('restored-session');
});
});