Skip to content

Commit f8b38fb

Browse files
committed
test(e2e): poll for initial shrink-to-fit zoom before asserting
The initial fit-to-width in the pdf viewer measures container.clientWidth immediately after showViewer() flips display:flex. Under CI load the reflow can lag a tick, leaving widthFit >= 1.0 and zoom at 100% when first read, which intermittently fails the toBeLessThan(100) assertion (~6 failures in the 30 runs since #583). Swap the single-shot read for expect.poll, matching the pattern already used for the post-fullscreen assertion below, then capture inlineZoom for the subsequent comparison.
1 parent 621a70a commit f8b38fb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/e2e/pdf-viewer-zoom.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ test.describe("PDF Viewer — fullscreen fit + pinch zoom", () => {
6363
await waitForPdfRender(page);
6464
const app = getAppFrame(page);
6565

66+
// Initial fit-to-width measures container.clientWidth immediately after
67+
// showViewer() flips display:flex; under CI load the reflow can lag, so
68+
// poll until the shrink-to-fit scale has actually applied.
69+
await expect
70+
.poll(() => readZoomPercent(page), { timeout: 5000 })
71+
.toBeLessThan(100);
6672
const inlineZoom = await readZoomPercent(page);
67-
expect(inlineZoom).toBeLessThan(100);
6873

6974
// Widen + give plenty of height, then enter fullscreen. Fullscreen uses
7075
// fit-to-PAGE (whole page visible), so the resulting zoom is whichever

0 commit comments

Comments
 (0)