Commit 22ccf3f
authored
Test/dark mode brightness assertions (#2097)
## 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.
One example is the PR where the monitor around Git's version number
is removed, which caused the dark mode tests to fail, even though the
new look did not change anything about how dark the dark mode is.
Instead, we now verify **perceived brightness** using the standard
definition of *relative luminance* from color science (per
[Wikipedia](https://en.wikipedia.org/wiki/Relative_luminance)), which
aligns with human vision sensitivity (green contributes most, blue
least).
Reference:
#2088 (comment)File tree
11 files changed
+53
-10
lines changed- tests
- git-scm.spec.js-snapshots
11 files changed
+53
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
319 | 347 | | |
| 348 | + | |
320 | 349 | | |
321 | | - | |
| 350 | + | |
322 | 351 | | |
323 | 352 | | |
324 | 353 | | |
| 354 | + | |
325 | 355 | | |
326 | 356 | | |
327 | | - | |
328 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
329 | 362 | | |
330 | | - | |
| 363 | + | |
| 364 | + | |
331 | 365 | | |
332 | | - | |
| 366 | + | |
| 367 | + | |
333 | 368 | | |
| 369 | + | |
334 | 370 | | |
335 | | - | |
336 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
337 | 375 | | |
338 | 376 | | |
339 | 377 | | |
340 | 378 | | |
341 | 379 | | |
342 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
343 | 385 | | |
344 | | - | |
345 | | - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 commit comments