diff --git a/e2e/utils/settle.ts b/e2e/utils/settle.ts index 14480ab7b..de8afc088 100644 --- a/e2e/utils/settle.ts +++ b/e2e/utils/settle.ts @@ -32,6 +32,17 @@ export async function settleBeforeMeasure( } else { await expect(sentinel).toBeVisible(); } + // A shell can be visible while the data underneath it is still arriving, + // and a placeholder standing in for that data occupies height like any + // other content. Measuring then reports the geometry of a page that no + // longer exists a moment later, and blames the application for it. The + // suite marks those placeholders with a `-loading` slot, so wait for them + // to go. Never fail on the wait: a page that legitimately keeps one would + // otherwise turn every measurement on it into a timeout, which is a worse + // failure than the one being prevented. + await expect(page.locator('[data-slot$="-loading"]')) + .toHaveCount(0, { timeout: 5_000 }) + .catch(() => {}); // Fonts and late CSS change geometry after the element is visible, and // every measurement in this suite is geometric. await page.waitForLoadState("networkidle").catch(() => {});