~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 history page (dead-field audit) (#4675)
LearningCircuit54814e12f828
diff --git a/tests/ui_tests/test_history_page_ci.js b/tests/ui_tests/test_history_page_ci.jsindex b18a893840..9a28e83fbc 100644--- a/tests/ui_tests/test_history_page_ci.js+++ b/tests/ui_tests/test_history_page_ci.js@@ -15,23 +15,31 @@ const HistoryPageTests = {async historyPageLoads(page, baseUrl) {await navigateTo(page, `${baseUrl}/history`);+ // Assert the page-specific container AND its header text. The history+ // template renders `<div class="ldr-page" id="history">` with an+ // `<h1>Research History</h1>` server-side (no data / no LLM needed),+ // so a wrong page (login/error) would fail this — unlike a generic+ // `h1`/`.page-title` OR-chain that matches any page's chrome.const result = await page.evaluate(() => {+ const container = document.querySelector('#history.ldr-page');+ const header = container?.querySelector('.ldr-page-header h1');return {- hasContent: !!document.querySelector('.history-container, .ldr-history, #history, .research-history'),- hasHeader: !!document.querySelector('h1, .history-header, .page-title'),- headerText: document.querySelector('h1, .history-header, .page-title')?.textContent?.trim(),- hasTable: !!document.querySelector('table, .history-table, .ldr-history-list'),- hasItems: document.querySelectorAll('.history-item, .research-item, tr[data-id], [data-research-id]').length,- hasEmptyState: !!document.querySelector('.ldr-empty-state, .no-history, .alert-info')+ hasContainer: !!container,+ headerText: header?.textContent?.trim() || '',+ // The history list mount point is part of the page chrome and+ // renders regardless of how many items the API returns.+ hasHistoryList: !!document.querySelector('#history-items.ldr-history-list'),+ itemCount: document.querySelectorAll('.ldr-history-item').length};});- const passed = result.hasContent || result.hasHeader || result.hasTable || result.hasEmptyState;+ const headerMatches = /history/i.test(result.headerText);+ const passed = result.hasContainer && headerMatches && result.hasHistoryList;return {passed,message: passed- ? `History page loaded (header: "${result.headerText}", items: ${result.hasItems})`- : 'History page failed to load'+ ? `History page loaded (container #history, header: "${result.headerText}", items: ${result.itemCount})`+ : `History page failed to load (container=${result.hasContainer}, header="${result.headerText}", list=${result.hasHistoryList})`};},@@ -40,8 +48,19 @@ const HistoryPageTests = {// Wait for JS to render history items from APIawait page.waitForFunction(- () => document.querySelectorAll('.ldr-history-item, .history-item, [data-research-id], table tbody tr').length > 0- || document.querySelector('.ldr-empty-state, .no-results'),+ () => {+ if (document.querySelectorAll('.ldr-history-item, .history-item, [data-research-id], table tbody tr').length > 0) {+ return true;+ }+ // The empty-state node (#history-empty-message.ldr-empty-state) is+ // server-rendered with display:none and only toggled VISIBLE by+ // renderHistoryItems when the list is genuinely empty. Require it+ // to be visible (not merely present) so this wait actually blocks+ // until the client-side render has run, instead of resolving on the+ // first poll against the always-present hidden node.+ const empty = document.querySelector('.ldr-empty-state, .no-results');+ return !!empty && getComputedStyle(empty).display !== 'none';+ },{ timeout: 5000 }).catch(() => {});@@ -63,10 +82,24 @@ const HistoryPageTests = {};}- // Check for list/card-based layout (ldr-history-list with ldr-history-item)- const items = document.querySelectorAll('.ldr-history-item, .history-card, .research-card, [data-research-id]');+ // Check for list/card-based layout (ldr-history-list with ldr-history-item).+ // The app renders each card as `.ldr-history-item` containing+ // `.ldr-history-item-title` (query/title), `.ldr-history-item-date`+ // and `.ldr-history-item-status` sub-elements (see history.js+ // createHistoryItemElement). Assert those exist on the first card so+ // the branch mirrors the table branch instead of being always-true.+ const items = document.querySelectorAll('.ldr-history-item');if (items.length > 0) {- return { hasTable: false, hasCards: true, cardCount: items.length };+ const first = items[0];+ return {+ hasTable: false,+ hasCards: true,+ cardCount: items.length,+ cardHasTitle: !!first.querySelector('.ldr-history-item-title'),+ cardHasDate: !!first.querySelector('.ldr-history-item-date'),+ cardHasStatus: !!first.querySelector('.ldr-history-item-status'),+ titleText: first.querySelector('.ldr-history-item-title')?.textContent?.trim() || ''+ };}return { hasTable: false, hasCards: false };@@ -80,7 +113,15 @@ const HistoryPageTests = {}if (result.hasCards) {- return { passed: true, message: `History uses card layout (${result.cardCount} items)` };+ // A real card must expose its query/title plus a date or status —+ // mirrors the table branch's hasQuery/hasDate requirement.+ const passed = result.cardHasTitle && (result.cardHasDate || result.cardHasStatus);+ return {+ passed,+ message: passed+ ? `History card layout (${result.cardCount} items; first title="${result.titleText}", date=${result.cardHasDate}, status=${result.cardHasStatus})`+ : `History card missing expected fields (title=${result.cardHasTitle}, date=${result.cardHasDate}, status=${result.cardHasStatus})`+ };}return { passed: null, skipped: true, message: 'No history table or cards found' };@@ -91,28 +132,46 @@ const HistoryPageTests = {// Wait for JS to render history items from APIawait page.waitForFunction(- () => document.querySelectorAll('.ldr-history-item, .history-item, [data-research-id]').length > 0- || document.querySelector('.ldr-empty-state'),+ () => {+ if (document.querySelectorAll('.ldr-history-item, .history-item, [data-research-id]').length > 0) {+ return true;+ }+ // Require the empty-state to be VISIBLE, not just present: it is+ // server-rendered hidden and only shown once the client render+ // runs (see historyTableStructure). Avoids resolving before the+ // items have rendered.+ const empty = document.querySelector('.ldr-empty-state');+ return !!empty && getComputedStyle(empty).display !== 'none';+ },{ timeout: 5000 }).catch(() => {});const result = await page.evaluate(() => {- const items = document.querySelectorAll('.ldr-history-item, .history-item, .research-item, tr[data-id], [data-research-id]');+ const items = Array.from(document.querySelectorAll('.ldr-history-item'));if (items.length === 0) return { hasItems: false };- const firstItem = items[0];- const buttons = Array.from(firstItem.querySelectorAll('button, a.btn, .btn, a[href]'));- const buttonTexts = buttons.map(b => b.textContent?.toLowerCase() || b.title?.toLowerCase() || '');+ // Page-specific action contract (history.js createHistoryItemElement):+ // - every item renders a delete control (.ldr-delete-item-btn),+ // unconditionally on the /history default load;+ // - the View/Open-Chat control (.ldr-view-btn) renders ONLY on+ // completed or chat items — both of which carry the+ // `ldr-status-completed` status class (isCompleted <=> status+ // 'completed'; chat groups hard-code that class).+ // So assert: all items expose delete, AND every completed item+ // exposes a View control. This stays a real, page-specific assertion+ // without false-failing when the DB happens to hold only in-progress+ // researches (which legitimately render no View button).+ const allHaveDelete = items.every(it => it.querySelector('.ldr-delete-item-btn'));+ const completed = items.filter(it =>+ it.querySelector('.ldr-history-item-status.ldr-status-completed'));+ const completedHaveView = completed.every(it => it.querySelector('.ldr-view-btn'));return {hasItems: true,itemCount: items.length,- hasViewButton: buttonTexts.some(t => t.includes('view') || t.includes('open') || t.includes('results')) ||- !!firstItem.querySelector('a[href*="/results/"]'),- hasDeleteButton: buttonTexts.some(t => t.includes('delete') || t.includes('remove')) ||- !!firstItem.querySelector('.btn-danger, .delete-btn'),- hasExportButton: buttonTexts.some(t => t.includes('export') || t.includes('download')),- actionCount: buttons.length+ completedCount: completed.length,+ allHaveDelete,+ completedHaveView};});@@ -120,12 +179,12 @@ const HistoryPageTests = {return { passed: null, skipped: true, message: 'No history items to test actions' };}- const hasActions = result.hasViewButton || result.hasDeleteButton || result.actionCount > 0;+ const passed = result.allHaveDelete && result.completedHaveView;return {- passed: hasActions,- message: hasActions- ? `History item actions: view=${result.hasViewButton}, delete=${result.hasDeleteButton}, export=${result.hasExportButton} (${result.actionCount} buttons)`- : 'No action buttons found on history items'+ passed,+ message: passed+ ? `History item actions present: ${result.itemCount} items all expose delete; ${result.completedCount} completed item(s) all expose View`+ : `History item actions missing: allHaveDelete=${result.allHaveDelete}, completedHaveView=${result.completedHaveView} (items=${result.itemCount}, completed=${result.completedCount})`};},