~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
fix: correct DOM selectors and add assertions in UI page tests (#2188)
LearningCircuit03c60300814e
diff --git a/tests/ui_tests/test_pages_browser.js b/tests/ui_tests/test_pages_browser.jsindex 2c642b6faf..df461e920b 100644--- a/tests/ui_tests/test_pages_browser.js+++ b/tests/ui_tests/test_pages_browser.js@@ -6,6 +6,8 @@const puppeteer = require('puppeteer');const AuthHelper = require('./auth_helper');const { getPuppeteerLaunchOptions } = require('./puppeteer_config');+const fs = require('fs');+const path = require('path');const DEFAULT_TIMEOUT = 10000; // Increased for pages with many network requestsconst DEFAULT_WAIT = 3000; // More time for JS to execute@@ -41,12 +43,22 @@ class BrowserTester {const url = request.url();const failure = request.failure();const error = failure ? failure.errorText : 'Unknown error';- // Only log 404s for important resources, ignore favicon etc.+ // Only log for important resources, ignore favicon etc.if (!url.includes('favicon') && !url.includes('.ico')) {console.log(`🔴 [REQUEST FAILED] ${url} - ${error}`);}});+ // Listen to 404 responses to identify missing resources+ this.page.on('response', response => {+ if (response.status() === 404) {+ const url = response.url();+ if (!url.includes('favicon') && !url.includes('.ico')) {+ console.log(` [404 RESPONSE] ${url}`);+ }+ }+ });+// Ensure authentication before running testsconsole.log('\n🔐 Ensuring authentication...');try {@@ -69,10 +81,17 @@ class BrowserTester {console.log(`\n📄 Testing ${testName}: ${url}`);try {- await this.page.goto(url, {- waitUntil: 'domcontentloaded', // Don't wait for all network requests- timeout: DEFAULT_TIMEOUT- });+ // Skip navigation if already on the target page (avoids ERR_ABORTED from double-navigation)+ const currentPath = new URL(this.page.url()).pathname;+ const targetPath = new URL(url).pathname;+ if (currentPath !== targetPath) {+ await this.page.goto(url, {+ waitUntil: 'domcontentloaded', // Don't wait for all network requests+ timeout: DEFAULT_TIMEOUT+ });+ } else {+ console.log(` Already on ${testName}, skipping navigation`);+ }console.log(`✅ ${testName} loaded successfully`);@@ -94,9 +113,17 @@ class BrowserTester {console.log(` Has body: ${basicChecks.hasBody}`);console.log(` Body visible: ${basicChecks.bodyVisible}`);- // Run custom tests if provided+ // Run custom tests if provided and collect failures+ const failures = [];if (customTests) {- await customTests(this.page);+ const customFailures = await customTests(this.page);+ if (Array.isArray(customFailures)) {+ failures.push(...customFailures);+ }+ }++ if (failures.length > 0) {+ return { success: false, error: failures.join('; ') };}return { success: true, checks: basicChecks };@@ -109,8 +136,11 @@ class BrowserTester {}// Custom test functions for specific pages+// Each returns an array of failure strings (empty = all passed)+const metricsPageTests = async (page) => {console.log('🧪 Running metrics-specific tests...');+ const failures = [];// Check if metrics elements are presentconst metricsChecks = await page.evaluate(() => {@@ -141,27 +171,40 @@ const metricsPageTests = async (page) => {console.log(` Total tokens: ${metricsChecks.tokenValue}`);console.log(` Total researches: ${metricsChecks.researchValue}`);+ // Either content or error element must exist (error state is valid in CI with no data)+ if (!metricsChecks.hasContentElement && !metricsChecks.hasErrorElement) {+ failures.push('Missing both #metrics-content and #error elements');+ }+ if (!metricsChecks.hasTotalTokens) failures.push('Missing #total-tokens element');+ if (!metricsChecks.hasTotalResearches) failures.push('Missing #total-researches element');+// Take screenshot for debuggingtry {- await page.screenshot({ path: 'tests/ui_tests/screenshots/metrics-test.png' });- console.log('📸 Screenshot saved: tests/ui_tests/screenshots/metrics-test.png');+ const screenshotPath = path.join(__dirname, 'screenshots', 'metrics-test.png');+ await page.screenshot({ path: screenshotPath });+ console.log(`📸 Screenshot saved: ${screenshotPath}`);} catch (err) {console.log('⚠️ Could not save screenshot:', err.message);}++ return failures;};const researchPageTests = async (page) => {console.log('🧪 Running research page tests...');+ const failures = [];const researchChecks = await page.evaluate(() => {const queryInput = document.getElementById('query');const submitButton = document.querySelector('button[type="submit"]');- const modeSelect = document.querySelector('select[name="mode"]');+ const modeSelection = document.querySelector('.ldr-mode-selection');+ const modeRadios = document.querySelectorAll('input[name="research_mode"]');return {hasQueryInput: !!queryInput,hasSubmitButton: !!submitButton,- hasModeSelect: !!modeSelect,+ hasModeSelection: !!modeSelection,+ modeRadioCount: modeRadios.length,queryInputEnabled: queryInput ? !queryInput.disabled : false,submitButtonEnabled: submitButton ? !submitButton.disabled : false};@@ -170,27 +213,34 @@ const researchPageTests = async (page) => {console.log('🔍 Research page checks:');console.log(` Has query input: ${researchChecks.hasQueryInput}`);console.log(` Has submit button: ${researchChecks.hasSubmitButton}`);- console.log(` Has mode select: ${researchChecks.hasModeSelect}`);+ console.log(` Has mode selection: ${researchChecks.hasModeSelection}`);+ console.log(` Mode radio count: ${researchChecks.modeRadioCount}`);console.log(` Query input enabled: ${researchChecks.queryInputEnabled}`);console.log(` Submit button enabled: ${researchChecks.submitButtonEnabled}`);+ if (!researchChecks.hasQueryInput) failures.push('Missing query input (#query)');+ if (!researchChecks.hasSubmitButton) failures.push('Missing submit button');+ if (!researchChecks.hasModeSelection) failures.push('Missing mode selection (.ldr-mode-selection)');+// If --search flag is provided, run a test searchif (process.argv.includes('--search') && researchChecks.hasQueryInput && researchChecks.hasSubmitButton) {console.log('\n🔎 Running test search...');await page.type('#query', 'Test search query for UI testing');console.log('✅ Entered test query');}++ return failures;};const historyPageTests = async (page) => {console.log('🧪 Running history page tests...');+ const failures = [];const historyChecks = await page.evaluate(() => {const historyContainer = document.getElementById('history-container') ||document.querySelector('.ldr-history-list') ||document.querySelector('[data-testid="history"]');- const searchInput = document.querySelector('input[type="search"]') ||- document.querySelector('input[placeholder*="search"]');+ const searchInput = document.getElementById('history-search');return {hasHistoryContainer: !!historyContainer,@@ -203,10 +253,16 @@ const historyPageTests = async (page) => {console.log(` Has history container: ${historyChecks.hasHistoryContainer}`);console.log(` Has search input: ${historyChecks.hasSearchInput}`);console.log(` History container visible: ${historyChecks.historyContainerVisible}`);++ if (!historyChecks.hasHistoryContainer) failures.push('Missing history container');+ if (!historyChecks.hasSearchInput) failures.push('Missing search input (#history-search)');++ return failures;};const settingsPageTests = async (page) => {console.log('🧪 Running settings page tests...');+ const failures = [];const settingsChecks = await page.evaluate(() => {const forms = document.querySelectorAll('form');@@ -231,6 +287,11 @@ const settingsPageTests = async (page) => {console.log(` Has forms: ${settingsChecks.hasForm} (${settingsChecks.formCount} forms)`);console.log(` Has inputs: ${settingsChecks.hasInputs} (${settingsChecks.inputCount} inputs)`);console.log(` Has save buttons: ${settingsChecks.hasSaveButtons}`);++ if (!settingsChecks.hasInputs) failures.push('Missing input elements');+ if (!settingsChecks.hasSaveButtons) failures.push('Missing save buttons');++ return failures;};// Main test runner@@ -245,9 +306,8 @@ async function runAllTests() {}// Ensure screenshots directory exists- await tester.page.evaluate(() => {- // This runs in browser context, can't create directories- });+ const screenshotsDir = path.join(__dirname, 'screenshots');+ fs.mkdirSync(screenshotsDir, { recursive: true });const results = [];