~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
test(ui-tests): real assertions for context overflow (dead-field audit) (#4671)
LearningCircuitfce567c23e95
diff --git a/tests/ui_tests/test_context_overflow_ci.js b/tests/ui_tests/test_context_overflow_ci.jsindex 81b2575649..8a1e68d507 100644--- a/tests/ui_tests/test_context_overflow_ci.js+++ b/tests/ui_tests/test_context_overflow_ci.js@@ -16,13 +16,19 @@ const ContextOverflowTests = {async contextOverflowPageLoads(page, baseUrl) {await navigateTo(page, `${baseUrl}/metrics/context-overflow`);+ // The page-specific scaffold is server-rendered (pages/context_overflow.html):+ // <div class="ldr-page active" id="context-overflow"> ... <h1>Token Usage & Context Analytics</h1>+ // Gate the pass on that container AND the exact header text so the test+ // fails if a login/error/wrong page loaded instead. The old check passed+ // on a bare `h1, .page-title` or a body-wide "overflow"/"truncat" substring+ // (which also matches the static help-panel chrome), so it could not tell+ // the real page apart from any other page that has a heading.const result = await page.evaluate(() => {+ const container = document.getElementById('context-overflow');+ const header = container?.querySelector('.ldr-page-header h1');return {- hasContent: !!document.querySelector('.context-overflow, .overflow-container, #context-overflow, .analytics'),- hasHeader: !!document.querySelector('h1, .page-title'),- headerText: document.querySelector('h1, .page-title')?.textContent?.trim(),- hasData: document.body.textContent?.toLowerCase().includes('overflow') ||- document.body.textContent?.toLowerCase().includes('truncat'),+ hasContainer: !!container,+ headerText: header?.textContent?.trim() || '',is404: document.body.textContent?.includes('404') || document.body.textContent?.includes('Not Found')};});@@ -31,53 +37,65 @@ const ContextOverflowTests = {return { passed: null, skipped: true, message: 'Context overflow page not found (feature may not be enabled)' };}- const passed = result.hasContent || result.hasHeader || result.hasData;+ const passed = result.hasContainer && result.headerText === 'Token Usage & Context Analytics';return {passed,message: passed- ? `Context overflow page loaded (header: "${result.headerText}")`- : 'Context overflow page failed to load'+ ? `Context overflow page loaded (#context-overflow header: "${result.headerText}")`+ : `Context overflow page failed to load (container=${result.hasContainer}, header="${result.headerText}")`};},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)++ // The truncation rate is rendered by context-overflow.js into the+ // overflow-specific element `#truncation-rate` (inside #context-overflow-section),+ // and ONLY when the API returns requests_with_context_data > 0. With no LLM /+ // fresh DB (CI), there is no token data, so the controller shows the+ // #empty-no-data state and never injects #truncation-rate.+ //+ // The old test read a body-wide percentage regex, which matched the static+ // help-panel text ("Green (<10%) / Orange (10-20%) / Red (>20%)") and so+ // reported a bogus "10%" truncation rate on a page with zero data. We now+ // read the rate ONLY from #truncation-rate, and when that element is absent+ // we assert the empty-state rendered on the correct page instead of skipping.const result = await page.evaluate(() => {- const rateElement = document.querySelector(- '[class*="truncation-rate"], ' +- '[id*="truncation-rate"], ' +- '.rate-display, ' +- '.overflow-rate'- );-- // Look for percentage pattern- const percentPattern = /(\d+(?:\.\d*)?)\s*%/;- const bodyText = document.body.textContent || '';- const percentMatch = bodyText.match(percentPattern);-- // Look for rate-related text- const hasRateText = bodyText.toLowerCase().includes('truncation rate') ||- bodyText.toLowerCase().includes('overflow rate');-+ const onPage = !!document.getElementById('context-overflow');+ const rateElement = document.getElementById('truncation-rate');+ const rateText = rateElement?.textContent?.trim() || '';+ const ratePct = rateText.match(/(\d+(?:\.\d*)?)\s*%/);+ const emptyNoData = document.getElementById('empty-no-data');+ const emptyVisible = emptyNoData+ ? getComputedStyle(emptyNoData).display !== 'none'+ : false;return {+ onPage,hasRateElement: !!rateElement,- rateText: rateElement?.textContent?.trim(),- hasPercentage: !!percentMatch,- percentValue: percentMatch ? percentMatch[1] : null,- hasRateText+ rateText,+ rateIsPercent: !!ratePct,+ emptyVisible};});- if (!result.hasRateElement && !result.hasPercentage && !result.hasRateText) {- return { passed: null, skipped: true, message: 'No truncation rate display found' };+ if (result.hasRateElement) {+ // Data present: the dedicated rate element must show a percentage.+ return {+ passed: result.rateIsPercent,+ message: result.rateIsPercent+ ? `Truncation rate displayed in #truncation-rate: "${result.rateText}"`+ : `#truncation-rate present but not a percentage: "${result.rateText}"`+ };}+ // No data (CI no-LLM path): assert we are on the overflow page and the+ // zero-data empty state rendered, rather than skipping or matching help text.return {- passed: true,- message: result.hasRateElement- ? `Truncation rate displayed: "${result.rateText}"`- : `Truncation rate: ${result.percentValue}%`+ passed: result.onPage && result.emptyVisible,+ message: result.onPage && result.emptyVisible+ ? 'No token data: #truncation-rate absent and #empty-no-data shown (expected with no LLM)'+ : `Truncation-rate state unexpected (onPage=${result.onPage}, emptyVisible=${result.emptyVisible})`};},@@ -122,27 +140,56 @@ const ContextOverflowTests = {async contextOverflowChart(page, baseUrl) {await navigateTo(page, `${baseUrl}/metrics/context-overflow`);- await delay(1000); // Wait for charts to render-+ await delay(1000); // Wait for the JS controller to render charts or the empty state++ // 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+ // the API reports requests_with_context_data > 0. With no LLM / fresh DB (CI) there+ // is no token data, so no canvas is created.+ //+ // The old test matched `canvas, svg, .chart, [class*="chart"]` — the substring+ // selector matched unrelated sidebar/header FontAwesome icons (<i class="fas fa-chart-bar">),+ // so it reported "Found 4 charts (types: i, i, i, i)" with zero real charts. We now+ // assert on the overflow-specific chart scaffold: the #context-overflow-section+ // injection point must exist on the correct page, and if a real #context-chart+ // canvas is present (data path) it must be a <canvas>; otherwise the empty state+ // must be shown — never counting icon chrome.const result = await page.evaluate(() => {- const charts = document.querySelectorAll('canvas, svg, .chart, .recharts-wrapper, [class*="chart"]');- const overflowChart = document.querySelector('[class*="overflow-chart"], [id*="overflow-chart"]');-+ const onPage = !!document.getElementById('context-overflow');+ const section = document.getElementById('context-overflow-section');+ const contextChart = document.getElementById('context-chart');+ const isCanvas = contextChart?.tagName?.toLowerCase() === 'canvas';+ const emptyNoData = document.getElementById('empty-no-data');+ const emptyVisible = emptyNoData+ ? getComputedStyle(emptyNoData).display !== 'none'+ : false;return {- hasCharts: charts.length > 0,- chartCount: charts.length,- hasOverflowChart: !!overflowChart,- chartTypes: Array.from(charts).map(c => c.tagName.toLowerCase()).slice(0, 5)+ onPage,+ hasSection: !!section,+ hasContextChart: !!contextChart,+ isCanvas,+ emptyVisible};});- if (!result.hasCharts) {- return { passed: null, skipped: true, message: 'No charts found on context overflow page' };+ if (result.hasContextChart) {+ // Data path: the overflow-specific chart element must be a real canvas.+ return {+ passed: result.onPage && result.hasSection && result.isCanvas,+ message: result.isCanvas+ ? 'Overflow scatter chart present (#context-chart is a <canvas>)'+ : `#context-chart present but not a <canvas>`+ };}+ // No data (CI no-LLM path): the chart injection point exists on the correct+ // page and the empty state rendered. This fails (not skips) if we are on the+ // wrong page or the overflow scaffold did not load.return {- passed: true,- message: `Found ${result.chartCount} charts (types: ${result.chartTypes.join(', ')})`+ passed: result.onPage && result.hasSection && result.emptyVisible,+ message: result.onPage && result.hasSection && result.emptyVisible+ ? 'No token data: #context-overflow-section scaffold present and #empty-no-data shown (no #context-chart canvas without data)'+ : `Overflow chart scaffold unexpected (onPage=${result.onPage}, section=${result.hasSection}, emptyVisible=${result.emptyVisible})`};},