Tests for canvas fallback heic converter#71052
Conversation
|
@dominictb Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive unit tests for the canvasFallback function that was previously introduced to handle HEIC image conversion. The function was moved from the heicConverter module to FileUtils and now needs proper test coverage.
- Adds unit tests for the
canvasFallbackfunction covering various scenarios including successful conversion, error cases, and image scaling - Moves the
canvasFallbackfunction from heicConverter to FileUtils and exports it - Updates the heicConverter import to use the function from FileUtils
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/unit/FileUtilsTest.ts | Adds comprehensive test suite for canvasFallback function with mock setup and multiple test cases |
| src/libs/fileDownload/heicConverter/index.ts | Removes canvasFallback function and imports it from FileUtils instead |
| src/libs/fileDownload/FileUtils.ts | Adds canvasFallback function implementation and exports it |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| jest.clearAllMocks(); | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
| (global as any).createImageBitmap = mockCreateImageBitmap; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
| (global as any).document = { | ||
| createElement: mockCreateElement, | ||
| }; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
| (global as any).URL = mockURL; |
There was a problem hiding this comment.
[nitpick] The repeated eslint-disable comments create visual clutter. Consider extracting the global object assignments to helper functions or using a more concise approach to reduce the duplication of these long disable comments.
| // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
| expect((result as any).uri).toBe('blob:mock-url'); |
There was a problem hiding this comment.
[nitpick] Casting to any to access the uri property suggests a type definition issue. Consider creating a proper type interface that extends File with the uri property, or use a more type-safe assertion method.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid-native.webmAndroid: mWeb Chromeandroid-web.webmiOS: mWeb Safariios-web.movMacOS: Chrome / Safarimac-web.movMacOS: Desktopmac-desktop.mov |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/inimaga in version: 9.2.18-0 🚀
|
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.2.18-7 🚀
|

Explanation of Change
This is a follow-up to the PR → #70273
Added the unit tests for the newly created canvasFallback function.
Fixed Issues
$ #68778
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop