Skip to content

Fix flaky avatar middleware tests - #5874

Merged
Eugene (OEvgeny) merged 1 commit into
mainfrom
OEvgeny/fix-flaky-avatar-tests
Oct 16, 2026
Merged

Eugene (OEvgeny) merged 1 commit into
mainfrom
OEvgeny/fix-flaky-avatar-tests

Conversation

@OEvgeny

Copy link
Copy Markdown
Collaborator

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 rendered

  • Avatar middleware tests preload the avatar images before rendering

  • I have added tests and executed them locally

  • I have updated CHANGELOG.md

  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@OEvgeny
Eugene (OEvgeny) enabled auto-merge (squash) October 16, 2026 22:17
@OEvgeny
Eugene (OEvgeny) merged commit e927c50 into main Oct 16, 2026
33 checks passed
@OEvgeny
Eugene (OEvgeny) deleted the OEvgeny/fix-flaky-avatar-tests branch October 16, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants