Skip to content

Conversation

RafaelJohn9
Copy link
Contributor

Changes

  • Replaced pixel-based visual regression tests for dark/light mode with perceptually accurate brightness assertions.
  • Implemented a getPageBrightness() helper that computes relative luminance using the ITU-R BT.709/sRGB coefficients (0.2126*R + 0.7152*G + 0.0722*B), normalized to the [0, 1] range.
  • Added assertions that light mode brightness is approximately 0.85 ± 0.1 and dark mode is 0.25 ± 0.1.
  • Removed all stored screenshot snapshots for dark/light mode across browsers and devices.

Context

Pixel-diff-based screenshot tests are fragile they fail on minor layout shifts, anti-aliasing changes, or browser rendering differences, even when the visual theme (light/dark) is correct.

Instead, we now verify perceived brightness using the standard definition of relative luminance from color science (per Wikipedia), which aligns with human vision sensitivity (green contributes most, blue least).

Reference: #2088 (comment)

Replace pixel-based screenshot comparisons with perceptually accurate
brightness assertions using ITU-R BT.709 relative luminance (0.2126R + 0.7152G + 0.0722B),
normalized to [0,1]. Assert light mode ≈0.85 and dark mode ≈0.25.

Signed-off-by: rafaeljohn9 <[email protected]>
Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

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

Very nice!

The only addition (which I will make in the merge commit's message) is to talk in the commit message about what motivated this change: The PR build failure in #2088 that shouldn't have included a test failure (pointing out that the assertions were ill-specified).

@dscho dscho merged commit 22ccf3f into git:gh-pages Oct 2, 2025
1 check passed
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.

2 participants