In jsdom, Blob does not implement stream(), but Node.js Response
internally calls blob.stream() when constructing with a Blob body.
Replace the new Response(blob) pattern with a plain object mock that
exposes .blob() directly, matching the download path used in production.
Issue 1 (fixed): "successful upload" test passed 1 file to uploadChatFiles
but expected result.length===2 from the mock. Now passes 2 files so the
assertion validates the complete response round-trip.
Issue 2 (fixed): fetchMock.mockRestore() called inline at end of each test
without try/finally. Now uses beforeEach/afterEach pattern consistent with
downloadChatFile describe block and consoleErrorSpy.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
New test cases in uploads.test.ts covering the two untested exports:
- uploadChatFiles empty-file guard (returns [] without calling fetch)
- uploadChatFiles successful upload returns ChatAttachment[]
- uploadChatFiles throws on non-ok response
- downloadChatFile opens external HTTPS URLs via window.open (no fetch)
- downloadChatFile fetches and triggers blob download for platform attachments
- downloadChatFile throws on non-ok download response
Closes gap from canvas test coverage audit (2026-05-13).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Object.keys({ attachments: undefined }) still includes "attachments" as a
key, breaking the "returns a plain object with expected keys" test. Fix by
conditionally spreading attachments only when non-empty, and Object.freeze
the return value to preserve the existing immutability assertion.
Fixes 2 test cases in createMessage.test.ts.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>