Fix applyChange tests to pass at all screen scales#3391
Merged
Conversation
generateDataURL sizes the output canvas by window.devicePixelRatio, but the expected newSrc images were captured at 100% scale, so the IHDR dimension assertions failed on hosts at other scales. Pin devicePixelRatio to 1 for these tests so canvas output is deterministic regardless of screen scale. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
vinguyen12
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
applyChangeimage-edit tests inapplyChangeTest.ts(rotate/crop/resize cases) failed on any host whose screen scale was not 100%.generateDataURL.tssizes the output canvas astargetWidth/Height * window.devicePixelRatio, but the hardcoded expectednewSrcimages were captured at 100% scale (devicePixelRatio === 1). At other scales the generated PNG was larger, so the IHDR dimension assertions failed.This pins
window.devicePixelRatioto1for the duration of these tests (set inbeforeEach, original descriptor restored inafterEach), making the canvas output deterministic regardless of the host screen scale. Only the test file changes; production code is untouched.How to test
yarn test:fast --testPathPattern=applyChange— all 11 should pass.--force-device-scale-factor=2: