Skip to content

~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.

test(playwright): add theme, subpage, and interactive state visual regression tests

LearningCircuit3235c9850889
diff --git a/tests/ui_tests/playwright/tests/interactive-states.spec.js b/tests/ui_tests/playwright/tests/interactive-states.spec.js
new file mode 100644
index 0000000000..923ff305d0
--- /dev/null
+++ b/tests/ui_tests/playwright/tests/interactive-states.spec.js
@@ -0,0 +1,457 @@
+/**
+ * Interactive States Tests
+ *
+ * Tests for active/expanded UI states where CSS often breaks:
+ * - Research page advanced options expanded
+ * - Settings search filtering
+ * - Mobile "More" menu navigation
+ * - Benchmark form sections
+ * - Help panel expanded states
+ *
+ * These tests verify that interactive elements don't cause overflow,
+ * z-index issues, or layout breakage when activated.
+ *
+ * Note: Authentication is handled by auth.setup.js via storageState
+ */
+
+import { test, expect } from '@playwright/test';
+const {
+ ensureSheetsClosed,
+ MOBILE_NAV_SELECTOR,
+ waitForPageLoad,
+} = require('./helpers/mobile-utils');
+
+// ============================================
+// RESEARCH PAGE - ADVANCED OPTIONS EXPANDED
+// ============================================
+
+test.describe('Research - Advanced Options Expanded', () => {
+ test.beforeEach(async ({ page }) => {
+ await page.goto('/');
+ await waitForPageLoad(page, { path: '/' });
+ });
+
+ test('advanced options expand without overflow', async ({ page }) => {
+ const toggleBtn = page.locator('.ldr-advanced-options-toggle');
+
+ if (await toggleBtn.count() > 0 && await toggleBtn.isVisible()) {
+ // Click to expand
+ await toggleBtn.click();
+ await page.waitForTimeout(500); // Wait for animation
+
+ // Check panel is visible
+ const panel = page.locator('.ldr-advanced-options-panel, #advanced-options-panel');
+ if (await panel.count() > 0) {
+ await expect(panel.first()).toBeVisible();
+ }
+
+ // Check no horizontal overflow
+ const hasOverflow = await page.evaluate(() =>
+ document.documentElement.scrollWidth > window.innerWidth
+ );
+
+ if (hasOverflow) {
+ const overflowInfo = await page.evaluate(() => {
+ const elements = [];
+ document.querySelectorAll('.ldr-advanced-options-panel *, #advanced-options-panel *').forEach((el) => {
+ const rect = el.getBoundingClientRect();
+ if (rect.right > window.innerWidth) {
+ elements.push({
+ tag: el.tagName.toLowerCase(),
+ class: el.className?.toString().slice(0, 60),
+ overflow: Math.round(rect.right - window.innerWidth),
+ });
+ }
+ });
+ return elements.slice(0, 5);
+ });
+ console.log('Advanced options overflow:', JSON.stringify(overflowInfo, null, 2));
+ }
+
+ expect(hasOverflow, 'Advanced options should not cause horizontal overflow').toBe(false);
+ }
+ });
+
+ test('advanced options expanded screenshot', async ({ page, isMobile }) => {
+ const toggleBtn = page.locator('.ldr-advanced-options-toggle');
+
+ if (await toggleBtn.count() > 0 && await toggleBtn.isVisible()) {
+ await toggleBtn.click();
+ await page.waitForTimeout(500);
+
+ if (isMobile) {
+ await ensureSheetsClosed(page);
+ }
+
+ await expect(page).toHaveScreenshot('research-advanced-options-expanded.png', {
+ fullPage: !isMobile,
+ maxDiffPixelRatio: 0.02,
+ });
+ }
+ });
+
+ test('advanced options panel fits viewport on mobile', async ({ page, isMobile }, testInfo) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ const isTablet = testInfo.project.name.includes('iPad');
+ if (isTablet) {
+ test.skip();
+ return;
+ }
+
+ const toggleBtn = page.locator('.ldr-advanced-options-toggle');
+
+ if (await toggleBtn.count() > 0 && await toggleBtn.isVisible()) {
+ await toggleBtn.click();
+ await page.waitForTimeout(500);
+
+ const panel = page.locator('.ldr-advanced-options-panel, #advanced-options-panel');
+ if (await panel.count() > 0 && await panel.first().isVisible()) {
+ const box = await panel.first().boundingBox();
+ const viewportWidth = await page.evaluate(() => window.innerWidth);
+
+ if (box) {
+ expect(
+ box.x + box.width,
+ 'Advanced options panel should fit viewport width'
+ ).toBeLessThanOrEqual(viewportWidth + 5);
+ }
+ }
+ }
+ });
+});
+
+// ============================================
+// SETTINGS SEARCH FILTERING
+// ============================================
+
+test.describe('Settings - Search Filtering', () => {
+ test.beforeEach(async ({ page }) => {
+ await page.goto('/settings/');
+ await waitForPageLoad(page, { path: '/settings/' });
+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});
+ });
+
+ test('search filter shows results for "model"', async ({ page }) => {
+ const searchInput = page.locator('#settings-search, .ldr-search-input');
+
+ if (await searchInput.count() > 0 && await searchInput.isVisible()) {
+ await searchInput.fill('model');
+ await page.waitForTimeout(500); // Wait for filter to apply
+
+ // Some settings should be visible (matching "model")
+ const visibleSettings = await page.evaluate(() => {
+ const items = document.querySelectorAll(
+ '.ldr-settings-group, .ldr-setting-item, [class*="setting"]'
+ );
+ let visibleCount = 0;
+ items.forEach(el => {
+ const style = window.getComputedStyle(el);
+ if (style.display !== 'none' && style.visibility !== 'hidden') {
+ visibleCount++;
+ }
+ });
+ return visibleCount;
+ });
+
+ expect(visibleSettings, 'Should show some settings matching "model"').toBeGreaterThan(0);
+ }
+ });
+
+ test('search filter screenshot with results', async ({ page, isMobile }) => {
+ const searchInput = page.locator('#settings-search, .ldr-search-input');
+
+ if (await searchInput.count() > 0 && await searchInput.isVisible()) {
+ await searchInput.fill('model');
+ await page.waitForTimeout(500);
+
+ if (isMobile) {
+ await ensureSheetsClosed(page);
+ }
+
+ await expect(page).toHaveScreenshot('settings-search-model.png', {
+ fullPage: !isMobile,
+ maxDiffPixelRatio: 0.02,
+ });
+ }
+ });
+
+ test('search filter empty state for non-matching query', async ({ page }) => {
+ const searchInput = page.locator('#settings-search, .ldr-search-input');
+
+ if (await searchInput.count() > 0 && await searchInput.isVisible()) {
+ await searchInput.fill('zzz_nonexistent_setting_xyz');
+ await page.waitForTimeout(500);
+
+ // Check that no settings are visible or an empty state is shown
+ const visibleSettings = await page.evaluate(() => {
+ const items = document.querySelectorAll(
+ '.ldr-settings-group:not([style*="display: none"]), .ldr-setting-item:not([style*="display: none"])'
+ );
+ let visibleCount = 0;
+ items.forEach(el => {
+ const style = window.getComputedStyle(el);
+ if (style.display !== 'none' && style.visibility !== 'hidden' && el.getBoundingClientRect().height > 0) {
+ visibleCount++;
+ }
+ });
+ return visibleCount;
+ });
+
+ // With a nonsense query, very few or no settings should match
+ // (some containers may remain visible even if content is hidden)
+ expect(visibleSettings, 'Non-matching query should show very few results').toBeLessThan(5);
+ }
+ });
+
+ test('search filter empty state screenshot', async ({ page, isMobile }) => {
+ const searchInput = page.locator('#settings-search, .ldr-search-input');
+
+ if (await searchInput.count() > 0 && await searchInput.isVisible()) {
+ await searchInput.fill('zzz_nonexistent_setting_xyz');
+ await page.waitForTimeout(500);
+
+ if (isMobile) {
+ await ensureSheetsClosed(page);
+ }
+
+ await expect(page).toHaveScreenshot('settings-search-empty.png', {
+ fullPage: !isMobile,
+ maxDiffPixelRatio: 0.02,
+ });
+ }
+ });
+});
+
+// ============================================
+// MOBILE "MORE" MENU NAVIGATION
+// ============================================
+
+test.describe('Mobile More Menu - Navigation', () => {
+ test('navigate to Metrics via More menu', async ({ page, isMobile }, testInfo) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ const isTablet = testInfo.project.name.includes('iPad');
+ if (isTablet) {
+ test.skip();
+ return;
+ }
+
+ await page.goto('/');
+ await waitForPageLoad(page, { path: '/' });
+
+ // Look for the "More" button in mobile nav
+ const moreBtn = page.locator('.ldr-mobile-bottom-nav button:has-text("More"), .ldr-mobile-bottom-nav [aria-label="More"]');
+
+ if (await moreBtn.count() > 0) {
+ await moreBtn.click();
+ await page.waitForTimeout(300);
+
+ // Look for Metrics link in the opened menu/sheet
+ const metricsLink = page.locator('a:has-text("Metrics"), [href*="metrics"]');
+
+ if (await metricsLink.count() > 0 && await metricsLink.first().isVisible()) {
+ await metricsLink.first().click();
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+
+ // Should now be on the metrics page
+ expect(page.url()).toContain('/metrics');
+ }
+ }
+ });
+
+ test('navigate to Library via More menu', async ({ page, isMobile }, testInfo) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ const isTablet = testInfo.project.name.includes('iPad');
+ if (isTablet) {
+ test.skip();
+ return;
+ }
+
+ await page.goto('/');
+ await waitForPageLoad(page, { path: '/' });
+
+ const moreBtn = page.locator('.ldr-mobile-bottom-nav button:has-text("More"), .ldr-mobile-bottom-nav [aria-label="More"]');
+
+ if (await moreBtn.count() > 0) {
+ await moreBtn.click();
+ await page.waitForTimeout(300);
+
+ const libraryLink = page.locator('a:has-text("Library"), [href*="library"]');
+
+ if (await libraryLink.count() > 0 && await libraryLink.first().isVisible()) {
+ await libraryLink.first().click();
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+
+ expect(page.url()).toContain('/library');
+ }
+ }
+ });
+
+ test('More menu sheet screenshot', async ({ page, isMobile }, testInfo) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ const isTablet = testInfo.project.name.includes('iPad');
+ if (isTablet) {
+ test.skip();
+ return;
+ }
+
+ await page.goto('/');
+ await waitForPageLoad(page, { path: '/' });
+
+ const moreBtn = page.locator('.ldr-mobile-bottom-nav button:has-text("More"), .ldr-mobile-bottom-nav [aria-label="More"]');
+
+ if (await moreBtn.count() > 0) {
+ await moreBtn.click();
+ await page.waitForTimeout(500);
+
+ await expect(page).toHaveScreenshot('mobile-more-menu-open.png', {
+ fullPage: false,
+ maxDiffPixelRatio: 0.02,
+ });
+ }
+ });
+});
+
+// ============================================
+// BENCHMARK FORM SECTIONS
+// ============================================
+
+test.describe('Benchmark Form - Visual Regression', () => {
+ test.beforeEach(async ({ page }) => {
+ await page.goto('/benchmark/');
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+ // Wait for benchmark form to load
+ await page.waitForSelector('#settings-form, form, .ldr-card', { timeout: 10000 }).catch(() => {});
+ });
+
+ test('benchmark form top screenshot', async ({ page, isMobile }) => {
+ if (isMobile) {
+ await ensureSheetsClosed(page);
+ }
+
+ await page.evaluate(() => window.scrollTo(0, 0));
+ await page.waitForTimeout(200);
+
+ await expect(page).toHaveScreenshot('benchmark-form-top.png', {
+ fullPage: false,
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+
+ test('benchmark form bottom screenshot', async ({ page, isMobile }) => {
+ if (isMobile) {
+ await ensureSheetsClosed(page);
+ }
+
+ // Scroll to bottom of the form
+ await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
+ await page.waitForTimeout(300);
+
+ await expect(page).toHaveScreenshot('benchmark-form-bottom.png', {
+ fullPage: false,
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+
+ test('benchmark form has no horizontal overflow', async ({ page }) => {
+ const hasOverflow = await page.evaluate(() =>
+ document.documentElement.scrollWidth > window.innerWidth
+ );
+
+ expect(hasOverflow, 'Benchmark form should have no horizontal overflow').toBe(false);
+ });
+});
+
+// ============================================
+// HELP PANEL EXPANDED STATE
+// ============================================
+
+test.describe('Help Panel - Expanded State', () => {
+ test('help panel expands without overflow on Research page', async ({ page }) => {
+ await page.goto('/');
+ await waitForPageLoad(page, { path: '/' });
+
+ // Look for help panel toggle
+ const helpToggle = page.locator('.ldr-help-panel-toggle, [class*="help-toggle"], button:has-text("Help")');
+
+ if (await helpToggle.count() > 0 && await helpToggle.first().isVisible()) {
+ await helpToggle.first().click();
+ await page.waitForTimeout(500);
+
+ // Check for overflow
+ const hasOverflow = await page.evaluate(() =>
+ document.documentElement.scrollWidth > window.innerWidth
+ );
+
+ expect(hasOverflow, 'Help panel should not cause overflow').toBe(false);
+ }
+ });
+
+ test('help panel expanded screenshot on Research page', async ({ page, isMobile }) => {
+ await page.goto('/');
+ await waitForPageLoad(page, { path: '/' });
+
+ const helpToggle = page.locator('.ldr-help-panel-toggle, [class*="help-toggle"], button:has-text("Help")');
+
+ if (await helpToggle.count() > 0 && await helpToggle.first().isVisible()) {
+ await helpToggle.first().click();
+ await page.waitForTimeout(500);
+
+ if (isMobile) {
+ // Don't remove sheets for this test since we want to see the help panel
+ // But do scroll to top
+ }
+
+ await page.evaluate(() => window.scrollTo(0, 0));
+ await page.waitForTimeout(200);
+
+ await expect(page).toHaveScreenshot('research-help-panel-expanded.png', {
+ fullPage: false,
+ maxDiffPixelRatio: 0.02,
+ });
+ }
+ });
+
+ test('help panel expanded on Settings page', async ({ page, isMobile }) => {
+ await page.goto('/settings/');
+ await waitForPageLoad(page, { path: '/settings/' });
+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});
+
+ const helpToggle = page.locator('.ldr-help-panel-toggle, [class*="help-toggle"], button:has-text("Help")');
+
+ if (await helpToggle.count() > 0 && await helpToggle.first().isVisible()) {
+ await helpToggle.first().click();
+ await page.waitForTimeout(500);
+
+ if (isMobile) {
+ await ensureSheetsClosed(page);
+ }
+
+ await page.evaluate(() => window.scrollTo(0, 0));
+ await page.waitForTimeout(200);
+
+ await expect(page).toHaveScreenshot('settings-help-panel-expanded.png', {
+ fullPage: false,
+ maxDiffPixelRatio: 0.02,
+ });
+ }
+ });
+});
diff --git a/tests/ui_tests/playwright/tests/theme-visual-regression.spec.js b/tests/ui_tests/playwright/tests/theme-visual-regression.spec.js
new file mode 100644
index 0000000000..beb0219171
--- /dev/null
+++ b/tests/ui_tests/playwright/tests/theme-visual-regression.spec.js
@@ -0,0 +1,425 @@
+/**
+ * Theme Visual Regression Tests
+ *
+ * Tests 6 representative themes across key pages on both mobile and desktop.
+ * Validates that theme switching works correctly and catches common theme bugs:
+ * - Invisible text on dark backgrounds
+ * - Broken borders on form elements
+ * - Unreadable inputs/buttons
+ * - WCAG contrast failures
+ *
+ * Themes tested: light, high-contrast, midnight, nord, ocean, rose-pine
+ * Pages tested: Research (/), Settings (/settings/), News (/news/)
+ *
+ * Note: Authentication is handled by auth.setup.js via storageState
+ */
+
+import { test, expect } from '@playwright/test';
+const {
+ ensureSheetsClosed,
+ waitForPageLoad,
+ MOBILE_NAV_SELECTOR,
+} = require('./helpers/mobile-utils');
+
+// Representative theme selection covering light, dark, and high-contrast variants
+const THEMES = [
+ { id: 'light', name: 'Light', type: 'light' },
+ { id: 'high-contrast', name: 'High Contrast', type: 'light' },
+ { id: 'midnight', name: 'Midnight', type: 'dark' },
+ { id: 'nord', name: 'Nord', type: 'dark' },
+ { id: 'ocean', name: 'Ocean', type: 'dark' },
+ { id: 'rose-pine', name: 'Rose Pine', type: 'dark' },
+];
+
+// Pages to test per theme
+const THEME_PAGES = [
+ { path: '/', name: 'Research' },
+ { path: '/settings/', name: 'Settings', waitForSpinner: true },
+ { path: '/news/', name: 'News' },
+];
+
+/**
+ * Apply a theme to the page by setting the data-theme attribute
+ */
+async function applyTheme(page, themeId) {
+ await page.evaluate((theme) => {
+ document.documentElement.setAttribute('data-theme', theme);
+ }, themeId);
+ // Wait for theme CSS to apply
+ await page.waitForTimeout(300);
+}
+
+/**
+ * Navigate to a page and apply a theme
+ */
+async function setupPageWithTheme(page, pageInfo, themeId) {
+ await page.goto(pageInfo.path);
+ await waitForPageLoad(page, pageInfo);
+
+ if (pageInfo.waitForSpinner) {
+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});
+ }
+
+ await applyTheme(page, themeId);
+}
+
+// ============================================
+// FULL-PAGE THEME SCREENSHOTS (Mobile + Desktop)
+// ============================================
+
+test.describe('Theme Visual Regression - Screenshots', () => {
+ for (const theme of THEMES) {
+ for (const pageInfo of THEME_PAGES) {
+ test(`${theme.name} theme on ${pageInfo.name}`, async ({ page, isMobile }) => {
+ await setupPageWithTheme(page, pageInfo, theme.id);
+
+ if (isMobile) {
+ await ensureSheetsClosed(page);
+ }
+
+ await page.evaluate(() => window.scrollTo(0, 0));
+ await page.waitForTimeout(200);
+
+ const safeName = `${theme.id}-${pageInfo.name.toLowerCase().replace(/[^a-z0-9]/g, '-')}`;
+
+ // Use viewport-only screenshots for Settings (very long page produces 5+ MB full-page images)
+ const useFullPage = !isMobile && pageInfo.path !== '/settings/';
+
+ await expect(page).toHaveScreenshot(`theme-${safeName}.png`, {
+ fullPage: useFullPage,
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+ }
+ }
+});
+
+// ============================================
+// TEXT READABILITY - WCAG CONTRAST CHECKS
+// ============================================
+
+test.describe('Theme Contrast - Text Readability', () => {
+ for (const theme of THEMES) {
+ test(`${theme.name} theme has readable text on Research page`, async ({ page }) => {
+ await setupPageWithTheme(page, { path: '/', name: 'Research' }, theme.id);
+
+ // Check contrast of key text elements against their backgrounds
+ const contrastIssues = await page.evaluate(() => {
+ const issues = [];
+
+ /**
+ * Parse RGB/RGBA string to components including alpha
+ */
+ function parseRgba(rgbStr) {
+ const match = rgbStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
+ if (!match) return null;
+ return {
+ r: parseInt(match[1]),
+ g: parseInt(match[2]),
+ b: parseInt(match[3]),
+ a: match[4] !== undefined ? parseFloat(match[4]) : 1,
+ };
+ }
+
+ /**
+ * Composite a semi-transparent color over a solid background
+ */
+ function compositeColor(fg, bg) {
+ const a = fg.a;
+ return {
+ r: Math.round(fg.r * a + bg.r * (1 - a)),
+ g: Math.round(fg.g * a + bg.g * (1 - a)),
+ b: Math.round(fg.b * a + bg.b * (1 - a)),
+ a: 1,
+ };
+ }
+
+ /**
+ * Get the effective background color by walking up the DOM tree,
+ * compositing semi-transparent backgrounds along the way
+ */
+ function getEffectiveBgColor(el) {
+ // Collect background layers from element up to root
+ const layers = [];
+ let current = el;
+ while (current) {
+ const style = window.getComputedStyle(current);
+ const bg = style.backgroundColor;
+ if (bg && bg !== 'transparent') {
+ const parsed = parseRgba(bg);
+ if (parsed && parsed.a > 0) {
+ layers.push(parsed);
+ // If this layer is fully opaque, stop walking
+ if (parsed.a >= 1) break;
+ }
+ }
+ current = current.parentElement;
+ }
+
+ if (layers.length === 0) return { r: 255, g: 255, b: 255, a: 1 };
+
+ // Composite from back to front (last layer is the bottom-most opaque one)
+ let result = layers[layers.length - 1].a >= 1
+ ? layers[layers.length - 1]
+ : compositeColor(layers[layers.length - 1], { r: 255, g: 255, b: 255, a: 1 });
+
+ for (let i = layers.length - 2; i >= 0; i--) {
+ result = compositeColor(layers[i], result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Parse RGB string to components (for foreground text color)
+ */
+ function parseRgb(rgbStr) {
+ const match = rgbStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
+ if (!match) return null;
+ return { r: parseInt(match[1]), g: parseInt(match[2]), b: parseInt(match[3]) };
+ }
+
+ /**
+ * Calculate relative luminance per WCAG 2.0
+ */
+ function luminance({ r, g, b }) {
+ const [rs, gs, bs] = [r, g, b].map(c => {
+ c = c / 255;
+ return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
+ });
+ return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
+ }
+
+ /**
+ * Calculate contrast ratio between two colors
+ */
+ function contrastRatio(fg, bg) {
+ const l1 = Math.max(luminance(fg), luminance(bg));
+ const l2 = Math.min(luminance(fg), luminance(bg));
+ return (l1 + 0.05) / (l2 + 0.05);
+ }
+
+ // Check key text elements
+ const selectors = [
+ 'h1', 'h2', 'h3',
+ 'p', 'label',
+ '.ldr-card', '.ldr-btn',
+ 'button:not([disabled])',
+ ];
+
+ selectors.forEach(selector => {
+ const elements = document.querySelectorAll(selector);
+ elements.forEach(el => {
+ const style = window.getComputedStyle(el);
+ if (style.display === 'none' || style.visibility === 'hidden') return;
+ if (el.getBoundingClientRect().height === 0) return;
+
+ const fgColor = parseRgb(style.color);
+ const bgColor = getEffectiveBgColor(el);
+
+ if (fgColor && bgColor) {
+ const ratio = contrastRatio(fgColor, bgColor);
+ // WCAG AA requires 4.5:1 for normal text, 3:1 for large text
+ const minRatio = parseFloat(style.fontSize) >= 18 ? 3.0 : 4.5;
+
+ if (ratio < minRatio) {
+ issues.push({
+ selector,
+ text: (el.textContent || '').trim().slice(0, 40),
+ ratio: Math.round(ratio * 100) / 100,
+ required: minRatio,
+ fg: style.color,
+ bg: `rgb(${bgColor.r}, ${bgColor.g}, ${bgColor.b})`,
+ });
+ }
+ }
+ });
+ });
+
+ return issues.slice(0, 10); // Return first 10 issues
+ });
+
+ if (contrastIssues.length > 0) {
+ console.log(
+ `${theme.name} contrast issues:`,
+ JSON.stringify(contrastIssues, null, 2)
+ );
+ }
+
+ // Allow up to 10 contrast issues. Dark themes commonly have more borderline
+ // contrast on inactive/secondary elements (mode cards, help panels, labels).
+ // Issues are logged above for manual review.
+ expect(
+ contrastIssues.length,
+ `${theme.name} should have minimal contrast issues`
+ ).toBeLessThan(11);
+ });
+ }
+});
+
+// ============================================
+// FORM ELEMENT VISIBILITY ON SETTINGS PAGE
+// ============================================
+
+test.describe('Theme Contrast - Settings Form Elements', () => {
+ for (const theme of THEMES) {
+ test(`${theme.name} theme - form elements visible on Settings`, async ({ page }) => {
+ await setupPageWithTheme(
+ page,
+ { path: '/settings/', name: 'Settings', waitForSpinner: true },
+ theme.id
+ );
+
+ // Check that form inputs have visible borders
+ const formIssues = await page.evaluate(() => {
+ const issues = [];
+ const inputs = document.querySelectorAll(
+ 'input:not([type="hidden"]), select, textarea'
+ );
+
+ inputs.forEach(el => {
+ const style = window.getComputedStyle(el);
+ if (style.display === 'none' || style.visibility === 'hidden') return;
+
+ const rect = el.getBoundingClientRect();
+ if (rect.width === 0 || rect.height === 0) return;
+ if (rect.top > window.innerHeight) return; // Off-screen below
+
+ // Check border visibility (border-color should differ from background)
+ const borderColor = style.borderColor;
+ const bgColor = style.backgroundColor;
+
+ // If border is same as background, it's invisible
+ if (borderColor === bgColor && style.borderWidth !== '0px') {
+ issues.push({
+ type: 'invisible-border',
+ tag: el.tagName.toLowerCase(),
+ inputType: el.type || '',
+ class: el.className?.toString().slice(0, 50),
+ });
+ }
+
+ // Check text color contrast for input text
+ if (el.tagName === 'SELECT' || el.tagName === 'INPUT') {
+ if (style.color === bgColor) {
+ issues.push({
+ type: 'invisible-text',
+ tag: el.tagName.toLowerCase(),
+ inputType: el.type || '',
+ class: el.className?.toString().slice(0, 50),
+ });
+ }
+ }
+ });
+
+ return issues.slice(0, 10);
+ });
+
+ if (formIssues.length > 0) {
+ console.log(
+ `${theme.name} form visibility issues:`,
+ JSON.stringify(formIssues, null, 2)
+ );
+ }
+
+ // No form elements should be completely invisible
+ expect(
+ formIssues.length,
+ `${theme.name} should have no invisible form elements on Settings`
+ ).toBe(0);
+ });
+ }
+});
+
+// ============================================
+// MOBILE NAV STYLING PER THEME
+// ============================================
+
+test.describe('Theme - Mobile Navigation Styling', () => {
+ for (const theme of THEMES) {
+ test(`${theme.name} theme - mobile nav visible`, async ({ page, isMobile }, testInfo) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ const isTablet = testInfo.project.name.includes('iPad');
+ if (isTablet) {
+ test.skip();
+ return;
+ }
+
+ await setupPageWithTheme(page, { path: '/', name: 'Research' }, theme.id);
+
+ const mobileNav = page.locator(MOBILE_NAV_SELECTOR);
+ await expect(mobileNav, `Mobile nav should be visible in ${theme.name} theme`).toBeVisible();
+
+ // Wait for theme to fully apply to mobile nav
+ await page.waitForTimeout(500);
+
+ // Screenshot the mobile nav area
+ const safeName = theme.id;
+ await expect(mobileNav).toHaveScreenshot(`theme-mobile-nav-${safeName}.png`, {
+ maxDiffPixelRatio: 0.03,
+ });
+ });
+ }
+});
+
+// ============================================
+// DESKTOP SIDEBAR STYLING PER THEME
+// ============================================
+
+test.describe('Theme - Desktop Sidebar Styling', () => {
+ for (const theme of THEMES) {
+ test(`${theme.name} theme - sidebar visible`, async ({ page, isMobile }) => {
+ if (isMobile) {
+ test.skip();
+ return;
+ }
+
+ await page.setViewportSize({ width: 1200, height: 800 });
+ await page.goto('/');
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+ await applyTheme(page, theme.id);
+
+ const sidebar = page.locator('.ldr-sidebar');
+ await expect(sidebar, `Sidebar should be visible in ${theme.name} theme`).toBeVisible();
+
+ // Screenshot the sidebar
+ const safeName = theme.id;
+ await expect(sidebar).toHaveScreenshot(`theme-sidebar-${safeName}.png`, {
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+ }
+});
+
+// ============================================
+// CHANGE PASSWORD PAGE PER THEME
+// ============================================
+
+test.describe('Theme - Change Password Page', () => {
+ for (const theme of THEMES) {
+ test(`${theme.name} theme on Change Password`, async ({ page, isMobile }) => {
+ await page.goto('/auth/change-password');
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+ await applyTheme(page, theme.id);
+
+ if (isMobile) {
+ await ensureSheetsClosed(page);
+ }
+
+ await page.evaluate(() => window.scrollTo(0, 0));
+ await page.waitForTimeout(200);
+
+ const safeName = theme.id;
+ await expect(page).toHaveScreenshot(`theme-change-password-${safeName}.png`, {
+ fullPage: !isMobile,
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+ }
+});
diff --git a/tests/ui_tests/playwright/tests/untested-subpages.spec.js b/tests/ui_tests/playwright/tests/untested-subpages.spec.js
new file mode 100644
index 0000000000..d09caf4839
--- /dev/null
+++ b/tests/ui_tests/playwright/tests/untested-subpages.spec.js
@@ -0,0 +1,483 @@
+/**
+ * Untested Subpages Tests
+ *
+ * Tests for pages that have zero test coverage:
+ * 1. /news/insights - Known broken route (missing template)
+ * 2. /news/preferences - Known broken route (missing template)
+ * 3. /benchmark/results - Benchmark results page
+ * 4. /auth/change-password - Change password form
+ *
+ * Covers mobile + desktop: page load, overflow, touch targets, screenshots.
+ *
+ * Note: Authentication is handled by auth.setup.js via storageState
+ */
+
+import { test, expect } from '@playwright/test';
+const {
+ ensureSheetsClosed,
+ MIN_TOUCH_TARGET,
+ MOBILE_NAV_SELECTOR,
+ waitForPageLoad,
+} = require('./helpers/mobile-utils');
+
+// ============================================
+// BROKEN ROUTES - Document Real Bugs
+// ============================================
+
+test.describe('Broken Routes - News Subpages', () => {
+ test('/news/insights returns error (missing template)', async ({ page }) => {
+ const response = await page.goto('/news/insights');
+
+ // This route should 500 because the template doesn't exist
+ // If it returns 200, the bug may have been fixed
+ const status = response?.status();
+ if (status === 500 || status === 404) {
+ // Document the bug: route is broken
+ console.log(`/news/insights returned ${status} - missing template confirmed`);
+ expect([404, 500]).toContain(status);
+ } else if (status === 200) {
+ // Bug has been fixed - verify the page loads properly
+ console.log('/news/insights returned 200 - template exists now');
+ await page.waitForLoadState('domcontentloaded');
+
+ // If it loads, check for page errors
+ const pageErrors = [];
+ page.on('pageerror', (error) => pageErrors.push(error.message));
+ await page.waitForTimeout(500);
+ expect(pageErrors.length).toBe(0);
+ } else {
+ // Unexpected status code - may be a redirect
+ console.log(`/news/insights returned unexpected status: ${status}`);
+ expect(status).toBeLessThan(500);
+ }
+ });
+
+ test('/news/preferences returns error (missing template)', async ({ page }) => {
+ const response = await page.goto('/news/preferences');
+
+ const status = response?.status();
+ if (status === 500 || status === 404) {
+ console.log(`/news/preferences returned ${status} - missing template confirmed`);
+ expect([404, 500]).toContain(status);
+ } else if (status === 200) {
+ console.log('/news/preferences returned 200 - template exists now');
+ await page.waitForLoadState('domcontentloaded');
+
+ const pageErrors = [];
+ page.on('pageerror', (error) => pageErrors.push(error.message));
+ await page.waitForTimeout(500);
+ expect(pageErrors.length).toBe(0);
+ } else {
+ console.log(`/news/preferences returned unexpected status: ${status}`);
+ expect(status).toBeLessThan(500);
+ }
+ });
+});
+
+// ============================================
+// BENCHMARK RESULTS PAGE
+// ============================================
+
+test.describe('Benchmark Results Page', () => {
+ test.beforeEach(async ({ page }) => {
+ await page.goto('/benchmark/results');
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+ });
+
+ test('page loads without critical errors', async ({ page }) => {
+ const errors = [];
+ const pageErrors = [];
+
+ // Set up listeners BEFORE navigation
+ page.on('console', (msg) => {
+ if (msg.type() === 'error') {
+ errors.push(msg.text());
+ }
+ });
+ page.on('pageerror', (error) => {
+ pageErrors.push(error.message);
+ });
+
+ // Navigate fresh to capture all errors
+ await page.goto('/benchmark/results');
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+
+ const criticalErrors = errors.filter(
+ (err) =>
+ !err.includes('favicon') &&
+ !err.includes('404') &&
+ !err.includes('Failed to load resource') &&
+ !err.includes("Can't find variable: Chart") &&
+ !err.includes("Can't find variable: io")
+ );
+
+ // Filter out known benign page errors (Chart.js and Socket.IO race conditions)
+ const criticalPageErrors = pageErrors.filter(
+ (err) =>
+ !err.includes('Chart') &&
+ !err.includes('io') &&
+ !err.includes('socket') &&
+ !err.includes('is not defined')
+ );
+
+ expect(criticalPageErrors.length, `Should have no critical page errors: ${pageErrors.join(', ')}`).toBe(0);
+ expect(
+ criticalErrors.length,
+ `Should have no critical console errors: ${criticalErrors.join(', ')}`
+ ).toBe(0);
+ });
+
+ test('has no horizontal overflow', async ({ page }) => {
+ const hasOverflow = await page.evaluate(() =>
+ document.documentElement.scrollWidth > window.innerWidth
+ );
+
+ if (hasOverflow) {
+ const overflowInfo = await page.evaluate(() => {
+ const elements = [];
+ document.querySelectorAll('*').forEach((el) => {
+ const rect = el.getBoundingClientRect();
+ if (rect.right > window.innerWidth) {
+ elements.push({
+ tag: el.tagName.toLowerCase(),
+ class: el.className?.toString().slice(0, 60),
+ width: Math.round(rect.width),
+ right: Math.round(rect.right),
+ overflow: Math.round(rect.right - window.innerWidth),
+ });
+ }
+ });
+ return elements.slice(0, 5);
+ });
+ console.log('Benchmark results overflow:', JSON.stringify(overflowInfo, null, 2));
+ }
+
+ expect(hasOverflow, 'Benchmark results should have no horizontal overflow').toBe(false);
+ });
+
+ test('mobile nav visible on phone', async ({ page, isMobile }, testInfo) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ const isTablet = testInfo.project.name.includes('iPad');
+ if (isTablet) {
+ test.skip();
+ return;
+ }
+
+ const mobileNav = page.locator(MOBILE_NAV_SELECTOR);
+ await expect(mobileNav, 'Mobile nav should be visible').toBeVisible();
+ });
+
+ test('touch targets >= 44px on mobile', async ({ page, isMobile }, testInfo) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ 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"], .btn'
+ );
+ const issues = [];
+
+ elements.forEach((el) => {
+ const rect = el.getBoundingClientRect();
+ const style = window.getComputedStyle(el);
+
+ if (style.display === 'none' || style.visibility === 'hidden') return;
+ if (rect.width === 0 || rect.height === 0) return;
+ if (rect.top > window.innerHeight || rect.bottom < 0) return;
+ if (rect.left > window.innerWidth || rect.right < 0) return;
+
+ if (rect.width < MIN_SIZE || rect.height < MIN_SIZE) {
+ issues.push({
+ tag: el.tagName.toLowerCase(),
+ class: el.className?.toString().slice(0, 50),
+ size: `${Math.round(rect.width)}x${Math.round(rect.height)}`,
+ text: (el.textContent || '').trim().slice(0, 30),
+ });
+ }
+ });
+
+ return issues;
+ }, MIN_TOUCH_TARGET);
+
+ if (smallTargets.length > 0) {
+ console.log('Benchmark results small touch targets:', JSON.stringify(smallTargets, null, 2));
+ }
+
+ expect(
+ smallTargets.length,
+ 'Benchmark results should have minimal small touch targets'
+ ).toBeLessThan(3);
+ });
+
+ test('content not hidden behind mobile nav', async ({ page, isMobile }, testInfo) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ const isTablet = testInfo.project.name.includes('iPad');
+ if (isTablet) {
+ test.skip();
+ return;
+ }
+
+ // Scroll to bottom
+ await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
+ await page.waitForTimeout(300);
+
+ const result = await page.evaluate((navSelector) => {
+ const mobileNav = document.querySelector(navSelector);
+ if (!mobileNav) return { hasNav: false };
+
+ const navStyle = window.getComputedStyle(mobileNav);
+ if (navStyle.display === 'none') return { hasNav: false };
+
+ const navRect = mobileNav.getBoundingClientRect();
+ const interactiveElements = document.querySelectorAll(
+ 'button, a, input, select, textarea, [role="button"]'
+ );
+ const hiddenElements = [];
+
+ interactiveElements.forEach((el) => {
+ const rect = el.getBoundingClientRect();
+ const style = window.getComputedStyle(el);
+
+ if (style.display === 'none' || style.visibility === 'hidden') return;
+ if (rect.width === 0 || rect.height === 0) return;
+ if (el.closest('.ldr-help-panel-dismiss')) return;
+
+ const OVERLAP_TOLERANCE = 20;
+ if (rect.bottom > navRect.top + OVERLAP_TOLERANCE && rect.top < navRect.bottom) {
+ if (!mobileNav.contains(el)) {
+ hiddenElements.push({
+ tag: el.tagName.toLowerCase(),
+ text: (el.textContent || '').trim().slice(0, 30),
+ bottom: Math.round(rect.bottom),
+ navTop: Math.round(navRect.top),
+ });
+ }
+ }
+ });
+
+ return { hasNav: true, hiddenElements };
+ }, MOBILE_NAV_SELECTOR);
+
+ expect(
+ result.hiddenElements?.length || 0,
+ 'Benchmark results should have no elements behind mobile nav'
+ ).toBe(0);
+ });
+
+ test('filter section renders correctly', async ({ page }) => {
+ // Check if there's a filter/controls section on the results page
+ const filterSection = page.locator(
+ '.ldr-filter, .ldr-controls, [class*="filter"], [class*="controls"], form'
+ );
+ const hasFilters = await filterSection.count() > 0;
+
+ if (hasFilters) {
+ const firstFilter = filterSection.first();
+ if (await firstFilter.isVisible()) {
+ const box = await firstFilter.boundingBox();
+ const viewportWidth = await page.evaluate(() => window.innerWidth);
+
+ if (box) {
+ // Filter section should fit within viewport
+ expect(
+ box.x + box.width,
+ 'Filter section should not overflow viewport'
+ ).toBeLessThanOrEqual(viewportWidth + 5);
+ }
+ }
+ }
+ });
+
+ test('mobile screenshot', async ({ page, isMobile }) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ await ensureSheetsClosed(page);
+ await page.evaluate(() => window.scrollTo(0, 0));
+ await page.waitForTimeout(200);
+
+ await expect(page).toHaveScreenshot('benchmark-results-mobile.png', {
+ fullPage: false,
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+
+ test('desktop screenshot', async ({ page, isMobile }) => {
+ if (isMobile) {
+ test.skip();
+ return;
+ }
+
+ await page.setViewportSize({ width: 1200, height: 800 });
+ await page.goto('/benchmark/results');
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+
+ await expect(page).toHaveScreenshot('benchmark-results-desktop.png', {
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+});
+
+// ============================================
+// CHANGE PASSWORD PAGE
+// ============================================
+
+test.describe('Change Password Page', () => {
+ test.beforeEach(async ({ page }) => {
+ await page.goto('/auth/change-password');
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+ });
+
+ test('page loads without critical errors', async ({ page }) => {
+ const errors = [];
+ const pageErrors = [];
+
+ page.on('console', (msg) => {
+ if (msg.type() === 'error') {
+ errors.push(msg.text());
+ }
+ });
+ page.on('pageerror', (error) => {
+ pageErrors.push(error.message);
+ });
+
+ await page.goto('/auth/change-password');
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+
+ const criticalErrors = errors.filter(
+ (err) =>
+ !err.includes('favicon') &&
+ !err.includes('404') &&
+ !err.includes('Failed to load resource')
+ );
+
+ const criticalPageErrors = pageErrors.filter(
+ (err) =>
+ !err.includes('Chart') &&
+ !err.includes('io') &&
+ !err.includes('socket') &&
+ !err.includes('is not defined')
+ );
+
+ expect(criticalPageErrors.length, `Should have no critical page errors: ${pageErrors.join(', ')}`).toBe(0);
+ expect(
+ criticalErrors.length,
+ `Should have no critical console errors: ${criticalErrors.join(', ')}`
+ ).toBe(0);
+ });
+
+ test('form centered and fits viewport', async ({ page }) => {
+ const form = page.locator('form').first();
+
+ if (await form.count() > 0 && await form.isVisible()) {
+ const formBox = await form.boundingBox();
+ const viewportWidth = await page.evaluate(() => window.innerWidth);
+
+ if (formBox) {
+ // Form should fit within viewport
+ expect(
+ formBox.x + formBox.width,
+ 'Form should fit within viewport'
+ ).toBeLessThanOrEqual(viewportWidth + 5);
+
+ // Form should have some margin (be centered, not flush to edge)
+ expect(formBox.x, 'Form should not be flush to left edge').toBeGreaterThanOrEqual(0);
+ }
+ }
+ });
+
+ test('password inputs properly sized on mobile', async ({ page, isMobile }, testInfo) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ const isTablet = testInfo.project.name.includes('iPad');
+ if (isTablet) {
+ test.skip();
+ return;
+ }
+
+ const passwordInputs = page.locator('input[type="password"]:visible');
+ const count = await passwordInputs.count();
+
+ for (let i = 0; i < count; i++) {
+ const input = passwordInputs.nth(i);
+ const box = await input.boundingBox().catch(() => null);
+
+ if (box) {
+ // Password inputs should be at least 44px tall for touch
+ expect(box.height, `Password input ${i} height >= 44px`).toBeGreaterThanOrEqual(MIN_TOUCH_TARGET);
+
+ // Font size >= 16px to prevent iOS auto-zoom
+ const fontSize = await input.evaluate((el) =>
+ parseFloat(window.getComputedStyle(el).fontSize)
+ );
+ expect(fontSize, `Password input ${i} font size >= 16px`).toBeGreaterThanOrEqual(16);
+ }
+ }
+ });
+
+ test('has no horizontal overflow', async ({ page }) => {
+ const hasOverflow = await page.evaluate(() =>
+ document.documentElement.scrollWidth > window.innerWidth
+ );
+
+ expect(hasOverflow, 'Change password page should have no horizontal overflow').toBe(false);
+ });
+
+ test('mobile screenshot', async ({ page, isMobile }) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ await ensureSheetsClosed(page);
+ await page.evaluate(() => window.scrollTo(0, 0));
+ await page.waitForTimeout(200);
+
+ await expect(page).toHaveScreenshot('change-password-mobile.png', {
+ fullPage: false,
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+
+ test('desktop screenshot', async ({ page, isMobile }) => {
+ if (isMobile) {
+ test.skip();
+ return;
+ }
+
+ await page.setViewportSize({ width: 1200, height: 800 });
+ await page.goto('/auth/change-password');
+ await page.waitForLoadState('domcontentloaded');
+ await page.waitForTimeout(500);
+
+ await expect(page).toHaveScreenshot('change-password-desktop.png', {
+ maxDiffPixelRatio: 0.02,
+ });
+ });
+});