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(sessions): align task routing and remote notification expectations

Chris21496593b4fd
diff --git a/apps/desktop/src/main/agent-island/__tests__/deviceSessions.test.ts b/apps/desktop/src/main/agent-island/__tests__/deviceSessions.test.ts
index 4711cb2a9e..8f50b3b481 100644
--- a/apps/desktop/src/main/agent-island/__tests__/deviceSessions.test.ts
+++ b/apps/desktop/src/main/agent-island/__tests__/deviceSessions.test.ts
@@ -104,7 +104,7 @@ describe('Agent Island device sessions', () => {
2_000,
);
expect(waiting.events).toEqual([
- { sessionId: 'remote-1', title: 'Fix login', deviceName: 'Studio Mac', kind: 'needs-reply' },
+ { sessionId: 'remote-1', deviceId: 'device-a', title: 'Fix login', deviceName: 'Studio Mac', kind: 'needs-reply' },
]);
const waitingDisplay = buildAgentIslandDisplayState(state, 2_000);
expect(waitingDisplay.mode).toBe('expanded');
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botIslandVisibility.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botIslandVisibility.test.tsx
index ea84974728..e1e16d9cbc 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botIslandVisibility.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botIslandVisibility.test.tsx
@@ -1,5 +1,5 @@
// @vitest-environment jsdom
-import { act, cleanup, render, waitFor } from '@testing-library/react';
+import { act, cleanup, fireEvent, render, waitFor } from '@testing-library/react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
const mocks = vi.hoisted(() => ({
@@ -134,8 +134,8 @@ describe.each([
});
});
-// 不可用页自己从不处置提醒:只有灵动岛入口导航器在目标地址提交后、带着那次点击的编号
-// 才会请 main 处置(见 botSessionOwners)。直接打开地址、被新点击取代后再访问都不消费。
+// 错误页和旧地址外壳不处置提醒;原任务内容加载后才确认可见。
+// 点击重试或跟随兼容地址本身都不是已读。
describe('unavailable Bot task page never disposes island alerts by itself', () => {
it('shows the unavailable state without asking main to dispose anything', async () => {
mocks.params = { botId: 'bot-a', sessionId: 'delegated-a' };
@@ -151,13 +151,21 @@ describe('unavailable Bot task page never disposes island alerts by itself', ()
expect(report.mock.calls.every(([id]) => id === null)).toBe(true);
});
- it('keeps the alert for a live chat and for a retryable load failure', async () => {
+ it('keeps a failed lookup visible without redirecting, and retries without consuming its alert', async () => {
const live = render(<BotSessionView />);
await waitFor(() => expect(live.getByTestId('chat')).toBeTruthy());
live.unmount();
get.mockRejectedValue(new Error('db busy'));
const failed = render(<BotSessionView />);
await waitFor(() => expect(failed.getByText('ccAgent.sessionEntry.failed')).toBeTruthy());
+ expect(failed.queryByTestId('original-task')).toBeNull();
+ expect(failed.queryByTestId('chat')).toBeNull();
+ expect(consumeEntryAlert).not.toHaveBeenCalled();
+ get.mockResolvedValue(profile);
+ fireEvent.click(failed.getByRole('button', { name: 'ccAgent.sessionEntry.retry' }));
+ await waitFor(() => expect(failed.getByTestId('chat')).toBeTruthy());
+ expect(failed.queryByRole('alert')).toBeNull();
+ expect(failed.queryByTestId('original-task')).toBeNull();
expect(consumeEntryAlert).not.toHaveBeenCalled();
});
});
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botNavigation.test.ts b/apps/desktop/src/renderer/features/bots/__tests__/botNavigation.test.ts
index 8963b99d47..18accea4f6 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botNavigation.test.ts
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botNavigation.test.ts
@@ -155,12 +155,8 @@ describe('Bot task creation cannot leave navigation permanently gated', () => {
describe('Bot task route recovery', () => {
const source = readFileSync(resolve(__dirname, '..', 'BotSessionView.tsx'), 'utf8');
- it('keeps load failures visible and retryable instead of silently redirecting', () => {
- expect(source).not.toContain('<Navigate');
- expect(source).toContain("kind: 'error'");
- expect(source).toContain('setReloadVersion');
- expect(source).toContain('bots.sessionLoadFailedTitle');
- });
+ // Retryable load failures are exercised through the rendered BotSessionView
+ // in botIslandVisibility.test.tsx. Valid stale URLs may redirect to their task.
it('passes the live Bot roster and the teammate identity into the shared task composer', () => {
expect(source).toContain('window.electronAPI.localDb.bots.list(');