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.

test(ui-tests): replace delay(1000) with polling in context-overflow tests (#4708)

LearningCircuited777c4cba9a
diff --git a/tests/ui_tests/test_context_overflow_ci.js b/tests/ui_tests/test_context_overflow_ci.js
index 8a1e68d507..7158b251b0 100644
--- a/tests/ui_tests/test_context_overflow_ci.js
+++ b/tests/ui_tests/test_context_overflow_ci.js
@@ -7,7 +7,7 @@
* Run: node test_context_overflow_ci.js
*/
-const { setupTest, teardownTest, TestResults, log, delay, navigateTo, withTimeout } = require('./test_lib');
+const { setupTest, teardownTest, TestResults, log, navigateTo, withTimeout } = require('./test_lib');
// ============================================================================
// Context Overflow Page Tests
@@ -48,7 +48,24 @@ const ContextOverflowTests = {
async truncationRateDisplay(page, baseUrl) {
await navigateTo(page, `${baseUrl}/metrics/context-overflow`);
- await delay(1000); // Wait for the JS controller to fetch + render (or show empty state)
+
+ // Poll for the controller to resolve one of two end states:
+ // (1) #truncation-rate injected (data path), or
+ // (2) #empty-no-data shown (no-LLM / fresh-DB path).
+ // Replaces a fixed delay(1000) — the controller resolves quickly when idle,
+ // but polling avoids flakiness if the fetch is slow under CI load.
+ try {
+ await page.waitForFunction(
+ () => {
+ if (document.getElementById('truncation-rate')) return true;
+ const empty = document.getElementById('empty-no-data');
+ return !!empty && getComputedStyle(empty).display !== 'none';
+ },
+ { timeout: 5000 }
+ );
+ } catch (_) {
+ // Fall through — the assertion below reports what's actually on the page.
+ }
// The truncation rate is rendered by context-overflow.js into the
// overflow-specific element `#truncation-rate` (inside #context-overflow-section),
@@ -140,7 +157,22 @@ const ContextOverflowTests = {
async contextOverflowChart(page, baseUrl) {
await navigateTo(page, `${baseUrl}/metrics/context-overflow`);
- await delay(1000); // Wait for the JS controller to render charts or the empty state
+
+ // Poll for the controller to resolve one of two end states:
+ // (1) #context-chart canvas injected (data path), or
+ // (2) #empty-no-data shown (no-LLM / fresh-DB path).
+ try {
+ await page.waitForFunction(
+ () => {
+ if (document.getElementById('context-chart')) return true;
+ const empty = document.getElementById('empty-no-data');
+ return !!empty && getComputedStyle(empty).display !== 'none';
+ },
+ { timeout: 5000 }
+ );
+ } catch (_) {
+ // Fall through — the assertion below reports what's actually on the page.
+ }
// The overflow scatter chart is a single page-specific <canvas id="context-chart">
// that context-overflow.js injects into #context-overflow-section, and ONLY when