~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
refactor(test): extract shared mobile test utilities and remove redundant tests
LearningCircuit8265f8b0467a
diff --git a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.jsindex e86c15044f..1bfc30ed1f 100644--- a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js@@ -21,69 +21,13 @@*/import { test, expect } from '@playwright/test';--// Test configuration-const MIN_TOUCH_TARGET = 44;-const MOBILE_NAV_SELECTOR = '.ldr-mobile-bottom-nav';-const SIDEBAR_SELECTOR = '.ldr-sidebar';-const SHEET_SELECTOR = '.ldr-mobile-sheet, [class*="sheet"]:not([class*="stylesheet"]), [class*="modal"]:not(.ldr-mode-selection), [class*="drawer"], [role="dialog"]';--/**- * Ensure any open sheets/modals are closed before taking screenshots.- * This prevents the "More" menu from overlapping page content in baselines.- *- * The sheet menu is a fixed-position element that Playwright captures in full-page screenshots- * even when hidden with CSS transforms. We must completely remove it from the DOM.- */-async function ensureSheetsClosed(page) {- // Remove sheet elements and verify they're gone- const removed = await page.evaluate(() => {- const results = { found: 0, removed: 0 };-- // Find and remove all sheet-related elements- const selectors = [- '.ldr-mobile-sheet-menu',- '.ldr-mobile-sheet-overlay',- '.ldr-mobile-sheet'- ];-- selectors.forEach(selector => {- const elements = document.querySelectorAll(selector);- results.found += elements.length;- elements.forEach(el => {- el.parentNode.removeChild(el);- results.removed++;- });- });-- // Clear MobileNavigation references- if (window.mobileNav && window.mobileNav.elements) {- window.mobileNav.elements.sheet = null;- window.mobileNav.elements.overlay = null;- }-- return results;- });-- // Force reflow- await page.evaluate(() => {- document.body.offsetHeight;- return null;- });-- // Small wait for any async operations- await page.waitForTimeout(50);-- // Verify removal- const remaining = await page.evaluate(() => {- const sheet = document.querySelector('.ldr-mobile-sheet-menu');- return sheet ? sheet.outerHTML.substring(0, 200) : null;- });-- if (remaining) {- console.error('Sheet still exists after removal:', remaining);- }-}+const {+ ensureSheetsClosed,+ MIN_TOUCH_TARGET,+ MOBILE_NAV_SELECTOR,+ SIDEBAR_SELECTOR,+ SHEET_SELECTOR+} = require('./helpers/mobile-utils');// Pages to testconst PAGES = [diff --git a/tests/ui_tests/playwright/tests/helpers/mobile-utils.js b/tests/ui_tests/playwright/tests/helpers/mobile-utils.jsnew file mode 100644index 0000000000..63af6073b7--- /dev/null+++ b/tests/ui_tests/playwright/tests/helpers/mobile-utils.js@@ -0,0 +1,70 @@+/**+ * Shared Mobile Test Utilities for Playwright+ *+ * Common constants and helper functions used across mobile test files.+ * Uses CommonJS to match existing auth.js pattern.+ */++// Constants+const MIN_TOUCH_TARGET = 44;+const MIN_ELEMENT_SPACING = 8;+const MOBILE_NAV_HEIGHT = 56;+const MOBILE_NAV_SELECTOR = '.ldr-mobile-bottom-nav';+const SIDEBAR_SELECTOR = '.ldr-sidebar';+const SHEET_SELECTOR = '.ldr-mobile-sheet, [class*="sheet"]:not([class*="stylesheet"]), [class*="modal"]:not(.ldr-mode-selection), [class*="drawer"], [role="dialog"]';++/**+ * Remove sheet elements from DOM to prevent bleeding in screenshots.+ *+ * The sheet menu is a fixed-position element that Playwright captures in full-page screenshots+ * even when hidden with CSS transforms. We must completely remove it from the DOM.+ *+ * @param {import('@playwright/test').Page} page - Playwright page object+ */+async function ensureSheetsClosed(page) {+ // Remove sheet elements from DOM+ await page.evaluate(() => {+ const selectors = [+ '.ldr-mobile-sheet-menu',+ '.ldr-mobile-sheet-overlay',+ '.ldr-mobile-sheet'+ ];++ selectors.forEach(selector => {+ document.querySelectorAll(selector).forEach(el => el.remove());+ });++ // Clear MobileNavigation references+ if (window.mobileNav && window.mobileNav.elements) {+ window.mobileNav.elements.sheet = null;+ window.mobileNav.elements.overlay = null;+ }+ });++ // Force reflow+ await page.evaluate(() => document.body.offsetHeight);++ // Small wait for any async operations+ await page.waitForTimeout(50);+}++/**+ * Check if running on tablet device.+ *+ * @param {import('@playwright/test').TestInfo} testInfo - Playwright test info+ * @returns {boolean} True if running on iPad or other tablet device+ */+function isTablet(testInfo) {+ return testInfo.project.name.includes('iPad');+}++module.exports = {+ MIN_TOUCH_TARGET,+ MIN_ELEMENT_SPACING,+ MOBILE_NAV_HEIGHT,+ MOBILE_NAV_SELECTOR,+ SIDEBAR_SELECTOR,+ SHEET_SELECTOR,+ ensureSheetsClosed,+ isTablet,+};diff --git a/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.js b/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.jsindex 961130c932..c8b0d51257 100644--- a/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.js@@ -12,10 +12,7 @@*/import { test, expect } from '@playwright/test';--// Test configuration-const MIN_TOUCH_TARGET = 44;-const MOBILE_NAV_SELECTOR = '.ldr-mobile-bottom-nav';+const { ensureSheetsClosed, MIN_TOUCH_TARGET, MOBILE_NAV_SELECTOR } = require('./helpers/mobile-utils');// Metrics subpages configurationconst METRICS_SUBPAGES = [@@ -25,35 +22,6 @@ const METRICS_SUBPAGES = [{ path: '/metrics/links', name: 'Link Analytics', header: 'Link Analytics Dashboard' },];-/**- * Helper to ensure sheets are closed and removed from DOM.- * Note: For viewport-only screenshots, this is less critical but still good practice.- */-async function ensureSheetsClosed(page) {- // Remove sheet elements from DOM- await page.evaluate(() => {- const selectors = [- '.ldr-mobile-sheet-menu',- '.ldr-mobile-sheet-overlay',- '.ldr-mobile-sheet'- ];-- selectors.forEach(selector => {- document.querySelectorAll(selector).forEach(el => el.remove());- });-- // Clear MobileNavigation references- if (window.mobileNav && window.mobileNav.elements) {- window.mobileNav.elements.sheet = null;- window.mobileNav.elements.overlay = null;- }- });-- // Force DOM update- await page.evaluate(() => document.body.offsetHeight);- await page.waitForTimeout(50);-}-// ============================================// COMMON TESTS FOR ALL METRICS SUBPAGES// ============================================diff --git a/tests/ui_tests/playwright/tests/mobile-components.spec.js b/tests/ui_tests/playwright/tests/mobile-components.spec.jsindex c4a005c3fd..ba8713ef2c 100644--- a/tests/ui_tests/playwright/tests/mobile-components.spec.js+++ b/tests/ui_tests/playwright/tests/mobile-components.spec.js@@ -13,21 +13,7 @@*/import { test, expect } from '@playwright/test';--// Helper to ensure sheets are closed-async function ensureSheetsClosed(page) {- const sheetSelectors = '.ldr-mobile-sheet, [class*="sheet"]:not([class*="stylesheet"]), [class*="drawer"]';- const sheets = page.locator(sheetSelectors);- const count = await sheets.count();-- for (let i = 0; i < count; i++) {- if (await sheets.nth(i).isVisible()) {- await page.click('body', { position: { x: 10, y: 10 }, force: true });- await page.waitForTimeout(300);- break;- }- }-}+const { ensureSheetsClosed } = require('./helpers/mobile-utils');// ============================================// MOBILE NAVIGATION COMPONENT TESTS@@ -435,6 +421,7 @@ test.describe('Interaction States', () => {return;}+ await ensureSheetsClosed(page);await expect(panel).toHaveScreenshot('advanced-options-expanded.png', {maxDiffPixelRatio: 0.02,});@@ -641,6 +628,7 @@ test.describe('Metrics Page Sections', () => {// Find the System Overview header sectionconst overviewSection = page.locator('.ldr-metrics-grid').first();if (await overviewSection.isVisible()) {+ await ensureSheetsClosed(page);await expect(overviewSection).toHaveScreenshot('metrics-system-overview.png', {maxDiffPixelRatio: 0.02,});@@ -661,6 +649,7 @@ test.describe('Metrics Page Sections', () => {// Find the token chart containerconst chartContainer = page.locator('#time-series-chart').locator('..');if (await chartContainer.isVisible()) {+ await ensureSheetsClosed(page);await expect(chartContainer).toHaveScreenshot('metrics-token-chart-section.png', {maxDiffPixelRatio: 0.05, // Charts may have some dynamic variance});@@ -681,6 +670,7 @@ test.describe('Metrics Page Sections', () => {// Find the search activity chartconst chartContainer = page.locator('#search-activity-chart').locator('..');if (await chartContainer.isVisible()) {+ await ensureSheetsClosed(page);await expect(chartContainer).toHaveScreenshot('metrics-search-activity-section.png', {maxDiffPixelRatio: 0.05,});@@ -701,6 +691,7 @@ test.describe('Metrics Page Sections', () => {// Find the model usage listconst modelUsageList = page.locator('#model-usage-list');if (await modelUsageList.isVisible()) {+ await ensureSheetsClosed(page);await expect(modelUsageList).toHaveScreenshot('metrics-model-usage-section.png', {maxDiffPixelRatio: 0.02,});@@ -721,6 +712,7 @@ test.describe('Metrics Page Sections', () => {// Find research analytics sectionconst analyticsSection = page.locator('#mode-breakdown').locator('..').locator('..');if (await analyticsSection.isVisible()) {+ await ensureSheetsClosed(page);await expect(analyticsSection).toHaveScreenshot('metrics-research-analytics-section.png', {maxDiffPixelRatio: 0.02,});@@ -745,6 +737,7 @@ test.describe('Metrics Page Sections', () => {await page.waitForTimeout(300);if (await rateLimitSection.isVisible()) {+ await ensureSheetsClosed(page);await expect(rateLimitSection).toHaveScreenshot('metrics-rate-limiting-section.png', {maxDiffPixelRatio: 0.02,});diff --git a/tests/ui_tests/playwright/tests/research-page.spec.js b/tests/ui_tests/playwright/tests/research-page.spec.jsindex 8b4c4d305b..2121c3e239 100644--- a/tests/ui_tests/playwright/tests/research-page.spec.js+++ b/tests/ui_tests/playwright/tests/research-page.spec.js@@ -1,70 +1,27 @@/*** Research Page Mobile Layout Tests*- * These tests specifically target the "mashed together" issues on the- * Research page (home page) on mobile devices.+ * Page-specific tests for the Research page (home page) on mobile devices.+ * These tests focus on element spacing, mobile nav clearance, and+ * advanced options interactions that are unique to this page.+ *+ * Note: Generic tests for visual regression, touch targets, and scrollability+ * are covered by all-pages-mobile.spec.js with better device coverage.** Key areas tested:- * 1. Visual regression - screenshot comparison against baselines- * 2. Element spacing - adequate gaps between form elements- * 3. Touch targets - minimum 44px for iOS accessibility- * 4. Mobile nav clearance - content not hidden behind bottom nav- * 5. Scroll behavior - all content reachable by scrolling+ * 1. Element spacing - adequate gaps between form elements+ * 2. Mobile nav clearance - content not hidden behind bottom nav+ * 3. Advanced options - panel expand/collapse interactions** Note: Authentication is handled by auth.setup.js via storageState*/import { test, expect } from '@playwright/test';+const { MIN_TOUCH_TARGET, MIN_ELEMENT_SPACING, MOBILE_NAV_HEIGHT } = require('./helpers/mobile-utils');-// Test configuration-const MOBILE_NAV_HEIGHT = 56;-const MIN_ELEMENT_SPACING = 8;-const MIN_TOUCH_TARGET = 44;+// Additional constants specific to this pageconst MIN_NAV_CLEARANCE = 16;-// ============================================-// VISUAL REGRESSION TESTS-// ============================================--test.describe('Research Page - Visual Regression', () => {- test.beforeEach(async ({ page }) => {- await page.goto('/');- await page.waitForLoadState('networkidle');- });-- test('full page screenshot matches baseline', async ({ page }) => {- // Wait for mobile nav to initialize (if present)- const mobileNav = page.locator('.ldr-mobile-bottom-nav');- await mobileNav.or(page.locator('body')).first().waitFor({ state: 'attached' });-- // Take full-page screenshot and compare to baseline- await expect(page).toHaveScreenshot('research-page-full.png', {- fullPage: true,- // Allow 1% pixel difference for anti-aliasing variations- maxDiffPixelRatio: 0.01,- });- });-- test('bottom section screenshot matches baseline', async ({ page }) => {- // Scroll to bottom to capture the "mashed together" area- await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- // Allow scroll animation to complete- await page.waitForLoadState('domcontentloaded');-- await expect(page).toHaveScreenshot('research-page-bottom.png', {- maxDiffPixelRatio: 0.01,- });- });-- test('form actions area screenshot', async ({ page }) => {- // Capture just the form actions area- const formActions = page.locator('.ldr-form-actions');- if (await formActions.count() > 0) {- await expect(formActions).toHaveScreenshot('form-actions.png');- }- });-});-// ============================================// ELEMENT SPACING TESTS// ============================================@@ -150,83 +107,6 @@ test.describe('Research Page - Element Spacing', () => {});});-// ============================================-// TOUCH TARGET TESTS-// ============================================--test.describe('Research Page - Touch Targets', () => {- test.beforeEach(async ({ page }) => {- await page.goto('/');- await page.waitForLoadState('networkidle');- });-- test('Start Research button meets 44px minimum', async ({ page }) => {- const button = page.locator('#start-research-btn');- const box = await button.boundingBox();-- expect(box, 'Button should exist').toBeTruthy();- expect(box.height, 'Button height >= 44px').toBeGreaterThanOrEqual(MIN_TOUCH_TARGET);- expect(box.width, 'Button width >= 44px').toBeGreaterThanOrEqual(MIN_TOUCH_TARGET);- });-- test('notification toggle meets 44px minimum', async ({ page }, testInfo) => {- // Skip on tablets (iPad) - they have different touch target requirements- const isTablet = testInfo.project.name.includes('iPad');- if (isTablet) {- test.skip();- return;- }-- const toggle = page.locator('#notification-toggle');- const box = await toggle.boundingBox();-- // For checkboxes, we check the label's touch area- if (box && (box.height < MIN_TOUCH_TARGET || box.width < MIN_TOUCH_TARGET)) {- // Check if parent label provides adequate touch area- const label = page.locator('label[for="notification-toggle"]');- const labelBox = await label.boundingBox();-- expect(labelBox, 'Label should provide touch area').toBeTruthy();- expect(labelBox.height, 'Label height >= 44px').toBeGreaterThanOrEqual(MIN_TOUCH_TARGET);- }- });-- test('all interactive elements have adequate touch targets', async ({ page }, testInfo) => {- // Skip on tablets (iPad) - they have different touch target requirements- const isTablet = testInfo.project.name.includes('iPad');- if (isTablet) {- test.skip();- return;- }- const smallTargets = await page.evaluate((MIN_SIZE) => {- const elements = document.querySelectorAll('button, a, input, select, textarea, [role="button"]');- const issues = [];-- elements.forEach(el => {- const rect = el.getBoundingClientRect();- const style = window.getComputedStyle(el);-- // Skip hidden elements- if (style.display === 'none' || style.visibility === 'hidden') return;- if (rect.width === 0 || rect.height === 0) return;-- if (rect.width < MIN_SIZE || rect.height < MIN_SIZE) {- issues.push({- tag: el.tagName.toLowerCase(),- size: `${Math.round(rect.width)}x${Math.round(rect.height)}`,- text: (el.textContent || '').slice(0, 30),- });- }- });-- return issues;- }, MIN_TOUCH_TARGET);-- // Allow some small elements but flag if too many- expect(smallTargets.length, `Small touch targets: ${JSON.stringify(smallTargets)}`).toBeLessThan(5);- });-});-// ============================================// MOBILE NAVIGATION CLEARANCE TESTS// ============================================@@ -327,51 +207,6 @@ test.describe('Research Page - Mobile Nav Clearance', () => {});});-// ============================================-// SCROLL BEHAVIOR TESTS-// ============================================--test.describe('Research Page - Scrollability', () => {- test.beforeEach(async ({ page }) => {- await page.goto('/');- await page.waitForLoadState('networkidle');- });-- test('can scroll to reveal all content', async ({ page }) => {- // Scroll to bottom- await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(500); // Wait for scroll animation-- // Check that help panel is visible (if it exists)- const helpPanel = page.locator('.ldr-help-panel');- if (await helpPanel.count() > 0) {- await expect(helpPanel).toBeInViewport({ timeout: 5000 });- }-- // Check that Start Research button is still accessible (scroll back up)- await page.evaluate(() => {- window.scrollTo({ top: 0, left: 0, behavior: 'instant' });- document.documentElement.scrollTop = 0;- document.body.scrollTop = 0;- });- await page.waitForTimeout(500); // Wait for scroll to complete-- const startButton = page.locator('#start-research-btn');- // First scroll the button into view if needed- await startButton.scrollIntoViewIfNeeded();- await page.waitForTimeout(200);- await expect(startButton).toBeInViewport({ timeout: 5000 });- });-- test('no horizontal scroll on mobile', async ({ page }) => {- const hasHorizontalScroll = await page.evaluate(() => {- return document.documentElement.scrollWidth > window.innerWidth;- });-- expect(hasHorizontalScroll, 'Should have no horizontal scroll').toBe(false);- });-});-// ============================================// ADVANCED OPTIONS PANEL TESTS// ============================================