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): make responsive + metrics tests fail on real bugs (#3979)

LearningCircuitab1b9fc6b851
diff --git a/.file-whitelist.txt b/.file-whitelist.txt
index b9e0b60282..fc8de7cd00 100644
--- a/.file-whitelist.txt
+++ b/.file-whitelist.txt
@@ -31,6 +31,9 @@
^tests/(.*/)?package\.json$
^tests/(.*/)?package-lock\.json$
^tests/settings/golden_master_settings\.json$
+# Allowlist of currently-known responsive UI bugs; checked-in baseline
+# for test_responsive_ui_comprehensive.js so new regressions can fail.
+^tests/ui_tests/responsive_baseline\.json$
# Journal-quality data: all datasets are runtime-downloaded into the user
# data dir, never bundled. Only __init__.py lives in the package data dir.
diff --git a/.gitignore b/.gitignore
index b027fd990b..975dca494e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -132,6 +132,11 @@ tests/**/*.json
tests/ui_tests/*.json
tests/ui_tests/results/
+# …but the responsive baseline is checked in on purpose: it's the
+# allowlist of currently-known UI bugs that test_responsive_ui_comprehensive.js
+# compares against. New regressions vs this list fail the test.
+!tests/ui_tests/responsive_baseline.json
+
# Still block Python cache and build artifacts even if they match patterns above
__pycache__/
**/__pycache__/
diff --git a/tests/ui_tests/responsive_baseline.json b/tests/ui_tests/responsive_baseline.json
new file mode 100644
index 0000000000..d6fcd81458
--- /dev/null
+++ b/tests/ui_tests/responsive_baseline.json
@@ -0,0 +1,66 @@
+{
+ "_README": [
+ "Known responsive UI issues — checked-in baseline for test_responsive_ui_comprehensive.js.",
+ "Each entry is the exact issue string the test produces (without the leading '⚠️ ' emoji).",
+ "When you fix one of these issues in the UI, the test will fail with a clear message",
+ "telling you to remove the matching line from this file so the baseline stays honest.",
+ "When a NEW issue appears that isn't here, the test fails as a regression.",
+ "Goal over time: every entry below disappears as the corresponding UI bug is fixed."
+ ],
+ "mobile": [
+ "Home: Overlapping elements detected at mobile",
+ "Home: Text too small for mobile viewing",
+ "Home: Touch targets too small (< 44px)",
+ "Settings: Overlapping elements detected at mobile",
+ "Settings: Text too small for mobile viewing",
+ "Settings: Touch targets too small (< 44px)",
+ "Metrics: Overlapping elements detected at mobile",
+ "Metrics: Text too small for mobile viewing",
+ "Metrics: Touch targets too small (< 44px)",
+ "History: Overlapping elements detected at mobile",
+ "History: Text too small for mobile viewing",
+ "News: Overlapping elements detected at mobile",
+ "News: Text too small for mobile viewing",
+ "News: Touch targets too small (< 44px)",
+ "Metrics-ContextOverflow: Overlapping elements detected at mobile",
+ "Metrics-ContextOverflow: Text too small for mobile viewing",
+ "Metrics-ContextOverflow: Touch targets too small (< 44px)",
+ "Metrics-Costs: Overlapping elements detected at mobile",
+ "Metrics-Costs: Text too small for mobile viewing",
+ "Metrics-Costs: Touch targets too small (< 44px)",
+ "Metrics-StarReviews: Overlapping elements detected at mobile",
+ "Metrics-StarReviews: Text too small for mobile viewing",
+ "Metrics-StarReviews: Touch targets too small (< 44px)",
+ "Metrics-Links: Overlapping elements detected at mobile",
+ "Metrics-Links: Text too small for mobile viewing",
+ "Metrics-Links: Touch targets too small (< 44px)",
+ "News-Subscriptions: Overlapping elements detected at mobile",
+ "News-Subscriptions: Text too small for mobile viewing",
+ "News-Subscriptions: Touch targets too small (< 44px)",
+ "News-NewSubscription: Overlapping elements detected at mobile",
+ "News-NewSubscription: Text too small for mobile viewing",
+ "News-NewSubscription: Touch targets too small (< 44px)",
+ "Benchmark: Overlapping elements detected at mobile",
+ "Benchmark: Text too small for mobile viewing",
+ "Benchmark: Touch targets too small (< 44px)",
+ "BenchmarkResults: Overlapping elements detected at mobile",
+ "BenchmarkResults: Text too small for mobile viewing",
+ "BenchmarkResults: Touch targets too small (< 44px)"
+ ],
+ "desktop": [
+ "Home: Horizontal overflow detected at desktop",
+ "Home: Overlapping elements detected at desktop",
+ "Settings: Overlapping elements detected at desktop",
+ "Metrics: Overlapping elements detected at desktop",
+ "History: Overlapping elements detected at desktop",
+ "News: Overlapping elements detected at desktop",
+ "Metrics-ContextOverflow: Overlapping elements detected at desktop",
+ "Metrics-Costs: Overlapping elements detected at desktop",
+ "Metrics-StarReviews: Overlapping elements detected at desktop",
+ "Metrics-Links: Overlapping elements detected at desktop",
+ "News-Subscriptions: Overlapping elements detected at desktop",
+ "News-NewSubscription: Overlapping elements detected at desktop",
+ "Benchmark: Overlapping elements detected at desktop",
+ "BenchmarkResults: Overlapping elements detected at desktop"
+ ]
+}
diff --git a/tests/ui_tests/test_metrics_dashboard.js b/tests/ui_tests/test_metrics_dashboard.js
index 0ce7393f85..da10f6de9f 100644
--- a/tests/ui_tests/test_metrics_dashboard.js
+++ b/tests/ui_tests/test_metrics_dashboard.js
@@ -139,17 +139,22 @@ async function testMetricsDashboard() {
log('\n=== TESTING METRICS DASHBOARD ===', 'section');
await page.goto(`${BASE_URL}/metrics`);
- // Wait for page to load - check multiple possible selectors
+ // Wait for page to load - check multiple possible selectors. If
+ // neither the expected container nor the URL matches, the metrics
+ // dashboard is broken and we want the test to fail loudly rather
+ // than continue and emit downstream "may not be working" warnings.
try {
await page.waitForSelector('.metrics-container, #metrics-dashboard, .container h1, [data-page="metrics"]', { timeout: 10000 });
log('✅ Metrics page loaded', 'success');
} catch {
- // Check if we're on the metrics page by URL
const currentUrl = page.url();
if (currentUrl.includes('/metrics')) {
log('✅ On metrics page (by URL)', 'success');
} else {
- log('⚠️ Could not verify metrics page loaded', 'warning');
+ throw new Error(
+ `Metrics dashboard did not load: no expected selector and URL is ${currentUrl}. ` +
+ 'Either the route is broken or the page renders without any of the known root selectors.'
+ );
}
}
@@ -273,7 +278,13 @@ async function testMetricsDashboard() {
}
}
} else {
- log('⚠️ Metrics grid not found on page', 'warning');
+ // The page-level metrics grid container is what holds the
+ // primary stat cards. If it's missing, the dashboard is
+ // structurally broken — fail rather than warn.
+ throw new Error(
+ 'Metrics grid container (.ldr-metrics-grid / .metrics-grid) not found on /metrics. ' +
+ 'The dashboard layout has regressed.'
+ );
}
}
@@ -315,7 +326,12 @@ async function testMetricsDashboard() {
if (recentApiCalls.length > 0) {
log('✅ Period selector works - API called with new period', 'success');
} else {
- log('⚠️ Period selector may not be working correctly', 'warning');
+ // The selector is rendered but changing it didn't trigger an
+ // API call with the new period — the period filter is broken.
+ throw new Error(
+ 'Period selector exists but changing it did not trigger an API call with period=7d. ' +
+ 'The filter handler has regressed.'
+ );
}
}
diff --git a/tests/ui_tests/test_responsive_ui_comprehensive.js b/tests/ui_tests/test_responsive_ui_comprehensive.js
index 8aa74cf97c..2b08642c87 100644
--- a/tests/ui_tests/test_responsive_ui_comprehensive.js
+++ b/tests/ui_tests/test_responsive_ui_comprehensive.js
@@ -458,6 +458,44 @@ class ResponsiveUITester {
}
}
+ /**
+ * Compare the warnings produced by this run against the checked-in
+ * baseline (responsive_baseline.json). Three outcomes:
+ *
+ * 1. Issues match the baseline exactly → return null (test passes).
+ * 2. New issues appeared that aren't in the baseline → REGRESSION.
+ * Caller should fail the test loudly so a PR can't introduce a
+ * new responsive bug without notice.
+ * 3. Baseline issues are no longer present → BASELINE STALE.
+ * Caller should fail the test so the contributor who fixed the
+ * bug is forced to remove the entry; this prevents the baseline
+ * from silently masking a future regression.
+ *
+ * Returning a structured result so the caller can format messaging.
+ */
+ diffAgainstBaseline() {
+ const baselinePath = path.join(__dirname, 'responsive_baseline.json');
+ let baseline;
+ try {
+ baseline = JSON.parse(fs.readFileSync(baselinePath, 'utf8'));
+ } catch (err) {
+ return {
+ error: `Could not read responsive_baseline.json: ${err.message}`,
+ };
+ }
+ const expected = (baseline[this.viewport] || []).slice().sort();
+ // Strip the leading "⚠️ " emoji+space the test prepends so the JSON
+ // file stays plain ASCII and easier to diff.
+ const actual = this.results.issues
+ .map((issue) => issue.replace(/^⚠️\s+/u, ''))
+ .slice()
+ .sort();
+
+ const newRegressions = actual.filter((i) => !expected.includes(i));
+ const fixedIssues = expected.filter((i) => !actual.includes(i));
+ return { newRegressions, fixedIssues };
+ }
+
printResults() {
console.log('\n' + '='.repeat(50));
console.log('RESPONSIVE UI TEST RESULTS');
@@ -476,10 +514,55 @@ class ResponsiveUITester {
console.log('='.repeat(50));
- // Exit with error if there are failures
+ // Page-level test failures (e.g. nav errors) always fail the run.
if (this.results.failed > 0) {
process.exit(1);
}
+
+ // Compare warnings against the checked-in baseline. New responsive
+ // bugs fail the run; old bugs that are now fixed also fail so the
+ // baseline must be kept honest.
+ const diff = this.diffAgainstBaseline();
+ if (diff.error) {
+ console.error(`\n❌ Baseline check failed: ${diff.error}`);
+ process.exit(1);
+ }
+ if (diff.newRegressions.length > 0) {
+ console.error(
+ '\n❌ NEW responsive issues not in responsive_baseline.json ' +
+ `(${this.viewport}):`
+ );
+ diff.newRegressions.forEach((i) => console.error(` + ${i}`));
+ console.error(
+ '\nIf this is an intentional change, add the lines above to ' +
+ `responsive_baseline.json under "${this.viewport}". ` +
+ 'Otherwise the PR is introducing a responsive regression.'
+ );
+ process.exit(1);
+ }
+ // We *warn* but don't fail when baseline entries don't reproduce in
+ // this run. Some warnings (notably touch-target detection on dynamic
+ // content) are intermittent — failing on a missing one would be flaky.
+ // If a maintainer has actually fixed an issue, they can confirm by
+ // running the test a few times and then trim responsive_baseline.json
+ // manually.
+ if (diff.fixedIssues.length > 0) {
+ console.warn(
+ `\nℹ️ Some baseline entries did not reproduce this run ` +
+ `(${this.viewport}):`
+ );
+ diff.fixedIssues.forEach((i) => console.warn(` - ${i}`));
+ console.warn(
+ `\nIf you've fixed these issues, please re-run the test 3+ ` +
+ 'times and remove the entries above from responsive_baseline.json. ' +
+ "(Not failing the run because some warnings are intermittent.)"
+ );
+ }
+
+ console.log(
+ `\n✅ Responsive issues within baseline (${this.viewport}): ` +
+ `${this.results.warnings} warning(s) this run, no regressions.`
+ );
}
}