~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(mobile): add component-level screenshot tests and sheet closing helper
LearningCircuit89f7ce38b066
diff --git a/.pre-commit-hooks/file-whitelist-check.sh b/.pre-commit-hooks/file-whitelist-check.shindex e01f0edb73..8a2ab61cc8 100755--- a/.pre-commit-hooks/file-whitelist-check.sh+++ b/.pre-commit-hooks/file-whitelist-check.sh@@ -52,6 +52,7 @@ ALLOWED_PATTERNS=("src/local_deep_research/web/static/sounds/.*\.mp3$""src/local_deep_research/web/static/favicon\.png$""unraid-templates/.*\.xml$"+ "tests/ui_tests/playwright/tests/.*-snapshots/.*\.png$")WHITELIST_VIOLATIONS=()diff --git a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.jsindex db356a6deb..db0c1d88f8 100644--- a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js@@ -26,6 +26,38 @@ import { test, expect } from '@playwright/test';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.+ */+async function ensureSheetsClosed(page) {+ // Check if any sheet-like element is visible+ const sheetElements = page.locator(SHEET_SELECTOR);+ const count = await sheetElements.count();++ for (let i = 0; i < count; i++) {+ const sheet = sheetElements.nth(i);+ if (await sheet.isVisible()) {+ // Click outside to close (top-left corner of viewport)+ await page.click('body', { position: { x: 10, y: 10 }, force: true });+ await page.waitForTimeout(300);+ break;+ }+ }++ // Also check for More menu specifically and close it+ const moreMenuBtn = page.locator('[data-nav="more"], .ldr-nav-more-btn');+ if (await moreMenuBtn.count() > 0) {+ // If the More menu sheet is visible, click outside to close+ const moreSheet = page.locator('.ldr-mobile-sheet');+ if (await moreSheet.isVisible()) {+ await page.click('body', { position: { x: 10, y: 10 }, force: true });+ await page.waitForTimeout(300);+ }+ }+}// Pages to testconst PAGES = [@@ -338,13 +370,29 @@ test.describe('All Pages - Basic Load Tests', () => {test.describe('All Pages - Visual Regression', () => {for (const pageInfo of PAGES) {- test(`${pageInfo.name} screenshot`, async ({ page }) => {+ test(`${pageInfo.name} screenshot`, async ({ page, isMobile }) => {await page.goto(pageInfo.path);await page.waitForLoadState('networkidle');+ // Wait for page-specific content to load+ if (pageInfo.path === '/settings/') {+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});+ await page.waitForSelector('.ldr-settings-form, #settings-form', { timeout: 10000 }).catch(() => {});+ }+// Wait for any animations to completeawait page.waitForTimeout(500);+ // CRITICAL: Ensure any open sheets/modals are closed before screenshot+ // This prevents the "More" menu from overlapping page content in baselines+ if (isMobile) {+ await ensureSheetsClosed(page);+ }++ // Scroll to top to ensure consistent screenshot starting position+ await page.evaluate(() => window.scrollTo(0, 0));+ await page.waitForTimeout(200);+// Generate a filename-safe nameconst safeName = pageInfo.name.toLowerCase().replace(/[^a-z0-9]/g, '-');diff --git a/tests/ui_tests/playwright/tests/mobile-components.spec.js b/tests/ui_tests/playwright/tests/mobile-components.spec.jsnew file mode 100644index 0000000000..151a79ceca--- /dev/null+++ b/tests/ui_tests/playwright/tests/mobile-components.spec.js@@ -0,0 +1,769 @@+/**+ * Mobile Component Screenshot Tests+ *+ * Component-level visual regression tests for isolated UI elements.+ * These capture specific components in various states to detect+ * regressions more precisely than full-page screenshots.+ *+ * Components tested:+ * - Mobile navigation (closed and open states)+ * - Form elements (textarea, buttons, inputs)+ * - Cards and containers+ * - Interactive states (expanded/collapsed)+ */++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;+ }+ }+}++// ============================================+// MOBILE NAVIGATION COMPONENT TESTS+// ============================================++test.describe('Mobile Navigation Components', () => {+ test('Mobile nav - closed state', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/');+ await page.waitForLoadState('networkidle');+ await ensureSheetsClosed(page);++ const nav = page.locator('.ldr-mobile-bottom-nav');+ await expect(nav).toBeVisible();+ await expect(nav).toHaveScreenshot('mobile-nav-closed.png', {+ maxDiffPixelRatio: 0.02,+ });+ });++ test('Mobile nav - More menu open', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/');+ await page.waitForLoadState('networkidle');+ await ensureSheetsClosed(page);++ // Find and click the More button+ const moreBtn = page.locator('[data-nav="more"], .ldr-nav-more-btn, .ldr-mobile-bottom-nav button:has-text("More")');+ if (await moreBtn.count() > 0) {+ await moreBtn.first().click();+ await page.waitForTimeout(300);++ // Take screenshot of the sheet+ const sheet = page.locator('.ldr-mobile-sheet');+ if (await sheet.isVisible()) {+ await expect(sheet).toHaveScreenshot('mobile-nav-more-open.png', {+ maxDiffPixelRatio: 0.02,+ });+ } else {+ // If no sheet, skip this test+ test.skip();+ }+ } else {+ test.skip();+ }+ });++ test('Mobile nav items have correct sizing', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const navItems = page.locator('.ldr-mobile-bottom-nav a, .ldr-mobile-bottom-nav button');+ const count = await navItems.count();++ expect(count).toBeGreaterThan(0);++ for (let i = 0; i < count; i++) {+ const item = navItems.nth(i);+ const box = await item.boundingBox();+ expect(box).toBeTruthy();+ expect(box.width).toBeGreaterThanOrEqual(44);+ expect(box.height).toBeGreaterThanOrEqual(44);+ }+ });+});++// ============================================+// FORM COMPONENT TESTS+// ============================================++test.describe('Form Components', () => {+ test('Research textarea component', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const textarea = page.locator('#query, textarea[name="query"], .ldr-research-textarea');+ if (await textarea.count() > 0) {+ await expect(textarea.first()).toHaveScreenshot('research-textarea.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Start Research button component', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const startBtn = page.locator('#start-research-btn, button:has-text("Start Research")');+ if (await startBtn.count() > 0) {+ await expect(startBtn.first()).toHaveScreenshot('start-research-button.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Mode selection component', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const modeSelection = page.locator('.ldr-mode-selection');+ if (await modeSelection.count() > 0) {+ await expect(modeSelection.first()).toHaveScreenshot('mode-selection.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Settings checkbox with label', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/settings/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);++ // Find a settings item with a checkbox+ const settingItem = page.locator('.ldr-settings-item').filter({+ has: page.locator('input[type="checkbox"]'),+ }).first();++ if (await settingItem.isVisible()) {+ await expect(settingItem).toHaveScreenshot('settings-checkbox-item.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Settings dropdown/select', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/settings/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);++ // Find a settings item with a select dropdown+ const settingItem = page.locator('.ldr-settings-item').filter({+ has: page.locator('select'),+ }).first();++ if (await settingItem.isVisible()) {+ await expect(settingItem).toHaveScreenshot('settings-dropdown-item.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Settings text input', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/settings/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);++ // Find a settings item with a text input+ const settingItem = page.locator('.ldr-settings-item').filter({+ has: page.locator('input[type="text"], input[type="number"]'),+ }).first();++ if (await settingItem.isVisible()) {+ await expect(settingItem).toHaveScreenshot('settings-text-input-item.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });+});++// ============================================+// CARD COMPONENT TESTS+// ============================================++test.describe('Card Components', () => {+ test('History card (empty state)', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/history/');+ await page.waitForLoadState('networkidle');++ // Look for empty state message or card container+ const emptyState = page.locator('.ldr-empty-state, [class*="empty"], :text("No research history")');+ const historyList = page.locator('.ldr-history-list, [class*="history"]');++ if (await emptyState.count() > 0 && await emptyState.first().isVisible()) {+ await expect(emptyState.first()).toHaveScreenshot('history-empty-state.png', {+ maxDiffPixelRatio: 0.02,+ });+ } else if (await historyList.count() > 0) {+ // If there are history items, capture the first card+ const firstCard = historyList.locator('.ldr-history-item, .ldr-card').first();+ if (await firstCard.isVisible()) {+ await expect(firstCard).toHaveScreenshot('history-card.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ }+ });++ test('Library card (empty state)', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/library/');+ await page.waitForLoadState('networkidle');++ // Look for empty state or document list+ const emptyState = page.locator('.ldr-empty-state, [class*="empty"], :text("No documents")');+ const docList = page.locator('.ldr-document-list, [class*="library"]');++ if (await emptyState.count() > 0 && await emptyState.first().isVisible()) {+ await expect(emptyState.first()).toHaveScreenshot('library-empty-state.png', {+ maxDiffPixelRatio: 0.02,+ });+ } else if (await docList.count() > 0) {+ const firstCard = docList.locator('.ldr-document-card, .ldr-card').first();+ if (await firstCard.isVisible()) {+ await expect(firstCard).toHaveScreenshot('library-card.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ }+ });++ test('Metrics link card', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/metrics/');+ await page.waitForLoadState('networkidle');+ await page.waitForTimeout(500);++ const metricLink = page.locator('.ldr-metric-link').first();+ if (await metricLink.isVisible()) {+ await expect(metricLink).toHaveScreenshot('metric-link-card.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });+});++// ============================================+// NEWS PAGE COMPONENT TESTS+// ============================================++test.describe('News Page Components', () => {+ test('News subscription template', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/news/');+ await page.waitForLoadState('networkidle');++ // Look for template cards+ const template = page.locator('[class*="template"], .news-template, .ldr-subscription-template').first();+ if (await template.isVisible()) {+ await expect(template).toHaveScreenshot('news-template.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Create Subscription button', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/news/');+ await page.waitForLoadState('networkidle');++ const createBtn = page.locator('button, a').filter({+ hasText: /Create.*Subscription/i,+ }).first();++ if (await createBtn.isVisible()) {+ await expect(createBtn).toHaveScreenshot('news-create-subscription-btn.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });+});++// ============================================+// INTERACTION STATE TESTS+// ============================================++test.describe('Interaction States', () => {+ test('Research - Advanced options collapsed', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const toggle = page.locator('.ldr-advanced-options-toggle, [class*="advanced"]').first();+ if (await toggle.isVisible()) {+ // Ensure panel is collapsed+ const panel = page.locator('.ldr-advanced-options-panel');+ if (await panel.isVisible()) {+ await toggle.click();+ await page.waitForTimeout(300);+ }++ await expect(toggle).toHaveScreenshot('advanced-options-collapsed.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Research - Advanced options expanded', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const toggle = page.locator('.ldr-advanced-options-toggle, [class*="advanced"]').first();+ if (await toggle.isVisible()) {+ // Expand the panel+ const panel = page.locator('.ldr-advanced-options-panel');+ if (!(await panel.isVisible())) {+ await toggle.click();+ await page.waitForTimeout(300);+ }++ if (await panel.isVisible()) {+ await expect(panel).toHaveScreenshot('advanced-options-expanded.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ }+ });++ test('Settings tabs - Tab navigation', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/settings/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);++ const tabNav = page.locator('.ldr-settings-tabs, .ldr-tab-navigation, [role="tablist"]').first();+ if (await tabNav.isVisible()) {+ await expect(tabNav).toHaveScreenshot('settings-tab-navigation.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Research textarea - with text entered', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const textarea = page.locator('#query, textarea[name="query"], .ldr-research-textarea').first();+ if (await textarea.isVisible()) {+ // Type sample text+ await textarea.fill('What are the latest advancements in quantum computing?');+ await page.waitForTimeout(200);++ await expect(textarea).toHaveScreenshot('research-textarea-with-text.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Mobile nav - active state highlighting', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ // Navigate to different pages to see active state+ const pages = [+ { path: '/', expected: 'Research' },+ { path: '/history/', expected: 'History' },+ { path: '/settings/', expected: 'Settings' },+ ];++ for (const pageInfo of pages) {+ await page.goto(pageInfo.path);+ await page.waitForLoadState('networkidle');+ await ensureSheetsClosed(page);++ const nav = page.locator('.ldr-mobile-bottom-nav');+ if (await nav.isVisible()) {+ const safeName = pageInfo.expected.toLowerCase();+ await expect(nav).toHaveScreenshot(`mobile-nav-active-${safeName}.png`, {+ maxDiffPixelRatio: 0.02,+ });+ }+ }+ });+});++// ============================================+// LOADING AND ERROR STATES+// ============================================++test.describe('Loading and Error States', () => {+ test('Settings - Loading spinner', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ // Block the settings API to capture loading state+ await page.route('**/api/settings**', (route) => {+ // Delay the response to capture loading state+ setTimeout(() => route.continue(), 5000);+ });++ await page.goto('/settings/');++ // Capture the loading spinner immediately+ const spinner = page.locator('.ldr-loading-spinner, .spinner, [class*="loading"]');+ if (await spinner.first().isVisible({ timeout: 2000 }).catch(() => false)) {+ await expect(spinner.first()).toHaveScreenshot('settings-loading-spinner.png', {+ maxDiffPixelRatio: 0.1, // Allow more variance for animations+ });+ }+ });++ test('Research page - Error message display', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ // Inject an error message element for testing+ await page.evaluate(() => {+ const errorDiv = document.createElement('div');+ errorDiv.className = 'ldr-error-message ldr-test-error';+ errorDiv.style.cssText = 'display: block; padding: 1rem; background: #fee; border: 1px solid #fcc; border-radius: 4px; color: #c00; margin: 1rem;';+ errorDiv.innerHTML = '<strong>Error:</strong> Failed to start research. Please try again.';+ const main = document.querySelector('main, .ldr-page, #content');+ if (main) {+ main.insertBefore(errorDiv, main.firstChild);+ }+ });++ const errorMsg = page.locator('.ldr-test-error');+ if (await errorMsg.isVisible()) {+ await expect(errorMsg).toHaveScreenshot('error-message-display.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Empty state - History page', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/history/');+ await page.waitForLoadState('networkidle');+ await ensureSheetsClosed(page);++ // Check for empty state message+ const emptyState = page.locator(':text("No research history"), :text("no history"), .ldr-empty-state').first();+ if (await emptyState.isVisible()) {+ const container = emptyState.locator('..').locator('..');+ await expect(container).toHaveScreenshot('history-empty-state-container.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Empty state - Library page', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/library/');+ await page.waitForLoadState('networkidle');+ await ensureSheetsClosed(page);++ // Check for empty state message+ const emptyState = page.locator(':text("No documents"), :text("no library"), .ldr-empty-state').first();+ if (await emptyState.isVisible()) {+ const container = emptyState.locator('..').locator('..');+ await expect(container).toHaveScreenshot('library-empty-state-container.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });+});++// ============================================+// METRICS PAGE SECTION TESTS+// ============================================++test.describe('Metrics Page Sections', () => {+ /**+ * The Metrics page is very tall (9543px+) which causes screenshot reliability issues.+ * These tests capture specific sections instead of the full page.+ */++ test('Metrics - System Overview section', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/metrics/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);++ // Find the System Overview header section+ const overviewSection = page.locator('.ldr-metrics-grid').first();+ if (await overviewSection.isVisible()) {+ await expect(overviewSection).toHaveScreenshot('metrics-system-overview.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Metrics - Token consumption chart section', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/metrics/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);++ // Find the token chart container+ const chartContainer = page.locator('#time-series-chart').locator('..');+ if (await chartContainer.isVisible()) {+ await expect(chartContainer).toHaveScreenshot('metrics-token-chart-section.png', {+ maxDiffPixelRatio: 0.05, // Charts may have some dynamic variance+ });+ }+ });++ test('Metrics - Search activity chart section', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/metrics/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);++ // Find the search activity chart+ const chartContainer = page.locator('#search-activity-chart').locator('..');+ if (await chartContainer.isVisible()) {+ await expect(chartContainer).toHaveScreenshot('metrics-search-activity-section.png', {+ maxDiffPixelRatio: 0.05,+ });+ }+ });++ test('Metrics - Model usage section', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/metrics/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);++ // Find the model usage list+ const modelUsageList = page.locator('#model-usage-list');+ if (await modelUsageList.isVisible()) {+ await expect(modelUsageList).toHaveScreenshot('metrics-model-usage-section.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Metrics - Research analytics section', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/metrics/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);++ // Find research analytics section+ const analyticsSection = page.locator('#mode-breakdown').locator('..').locator('..');+ if (await analyticsSection.isVisible()) {+ await expect(analyticsSection).toHaveScreenshot('metrics-research-analytics-section.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ });++ test('Metrics - Rate limiting section', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/metrics/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);++ // Scroll to rate limiting section+ const rateLimitSection = page.locator('#rate-limit-success-rate').locator('..').locator('..');+ if (await rateLimitSection.count() > 0) {+ await rateLimitSection.scrollIntoViewIfNeeded();+ await page.waitForTimeout(300);++ if (await rateLimitSection.isVisible()) {+ await expect(rateLimitSection).toHaveScreenshot('metrics-rate-limiting-section.png', {+ maxDiffPixelRatio: 0.02,+ });+ }+ }+ });++ test('Metrics - Viewport-only screenshot (no fullPage)', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/metrics/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);+ await ensureSheetsClosed(page);++ // Take a viewport-only screenshot (not fullPage) for reliable baseline+ await expect(page).toHaveScreenshot('metrics-viewport-only.png', {+ fullPage: false,+ maxDiffPixelRatio: 0.02,+ });+ });+});++// ============================================+// RESPONSIVE HEADER/TITLE TESTS+// ============================================++test.describe('Page Headers', () => {+ const pages = [+ { path: '/', name: 'research' },+ { path: '/history/', name: 'history' },+ { path: '/settings/', name: 'settings' },+ { path: '/news/', name: 'news' },+ { path: '/library/', name: 'library' },+ { path: '/metrics/', name: 'metrics' },+ ];++ for (const pageInfo of pages) {+ test(`${pageInfo.name} page header`, async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto(pageInfo.path);+ await page.waitForLoadState('networkidle');+ await ensureSheetsClosed(page);++ // Find the main header/title area+ const header = page.locator('h1, .page-title, .ldr-page-header, header').first();+ if (await header.isVisible()) {+ await expect(header).toHaveScreenshot(`${pageInfo.name}-page-header.png`, {+ maxDiffPixelRatio: 0.02,+ });+ }+ });+ }+});