Browse Source

test(client): cover instant image echo branches

creatixchu 2 weeks ago
parent
commit
2dd59b2ca1

+ 7 - 1
packages/client/ui-attachment/tests/message-image.client.spec.tsx

@@ -207,10 +207,16 @@ describe('ImageGallery', () => {
     const empty = render(<ImageGallery images={[]} load={load} align="start" labels={labels} />)
     expect(empty.container.firstChild).toBeNull()
     const view = render(
-      <ImageGallery images={[{ attachment }, { attachment }]} load={load} align="end" labels={labels} />,
+      <ImageGallery
+        images={[{ attachment }, { preview: { url: 'blob:echo', name: 'echo.png' } }, { attachment }]}
+        load={load}
+        align="end"
+        labels={labels}
+      />,
     )
     expect(view.container.querySelector('[data-align="end"]')).not.toBeNull()
     await waitFor(() => { expect(view.getAllByAltText('history.png')).toHaveLength(2) })
+    expect(view.getByAltText('echo.png')).toBeTruthy()
   })
 
   it('renders a lone image large and several images as square tiles', () => {

+ 3 - 1
packages/client/ui-chat/tests/apply-inject.client.spec.tsx

@@ -169,8 +169,10 @@ describe('Chat inject API', () => {
     injected.chatScroll.save(null)
     expect(injected.chatScroll.read()).toBeNull()
 
-    await expect(injected.loadImage(ATTACHMENT)).resolves.toEqual(expect.any(String))
+    const loaded = await injected.loadImage(ATTACHMENT)
+    expect(loaded).toEqual(expect.any(String))
     expect(b.session.readAttachment).toHaveBeenCalledWith(ATTACHMENT.attachmentId)
+    expect(injected.loadImage.peek?.(ATTACHMENT)).toBe(loaded)
     await b.runtime.dispose()
   })
 })

+ 3 - 0
packages/test-support/client-runtime/tests/runtime.client.spec.tsx

@@ -433,6 +433,9 @@ describe('fixture session face', () => {
     expect(() => bare.command()).toThrow(/command is not stubbed/)
     expect(() => bare.loadOlder()).toThrow(/loadOlder is not stubbed/)
     expect(() => bare.rename()).toThrow(/rename is not stubbed/)
+    const submission = bare.beginSubmission()
+    expect(submission.requestId).toBe('test-submission-1')
+    expect(() => { submission.abandon() }).not.toThrow()
     await runtime.dispose()
   })