mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-08-25 20:46:31 +00:00
fix(e2e): composite text colour onto its own ground before measuring contrast
`paint()` clears to transparent and the label was painted alone, so a translucent text token kept its opaque base: 30% black on white measured 21:1 instead of 2.12:1 — a failing token reported as perfect contrast. Paint the label on the same layer stack as the surface. No probed token is translucent today, so every current reading is unchanged (7/7 still pass); this stops the helper lying about the next one. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
dbfdbe0e8d
commit
fadde5ad5a
@@ -138,11 +138,14 @@ export const measureContrast = async (page: Page, probe: string): Promise<number
|
||||
return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
|
||||
};
|
||||
|
||||
const surface = paint(
|
||||
// The text goes on top of the same stack, not on its own: `paint` starts from transparent,
|
||||
// where a translucent colour keeps its opaque base and reads as a contrast it does not have.
|
||||
const ground = [
|
||||
getComputedStyle(element.parentElement).backgroundColor,
|
||||
getComputedStyle(element).backgroundColor,
|
||||
);
|
||||
const label = paint(getComputedStyle(element).color);
|
||||
];
|
||||
const surface = paint(...ground);
|
||||
const label = paint(...ground, getComputedStyle(element).color);
|
||||
const [high = 0, low = 0] = [luminance(label), luminance(surface)].sort((a, b) => b - a);
|
||||
|
||||
return (high + 0.05) / (low + 0.05);
|
||||
|
||||
Reference in New Issue
Block a user