Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
test(mobile): cover multi-image history and thread preview visibility
xd465a7bc16a2e
diff --git a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsxindex 55d3022cad..24a812d1ef 100644--- a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx+++ b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx@@ -273,12 +273,12 @@ async function click(id: string) {if (!target) throw new Error(`missing ${id}`);await act(async () => { target.click(); });}-async function render(data: BotGroupRemoteChatData | null = group(), kind: 'ready' | 'loading' | 'missing' | 'error' = 'ready') {+async function render(data: BotGroupRemoteChatData | null = group(), kind: 'ready' | 'loading' | 'missing' | 'error' = 'ready', threadRootId?: string) {h.chat = {...h.chat,state: kind === 'ready' ? { kind, group: data } : kind === 'error' ? { kind, message: 'x' } : { kind },};- await act(async () => root.render(el(BotGroupChatScreen, { deviceId: 'mac', deviceName: 'Mac', groupId: 'g1' })));+ await act(async () => root.render(el(BotGroupChatScreen, { deviceId: 'mac', deviceName: 'Mac', groupId: 'g1', threadRootId })));}beforeEach(() => {@@ -1375,10 +1375,10 @@ describe('direct server group presentation', () => {expect(byId('botGroup.settings.delete')?.disabled).toBe(true);expect(byId('botGroup.settings.replyMode.mentioned')?.disabled).toBe(true);});- it('reauthorizes a server attachment on tap and opens the existing image viewer', async () => {+ it.each([undefined, 'thread-root'])('gates server previews by the viewport and reauthorizes on tap (thread=%s)', async (threadRootId) => {const attachment = { id: 'media', name: 'picture.png', mimeType: 'image/png', size: 10, category: 'image' as const, url: 'https://media.example.invalid/one-use', path: null };h.chat = { ...h.chat, server: true, media: vi.fn(async () => attachment) };- await render(group({ messages: [message('picture', 1, { authorKind: 'user', isSelf: false, attachments: [{ ...attachment, url: null, category: 'file' }] })], plans: [], openPlan: null }));+ await render(group({ messages: [message('picture', 1, { authorKind: 'user', isSelf: false, attachments: [{ ...attachment, url: null, category: 'file' }] })], plans: [], openPlan: null }), 'ready', threadRootId);expect(h.chat.media).not.toHaveBeenCalled();let row = byId('attachmentStrip') as HTMLElement & { nativeLayout?: (event: unknown) => void };while (!row.nativeLayout) row = row.parentElement as typeof row;diff --git a/apps/mobile/src/__tests__/botGroupAttachmentLightbox.test.tsx b/apps/mobile/src/__tests__/botGroupAttachmentLightbox.test.tsxindex c164b005ed..c56e8fa8ff 100644--- a/apps/mobile/src/__tests__/botGroupAttachmentLightbox.test.tsx+++ b/apps/mobile/src/__tests__/botGroupAttachmentLightbox.test.tsx@@ -164,6 +164,28 @@ describe('Chat Server group image attachments (#5875)', () => {expect(container.querySelector('img')?.getAttribute('src')).toBe(signedImageUrl);});+ it('keeps a multi-image history offscreen while loading the latest row, then authorizes again on tap', async () => {+ const visibility = new MessageListVisibility();+ const resolveServerMedia = vi.fn(async (id: string) => ({ ...serverAttachment, id, category: 'image' as const, url: `${signedImageUrl}#${id}` }));+ const container = await render({}, visibility);+ await act(async () => root!.render(createElement(MessageListVisibilityContext.Provider, { value: visibility },+ ...['history', 'latest'].map(messageId => createElement(BotGroupMessageAttachments, {+ key: messageId, messageId, align: 'right', resolveServerMedia, onResolveRemoteMedia: vi.fn(),+ attachments: (messageId === 'history' ? ['old-1', 'old-2'] : ['latest']).map(id => ({ ...serverAttachment, id })),+ })),+ )));+ expect(resolveServerMedia).not.toHaveBeenCalled();+ await act(async () => visibility.update([{ key: 'latest', isViewable: true }]));+ expect(resolveServerMedia.mock.calls.map(([id]) => id)).toEqual(['latest']);+ expect(container.querySelectorAll('img')).toHaveLength(1);+ await act(async () => visibility.update([{ key: 'history', isViewable: true }]));+ expect(resolveServerMedia.mock.calls.map(([id]) => id)).toEqual(['latest', 'old-1', 'old-2']);+ expect(container.querySelectorAll('img')).toHaveLength(3);+ await click(container.querySelector(`img[src="${signedImageUrl}#old-2"]`)?.closest('[data-testid="message.mediaPreviewButton"]'));+ expect(resolveServerMedia.mock.calls.map(([id]) => id)).toEqual(['latest', 'old-1', 'old-2', 'old-2']);+ expect(container.querySelector('[data-testid="message.imageLightbox"] img')?.getAttribute('src')).toBe(`${signedImageUrl}#old-2`);+ });+it('shows an authorized HTTPS image in the real lightbox, re-authorizing on every tap', async () => {const resolveServerMedia = vi.fn(async (id: string): Promise<BotGroupAttachment> => ({id, name: '1.png', category: 'image', mimeType: 'image/png', size: 10, url: signedImageUrl, path: null,