test(app): tolerate footer icon subpixel rounding (#5898)

Chromium bounding boxes differ by millionths of a pixel for equal-width footer buttons. Allow less than 0.01px in width and grouped-gap comparisons while preserving alignment and Help/Settings separation checks.
This commit is contained in:
Mohamed Boudra
2026-10-02 10:10:33 +01:00
committed by GitHub
parent bd3986d964
commit 6c985769be
@@ -225,6 +225,9 @@ const FOOTER_ICON_TEST_IDS = [
"sidebar-settings",
];
// Browser layout boxes include floating-point rounding, even for whole-pixel styles.
const FOOTER_GEOMETRY_TOLERANCE = 0.01;
/**
* One line of same-size icons: Add project, Usage and Hosts together on the left, Help and
* Settings together at the end.
@@ -240,10 +243,12 @@ export async function expectFooterIconRow(page: Page): Promise<void> {
const [first] = boxes;
for (const box of boxes) {
expect(Math.abs(box.y + box.height / 2 - first!.y - first!.height / 2)).toBeLessThan(2);
expect(box.width).toBe(first!.width);
expect(Math.abs(box.width - first!.width)).toBeLessThan(FOOTER_GEOMETRY_TOLERANCE);
}
const gaps = boxes.slice(1).map((box, index) => box.x - (boxes[index]!.x + boxes[index]!.width));
expect(gaps).toEqual([0, 0, expect.any(Number), 0]);
for (const index of [0, 1, 3]) {
expect(Math.abs(gaps[index]!)).toBeLessThan(FOOTER_GEOMETRY_TOLERANCE);
}
expect(gaps[2]).toBeGreaterThan(first!.width);
}