Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(tests): wait for async content to settle in mobile-safari nav tests (#4439)

LearningCircuite87da6b8e72d
diff --git a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js
index e21549a05d..c7db0b2b8c 100644
--- a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js
+++ b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js
@@ -388,6 +388,35 @@ test.describe('All Pages - Content Above Mobile Nav', () => {
// `load`, leaving zero time for the DOM walk below.
await page.waitForLoadState('load', { timeout: 3000 }).catch(() => {});
+ // Wait for async-loaded content to settle before scrolling.
+ // History, News, Library and Metrics populate their lists via XHR
+ // *after* `load` fires. History/News/Library have no content-ready wait
+ // in waitForPageLoad at all, and Metrics only waits for its cards to
+ // exist (not for the layout to stop shifting). A single scroll-to-bottom
+ // taken mid-load lands on a stale layout; the list then resolves to its
+ // empty-state and the page's bottom controls (search inputs, filter
+ // dropdowns) end up behind the fixed mobile nav — which the assertion
+ // below flags as "hidden behind nav". The #4314 clearance padding is
+ // already sufficient; the failures were a measurement race, confirmed by
+ // trace snapshots showing loading spinners still present at assertion time
+ // on /history/, /news/, /library/, /metrics/.
+ //
+ // Poll until the document height is stable across two consecutive samples.
+ // Bounded so pages with continuous lazy-loading (e.g. `/`) still proceed
+ // instead of hanging — the exact failure mode that retired the old
+ // scrollY-based poll referenced below.
+ await page
+ .waitForFunction(
+ () => {
+ const h = document.documentElement.scrollHeight;
+ const prev = window.__ldrPrevScrollH;
+ window.__ldrPrevScrollH = h;
+ return prev !== undefined && Math.abs(h - prev) < 2;
+ },
+ { timeout: 4000, polling: 250 }
+ )
+ .catch(() => {});
+
// Scroll to bottom to check last content. scrollTo() is synchronous inside
// page.evaluate(): the browser commits the scroll before the evaluate resolves,
// so an additional `waitForFunction(scrollY >= scrollHeight)` poll is redundant.
diff --git a/tests/ui_tests/playwright/tests/interactive-states.spec.js b/tests/ui_tests/playwright/tests/interactive-states.spec.js
index ffb37e0083..452caacb4e 100644
--- a/tests/ui_tests/playwright/tests/interactive-states.spec.js
+++ b/tests/ui_tests/playwright/tests/interactive-states.spec.js
@@ -217,9 +217,13 @@ test.describe('Mobile More Menu - Navigation', () => {
if (await metricsItem.count() > 0 && await metricsItem.first().isVisible()) {
await metricsItem.first().click();
- await page.waitForLoadState('domcontentloaded');
- // Should now be on the metrics page
+ // Wait for the navigation to actually land on /metrics before
+ // asserting. waitForLoadState('domcontentloaded') resolves immediately
+ // when the current document is already loaded, so the URL check could
+ // race the (JS-driven) navigation and still observe '/'. waitForURL
+ // blocks until the address bar reflects the new page.
+ await page.waitForURL(/\/metrics/, { timeout: 10000 });
expect(page.url()).toContain('/metrics');
}
}