test(canvas): add uploadChatFiles + downloadChatFile coverage — 7 cases #829

Merged
devops-engineer merged 4 commits from test/canvas-upload-chat-file-coverage into staging 2026-05-13 13:33:16 +00:00

4 Commits

Author SHA1 Message Date
6b4bcb3b94 fix(canvas/tests): mock Response.blob() to avoid blob.stream() in jsdom
All checks were successful
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 9s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
CI / Detect changes (pull_request) Successful in 22s
sop-checklist-gate / gate (pull_request) Successful in 12s
sop-tier-check / tier-check (pull_request) Successful in 14s
CI / Platform (Go) (pull_request) Successful in 5s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 4s
CI / Python Lint & Test (pull_request) Successful in 6s
CI / Canvas (Next.js) (pull_request) Successful in 13m52s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Successful in 4s
audit-force-merge / audit (pull_request) Successful in 20s
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.
2026-05-13 12:54:40 +00:00
ef87b2e3e8 fix(canvas/test): correct upload test mock/assertion + add try/finally for fetchMock
Some checks failed
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 33s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
CI / Detect changes (pull_request) Successful in 1m22s
sop-checklist-gate / gate (pull_request) Successful in 39s
sop-tier-check / tier-check (pull_request) Successful in 39s
CI / Platform (Go) (pull_request) Successful in 10s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 6s
CI / Python Lint & Test (pull_request) Successful in 10s
CI / Canvas (Next.js) (pull_request) Failing after 12m5s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Failing after 5s
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>
2026-05-13 11:57:07 +00:00
6041e36cf1 test(canvas): add uploadChatFiles + downloadChatFile coverage — 7 cases
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>
2026-05-13 11:57:07 +00:00
7ebaa3a686 fix(chat): omit attachments key from createMessage when no files provided
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>
2026-05-13 11:57:07 +00:00