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(mobile): 补齐 Goal 发送测试的页面依赖

DavidShen7f6a8010be31
diff --git a/apps/mobile/src/__tests__/mobileGoalCommands.test.ts b/apps/mobile/src/__tests__/mobileGoalCommands.test.ts
index fc7d3df4c7..99ef50b460 100644
--- a/apps/mobile/src/__tests__/mobileGoalCommands.test.ts
+++ b/apps/mobile/src/__tests__/mobileGoalCommands.test.ts
@@ -77,12 +77,14 @@ function existingHarness(args = 'target') {
maker: { goal: { set: vi.fn(async () => {}), clear: vi.fn(async () => {}), getStatus: vi.fn(async () => ({ status: 'active', objective: 'target' })) } },
remoteSessionStore: { setGoalStatus: vi.fn(), acquireSessionMessageWork: vi.fn(() => ({ release })), getSessionDeviceId: () => 'host' }, setContextSheetView: vi.fn(), setContextSheetOpen: vi.fn(),
setGoalRestore: vi.fn(), router: { setParams: vi.fn() }, composerDocumentRef: { current: initial },
+ params: {}, readRouteParam: () => null,
composerDocumentsEqual: (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b),
applyComposerDocument: vi.fn(), normalizeComposerDocument, humanizeRemoteError,
composerDraftHydrated: true, voiceState: 'idle', slashCommandsRef: { current: [] }, queueEditingRef: { current: null },
composerDocumentProjectedText, serializeComposerDocument, reconcileComposerProjectedText, emptyComposerDocument,
canUseComposer: true, attachments: [] as unknown[], attachmentsRef: { current: [] as unknown[] }, pendingUploads: [],
sendInFlightRef: { current: false }, sending: false, setSending: vi.fn((_sending: boolean) => {}), currentSession: session,
+ invalidateHistoryRecoveryNavigation: vi.fn(),
outboxConnectionBlockedNow: () => false, getPendingUploadCount: () => 0,
parseMobileLocalSystemCommand: () => null, parseMobileDesktopCommand, pendingSkillSelectionRef: { current: null },
resolveSessionAgentKind: () => 'pi', modelNeedsReselection: () => false, getCachedDeviceProviders: () => undefined,
@@ -149,6 +151,7 @@ describe('existing task /goal send boundary', () => {
expect(h.bindings.maker.goal.set).toHaveBeenCalledExactlyOnceWith({ sessionId: 'existing-task', objective: 'target' });
expect(h.bindings.remoteSessionStore.setGoalStatus).toHaveBeenCalledWith('existing-task', { status: 'active', objective: 'target' });
expect(h.bindings.applyComposerDocument).toHaveBeenCalledWith(emptyComposerDocument());
+ expect(h.bindings.invalidateHistoryRecoveryNavigation).toHaveBeenCalledOnce();
});
it('bare /goal opens the existing panel', async () => {
const h = existingHarness(''); await h.run();
@@ -193,6 +196,7 @@ describe('existing task /goal send boundary', () => {
expect(h.bindings.sendInFlightRef.current).toBe(true);
await h.run();
expect(h.bindings.maker.goal.set).toHaveBeenCalledOnce();
+ expect(h.bindings.invalidateHistoryRecoveryNavigation).toHaveBeenCalledOnce();
expect(h.release).not.toHaveBeenCalled();
finish();
await first;
@@ -213,11 +217,13 @@ describe('existing task /goal send boundary', () => {
h.bindings.attachmentsRef.current = [];
h.bindings.composerDocumentRef.current = textComposerDocument('ordinary follow-up');
await h.run();
+ expect(h.bindings.setError).toHaveBeenLastCalledWith(null);
expect(h.bindings.mobileDurableOutbox.add).toHaveBeenCalledExactlyOnceWith(expect.objectContaining({
item: expect.objectContaining({ sessionId: 'existing-task', text: 'ordinary follow-up' }),
}));
expect(h.bindings.sendInFlightRef.current).toBe(false);
expect(h.bindings.sending).toBe(false);
expect(h.release).toHaveBeenCalledTimes(2);
+ expect(h.bindings.invalidateHistoryRecoveryNavigation).toHaveBeenCalledTimes(2);
});
});