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): 对齐性能重构后的源码守卫

DavidShen297ed02f0e1e
diff --git a/apps/mobile/src/__tests__/historyWindowBackfillWiring.test.ts b/apps/mobile/src/__tests__/historyWindowBackfillWiring.test.ts
index 2bb0a76695..55f82ba4d8 100644
--- a/apps/mobile/src/__tests__/historyWindowBackfillWiring.test.ts
+++ b/apps/mobile/src/__tests__/historyWindowBackfillWiring.test.ts
@@ -77,7 +77,7 @@ describe('history window backfill wiring', () => {
// 换会话时整体重置,否则上个会话的已考察集合会压住新会话的补齐。
expect(source).toContain('existingState?.sid === sessionId');
expect(source).toContain('state.sid !== sessionIdAtStart || state.epoch !== epochAtStart');
- expect(source).toContain('findHistoryWindowGap(messages, consideredKeys)');
+ expect(source).toContain('findHistoryWindowGap(latestMessagesRef.current, consideredKeys)');
expect(source).toContain('...gapState.contiguous,');
expect(source).toContain('...gapState.backfilled,');
expect(source).toContain('...gapState.failed,');
diff --git a/apps/mobile/src/__tests__/inactiveSessionListSubscriptions.test.ts b/apps/mobile/src/__tests__/inactiveSessionListSubscriptions.test.ts
index 5b1eb87051..c84528f03c 100644
--- a/apps/mobile/src/__tests__/inactiveSessionListSubscriptions.test.ts
+++ b/apps/mobile/src/__tests__/inactiveSessionListSubscriptions.test.ts
@@ -20,15 +20,35 @@ describe('inactive session list subscriptions', () => {
it('pauses list and row subscriptions while their route is covered', () => {
const store = source('src/session/remoteSessionStore.ts');
expect(store).toContain(
- 'enabled ? remoteSessionStore.subscribe : INACTIVE_REMOTE_SESSION_STORE_SUBSCRIBE',
+ 'enabled ? subscribe : INACTIVE_REMOTE_SESSION_STORE_SUBSCRIBE',
);
expect(store).toContain(
"usePausableRemoteSessionStoreSnapshot('sessions', remoteSessionStore.getSessions)",
);
- expect(store).toContain("'message-version',\n remoteSessionStore.getMessageVersion");
- expect(store).toContain("'store-version',\n remoteSessionStore.getStoreVersion");
- expect(store).toContain(
- '() => remoteSessionStore.isSessionRunning(sessionId)',
+ const previewHook = store.slice(
+ store.indexOf('export function useRemoteSessionMessagePreview'),
+ store.indexOf('// 本地「最近消息」缓存持久化'),
+ );
+ expect(previewHook).toContain('usePausableRemoteSessionStoreSnapshot(');
+ expect(previewHook).toContain('remoteSessionStore.subscribeSessionMessagePreview(sessionId, cb)');
+ const messageVersionHook = store.slice(
+ store.indexOf('export function useRemoteMessageVersion'),
+ store.indexOf('/** Home-list invalidation'),
+ );
+ expect(messageVersionHook).toContain('usePausableRemoteSessionStoreSnapshot(');
+ expect(messageVersionHook).toContain('remoteSessionStore.getMessageVersion()');
+ const storeVersionHook = store.slice(
+ store.indexOf('export function useRemoteSessionStoreVersion'),
+ store.indexOf('export function useRemoteNewMakerWorktreePreference'),
+ );
+ expect(storeVersionHook).toContain('usePausableRemoteSessionStoreSnapshot(');
+ expect(storeVersionHook).toContain('remoteSessionStore.getStoreVersion');
+ const runningHook = store.slice(
+ store.indexOf('export function useSessionRunning'),
+ store.indexOf('export function useSessionRunStatus'),
);
+ expect(runningHook).toContain('usePausableRemoteSessionStoreSnapshot(');
+ expect(runningHook).toContain('() => remoteSessionStore.isSessionRunning(sessionId)');
+ expect(runningHook).toContain('remoteSessionStore.subscribeHomeStatus');
});
});
diff --git a/apps/mobile/src/__tests__/mobilePresentationRefresh.test.ts b/apps/mobile/src/__tests__/mobilePresentationRefresh.test.ts
index c3bc392556..91247f86a8 100644
--- a/apps/mobile/src/__tests__/mobilePresentationRefresh.test.ts
+++ b/apps/mobile/src/__tests__/mobilePresentationRefresh.test.ts
@@ -33,8 +33,8 @@ describe('mobile localized presentation refresh', () => {
it('rebuilds localized session history and tail errors when the language changes', () => {
const source = read('app/sessions/[sessionId].tsx');
- const renderItems = source.slice(
- source.indexOf('const renderItems = useMemo'),
+ const renderWindow = source.slice(
+ source.indexOf('const renderWindow = useMemo'),
source.indexOf('// 只在本次 render 真正 commit 后更新 reconcile 基准'),
);
const tailBanner = source.slice(
@@ -42,7 +42,7 @@ describe('mobile localized presentation refresh', () => {
source.indexOf('// 主按钮(重试 / 继续任务)'),
);
- expect(renderItems).toContain('i18nInstance.language');
+ expect(renderWindow).toContain('i18nInstance.language');
expect(tailBanner).toContain('i18nInstance.language');
});