mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
Wait for a page's placeholders before measuring its height
The over-scroll guard measured a settings page while two of its cards were still showing their loading state, and read a height that no longer existed a moment later. The page was blamed for a second scroll surface it did not have. The gate waited on the layout shell, which is present long before the data under it, and its own documentation says a sentinel has to be something the measurement depends on. It now also waits for the loading placeholders the app marks in the markup, and gives up quietly rather than failing if one legitimately stays, since a timeout would be a worse failure than the one being prevented.
This commit is contained in:
1 parent
5ef7fa86a8
commit
842a24f1d1
1 file changed
+11
@@ -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(() => {});
|
||||
|
||||
Reference in new issue
Block a user