Repository navigation
Fix flaky avatar middleware tests - #5874
Merged
Merged
Conversation
When the avatar image is not available at first paint, the browser repaints its area later, and anti-aliased rounded edges around it may differ by a few pixels from a full paint. Preload and decode the avatar images before rendering, and keep them referenced so they stay available.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in these narrow test-only changes; browser tests were not rerun during review.
No open issues 🎉
What changed in this PR
Stabilizes avatar middleware snapshots by ensuring avatar images are decoded before rendering. Changes are limited to test infrastructure and tests.
Changes:
- Adds and exports
preloadImages()to load, decode, and retain images. - Updates ten avatar middleware tests to preload both avatars before rendering.
| File | Description |
|---|---|
| packages/test/page-object/src/globals/testHelpers/preloadImages.js | Adds image preloading helper. |
| packages/test/page-object/src/globals/testHelpers/index.js | Exports the helper. |
| tests/html2/middleware/avatar/useBuildRenderAvatarCallback.html | Preloads avatars for callback tests. |
| tests/html2/middleware/avatar/renderProxy.html | Preloads avatars for proxy tests. |
| tests/html2/middleware/avatar/polymiddleware/decorate.html | Preloads avatars for decoration tests. |
| tests/html2/middleware/avatar/polymiddleware/changing.html | Preloads avatars for middleware-change tests. |
| tests/html2/middleware/avatar/polymiddleware/addOrReplace.html | Preloads avatars for replacement tests. |
| tests/html2/middleware/avatar/legacyAvatarMiddleware/styleOptions.html | Preloads avatars for legacy styling tests. |
| tests/html2/middleware/avatar/legacyAvatarMiddleware/decorate.html | Preloads avatars for legacy decoration tests. |
| tests/html2/middleware/avatar/legacyAvatarMiddleware/changing.html | Preloads avatars for legacy middleware-change tests. |
| tests/html2/middleware/avatar/legacyAvatarMiddleware/addOrReplace.html | Preloads avatars for legacy replacement tests. |
| tests/html2/middleware/avatar/backwardCompatibility.html | Preloads avatars for compatibility tests. |
Review effort: Balanced
Eugene (OEvgeny)
enabled auto-merge (squash)
October 16, 2026 22:17
William Wong (compulim)
approved these changes
Oct 16, 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.
Changelog Entry
Not required, development only.
Description
Avatar middleware tests failed a few pixels off the snapshot in about 3-5% of runs, e.g. 2 shards in the last CI run of #5873. When the avatar image is not available at first paint, the browser repaints its area later, and the anti-aliased rounded edges around it come out slightly different.
Design
Layout is identical in failing runs, only anti-aliased edges differ. With images preloaded, 0 failures in 300 local runs, down from about 3-5%.
Specific Changes
Added
testHelpers.preloadImages(), which loads and decodes images, and keeps them available until they are renderedAvatar middleware tests preload the avatar images before rendering
I have added tests and executed them locally
I have updated
CHANGELOG.mdI have updated documentation
Review Checklist
z-index)package.jsonandpackage-lock.jsonreviewed