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(mobile): add comprehensive mobile UI tests and fix nav overlap

LearningCircuitace9af09e7a4
diff --git a/src/local_deep_research/web/static/css/mobile-responsive.css b/src/local_deep_research/web/static/css/mobile-responsive.css
index 3d5fd33d9f..2b9638406b 100644
--- a/src/local_deep_research/web/static/css/mobile-responsive.css
+++ b/src/local_deep_research/web/static/css/mobile-responsive.css
@@ -763,6 +763,45 @@
.ldr-subscriptions-grid {
padding-bottom: 80px;
}
+
+ /* Settings page - ensure community note and links are above mobile nav */
+ .ldr-page#settings,
+ .ldr-settings-container {
+ padding-bottom: 120px !important;
+ }
+
+ .ldr-community-note {
+ margin-bottom: 100px !important;
+ }
+
+ .ldr-settings-form {
+ padding-bottom: 100px !important;
+ }
+
+ /* Library page - ensure footer content is above mobile nav */
+ /* Note: These target existing classes in library.html that predate ldr- prefix convention */
+ [class~="library-container"] {
+ padding-bottom: 120px !important;
+ }
+
+ [class~="library-container"] [class~="documents-grid"] {
+ padding-bottom: 80px !important;
+ }
+
+ [class~="library-container"] [class~="empty-state"] {
+ margin-bottom: 100px !important;
+ }
+
+ /* Library filters need extra spacing */
+ [class~="filters-section"] {
+ margin-bottom: 1rem;
+ }
+
+ /* Ensure modals don't appear behind the mobile nav */
+ #pdf-modal,
+ #text-modal {
+ z-index: 3000 !important;
+ }
}
/* 24. Fix Download Manager page for mobile */
diff --git a/src/local_deep_research/web/static/css/settings-mobile-fix.css b/src/local_deep_research/web/static/css/settings-mobile-fix.css
index f5d82013f1..34774ab6b7 100644
--- a/src/local_deep_research/web/static/css/settings-mobile-fix.css
+++ b/src/local_deep_research/web/static/css/settings-mobile-fix.css
@@ -17,30 +17,30 @@
/* Fix extreme height issue on mobile devices */
@media screen and (max-width: 768px) {
- /* Main container height constraints */
+ /* Main container - allow natural height expansion */
.ldr-settings-container {
- max-height: 100vh;
- overflow-y: auto;
+ max-height: none !important;
+ overflow: visible;
-webkit-overflow-scrolling: touch;
}
- /* Fix main content height on mobile */
+ /* Fix main content height on mobile - allow expansion */
.ldr-main-content {
height: auto !important;
- max-height: calc(100vh - 60px); /* Account for mobile nav bar */
- overflow-y: auto;
+ max-height: none !important;
+ overflow: visible;
}
- /* Settings page specific */
+ /* Settings page specific - allow natural height */
#settings {
height: auto !important;
- max-height: 100%;
+ max-height: none !important;
}
- /* Card content should scroll */
+ /* Card content - allow natural height */
.ldr-card {
- max-height: calc(100vh - 120px);
- overflow-y: auto;
+ max-height: none !important;
+ overflow: visible;
}
/* Form should not expand infinitely */
@@ -79,19 +79,19 @@
font-size: 16px; /* Prevent iOS zoom */
}
- /* Fix body overflow */
+ /* Fix body overflow - allow scrolling beyond viewport */
body {
overflow-x: hidden;
overflow-y: auto;
- height: 100vh;
+ min-height: 100vh;
position: relative;
}
- /* Ensure page doesn't expand beyond viewport */
+ /* Let page expand naturally - removed max-height constraint that caused overlap with mobile nav */
.ldr-page {
min-height: auto !important;
- max-height: calc(100vh - 60px);
- overflow-y: auto;
+ max-height: none !important;
+ overflow: visible;
}
}
@@ -111,6 +111,71 @@
}
}
+/* Fix for content behind mobile navigation on small screens */
+@media screen and (max-width: 767px) {
+ /* Ensure Settings page has enough bottom padding for mobile nav */
+ #settings,
+ .ldr-page#settings {
+ padding-bottom: 100px !important;
+ }
+
+ /* Page header needs extra bottom margin to stay above nav when page is short */
+ #settings .ldr-page-header {
+ margin-bottom: 2rem;
+ }
+
+ /* Community note specifically needs margin from bottom */
+ #settings .ldr-community-note {
+ margin-bottom: 100px !important;
+ }
+
+ /* Settings form container needs bottom padding */
+ #settings .ldr-card {
+ margin-bottom: 100px !important;
+ }
+
+ /* Remove restrictive max-height that prevents proper scrolling */
+ #settings,
+ #settings .ldr-settings-container,
+ #settings .ldr-card {
+ max-height: none !important;
+ overflow: visible !important;
+ }
+
+ /* Add a spacer after the settings container to push content above nav */
+ #settings .ldr-settings-container::after {
+ content: '';
+ display: block;
+ height: 120px;
+ width: 100%;
+ }
+
+ /* Ensure loading state also has spacer */
+ #settings-content {
+ min-height: 200px;
+ }
+
+ /* Mobile nav spacer - adds space below content to keep it above mobile nav */
+ .ldr-mobile-nav-spacer {
+ display: block;
+ height: 120px;
+ width: 100%;
+ flex-shrink: 0;
+ }
+
+ /* Extra spacer at end of settings content */
+ .ldr-settings-end-spacer {
+ height: 150px !important;
+ }
+}
+
+/* Hide spacer on desktop */
+@media screen and (min-width: 768px) {
+ .ldr-mobile-nav-spacer {
+ display: none;
+ }
+}
+
/* Mobile touch target improvements */
@media screen and (max-width: 768px) {
/* Make help/support links touch-friendly */
diff --git a/src/local_deep_research/web/templates/settings_dashboard.html b/src/local_deep_research/web/templates/settings_dashboard.html
index 429d940160..a2a63ec35c 100644
--- a/src/local_deep_research/web/templates/settings_dashboard.html
+++ b/src/local_deep_research/web/templates/settings_dashboard.html
@@ -50,6 +50,9 @@
</p>
</div>
+ <!-- Mobile navigation spacer - ensures page content doesn't overlap mobile nav -->
+ <div class="ldr-mobile-nav-spacer" aria-hidden="true"></div>
+
{% if not has_encryption %}
<div class="ldr-alert ldr-alert-warning">
<i class="fas fa-exclamation-triangle"></i> <strong>Security Warning:</strong>
@@ -123,6 +126,9 @@
</form>
</div>
</div>
+
+ <!-- Mobile navigation spacer at end of content -->
+ <div class="ldr-mobile-nav-spacer ldr-settings-end-spacer" aria-hidden="true"></div>
</div>
</div>
{% endblock %}
diff --git a/tests/ui_tests/playwright/playwright.config.js b/tests/ui_tests/playwright/playwright.config.js
index 80fc777362..50286b8e7a 100644
--- a/tests/ui_tests/playwright/playwright.config.js
+++ b/tests/ui_tests/playwright/playwright.config.js
@@ -6,12 +6,16 @@
* - Multiple mobile device profiles
* - Cross-browser testing (Chromium, Firefox, WebKit/Safari)
* - Parallel execution for faster CI runs
+ * - Single authentication to avoid rate limiting
*
* Migration from Puppeteer: This provides the "real" testing
* that Puppeteer emulation cannot deliver.
*/
import { defineConfig, devices } from '@playwright/test';
+import path from 'path';
+
+const authFile = path.join(__dirname, '.auth/user.json');
/**
* See https://playwright.dev/docs/test-configuration
@@ -55,6 +59,17 @@ export default defineConfig({
/* Configure projects for major browsers and mobile devices */
projects: [
+ // ==========================================
+ // AUTHENTICATION SETUP (runs first)
+ // ==========================================
+ {
+ name: 'setup',
+ testMatch: /auth\.setup\.js/,
+ use: {
+ ...devices['Desktop Chrome'],
+ },
+ },
+
// ==========================================
// MOBILE DEVICES - Primary Testing Targets
// ==========================================
@@ -62,53 +77,63 @@ export default defineConfig({
// Small iPhones (most constrained viewport)
{
name: 'iPhone SE',
+ dependencies: ['setup'],
use: {
...devices['iPhone SE'],
// Additional settings for thorough testing
hasTouch: true,
isMobile: true,
+ storageState: authFile,
},
},
// Standard iPhone (most popular)
{
name: 'iPhone 14',
+ dependencies: ['setup'],
use: {
...devices['iPhone 14'],
hasTouch: true,
isMobile: true,
+ storageState: authFile,
},
},
// Large iPhone (Pro Max)
{
name: 'iPhone 14 Pro Max',
+ dependencies: ['setup'],
use: {
...devices['iPhone 14 Pro Max'],
hasTouch: true,
isMobile: true,
+ storageState: authFile,
},
},
// Android - Small (budget phones)
{
name: 'Pixel 5',
+ dependencies: ['setup'],
use: {
...devices['Pixel 5'],
hasTouch: true,
isMobile: true,
+ storageState: authFile,
},
},
// Android - Large (Samsung Galaxy)
{
name: 'Galaxy S23',
+ dependencies: ['setup'],
use: {
viewport: { width: 360, height: 780 },
deviceScaleFactor: 3,
hasTouch: true,
isMobile: true,
userAgent: 'Mozilla/5.0 (Linux; Android 13; SM-S911B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
+ storageState: authFile,
},
},
@@ -118,19 +143,23 @@ export default defineConfig({
{
name: 'iPad Mini',
+ dependencies: ['setup'],
use: {
...devices['iPad Mini'],
hasTouch: true,
isMobile: true,
+ storageState: authFile,
},
},
{
name: 'iPad Pro 11',
+ dependencies: ['setup'],
use: {
...devices['iPad Pro 11'],
hasTouch: true,
isMobile: true,
+ storageState: authFile,
},
},
@@ -140,19 +169,23 @@ export default defineConfig({
{
name: 'iPhone SE Landscape',
+ dependencies: ['setup'],
use: {
...devices['iPhone SE landscape'],
hasTouch: true,
isMobile: true,
+ storageState: authFile,
},
},
{
name: 'iPhone 14 Landscape',
+ dependencies: ['setup'],
use: {
...devices['iPhone 14 landscape'],
hasTouch: true,
isMobile: true,
+ storageState: authFile,
},
},
@@ -162,17 +195,29 @@ export default defineConfig({
{
name: 'Desktop Chrome',
- use: { ...devices['Desktop Chrome'] },
+ dependencies: ['setup'],
+ use: {
+ ...devices['Desktop Chrome'],
+ storageState: authFile,
+ },
},
{
name: 'Desktop Firefox',
- use: { ...devices['Desktop Firefox'] },
+ dependencies: ['setup'],
+ use: {
+ ...devices['Desktop Firefox'],
+ storageState: authFile,
+ },
},
{
name: 'Desktop Safari',
- use: { ...devices['Desktop Safari'] },
+ dependencies: ['setup'],
+ use: {
+ ...devices['Desktop Safari'],
+ storageState: authFile,
+ },
},
// ==========================================
@@ -181,9 +226,11 @@ export default defineConfig({
{
name: 'Mobile Safari',
+ dependencies: ['setup'],
use: {
...devices['iPhone 14'],
browserName: 'webkit', // This uses WebKit, closer to real Safari
+ storageState: authFile,
},
},
],
diff --git a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js
new file mode 100644
index 0000000000..f8add386d0
--- /dev/null
+++ b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js
@@ -0,0 +1,356 @@
+/**
+ * All Pages Mobile Layout Tests
+ *
+ * Comprehensive mobile UI tests for all major pages in the application.
+ * Tests are designed to identify layout issues on mobile devices:
+ * - Horizontal overflow
+ * - Hidden content behind mobile navigation
+ * - Touch target sizing
+ * - Mobile navigation visibility
+ * - Sidebar behavior
+ *
+ * Pages tested (in priority order):
+ * 1. / - Research (Home)
+ * 2. /history/ - History
+ * 3. /settings/ - Settings
+ * 4. /news/ - News Feed
+ * 5. /library/ - Library
+ * 6. /metrics/ - Metrics Dashboard
+ *
+ * Note: Authentication is handled by auth.setup.js via storageState
+ */
+
+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';
+
+// Pages to test
+const PAGES = [
+ { path: '/', name: 'Research (Home)', priority: 'high' },
+ { path: '/history/', name: 'History', priority: 'high' },
+ { path: '/settings/', name: 'Settings', priority: 'high' },
+ { path: '/news/', name: 'News Feed', priority: 'high' },
+ { path: '/library/', name: 'Library', priority: 'high' },
+ { path: '/metrics/', name: 'Metrics Dashboard', priority: 'high' },
+];
+
+// ============================================
+// HORIZONTAL OVERFLOW TESTS
+// ============================================
+
+test.describe('All Pages - No Horizontal Overflow', () => {
+ for (const pageInfo of PAGES) {
+ test(`${pageInfo.name} has no horizontal overflow`, async ({ page }) => {
+ await page.goto(pageInfo.path);
+ await page.waitForLoadState('networkidle');
+
+ const hasOverflow = await page.evaluate(() =>
+ document.documentElement.scrollWidth > window.innerWidth
+ );
+
+ if (hasOverflow) {
+ // Get information about what's causing overflow
+ 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,
+ id: el.id,
+ width: Math.round(rect.width),
+ right: Math.round(rect.right),
+ overflow: Math.round(rect.right - window.innerWidth),
+ });
+ }
+ });
+ return elements.slice(0, 5); // Return first 5 overflowing elements
+ });
+ console.log('Overflowing elements:', JSON.stringify(overflowInfo, null, 2));
+ }
+
+ expect(hasOverflow, `${pageInfo.name} should have no horizontal overflow`).toBe(false);
+ });
+ }
+});
+
+// ============================================
+// MOBILE NAVIGATION VISIBILITY TESTS
+// ============================================
+
+test.describe('All Pages - Mobile Navigation', () => {
+ for (const pageInfo of PAGES) {
+ test(`${pageInfo.name} shows mobile nav on mobile`, async ({ page, isMobile }) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ await page.goto(pageInfo.path);
+ await page.waitForLoadState('networkidle');
+
+ const mobileNav = page.locator(MOBILE_NAV_SELECTOR);
+ await expect(mobileNav, `Mobile nav should be visible on ${pageInfo.name}`).toBeVisible();
+ });
+ }
+});
+
+// ============================================
+// SIDEBAR HIDDEN ON MOBILE TESTS
+// ============================================
+
+test.describe('All Pages - Sidebar Hidden on Mobile', () => {
+ for (const pageInfo of PAGES) {
+ test(`${pageInfo.name} hides sidebar on mobile`, async ({ page, isMobile }) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ await page.goto(pageInfo.path);
+ await page.waitForLoadState('networkidle');
+
+ const sidebar = page.locator(SIDEBAR_SELECTOR);
+
+ // Check if sidebar exists
+ if ((await sidebar.count()) > 0) {
+ // Sidebar should not be visible on mobile (either hidden or collapsed)
+ const isVisible = await sidebar.isVisible();
+ const sidebarBox = isVisible ? await sidebar.boundingBox() : null;
+
+ // Sidebar might be "visible" but positioned off-screen or collapsed to 0 width
+ if (isVisible && sidebarBox) {
+ expect(
+ sidebarBox.width,
+ `Sidebar on ${pageInfo.name} should be collapsed or hidden`
+ ).toBeLessThanOrEqual(0);
+ }
+ }
+ });
+ }
+});
+
+// ============================================
+// TOUCH TARGET SIZE TESTS
+// ============================================
+
+test.describe('All Pages - Touch Targets', () => {
+ for (const pageInfo of PAGES) {
+ test(`${pageInfo.name} has adequate touch targets`, async ({ page, isMobile }) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ await page.goto(pageInfo.path);
+ await page.waitForLoadState('networkidle');
+
+ 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);
+
+ // Skip hidden elements
+ if (style.display === 'none' || style.visibility === 'hidden') return;
+ if (rect.width === 0 || rect.height === 0) return;
+
+ // Skip elements that are off-screen
+ 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),
+ id: el.id,
+ size: `${Math.round(rect.width)}x${Math.round(rect.height)}`,
+ text: (el.textContent || '').trim().slice(0, 30),
+ });
+ }
+ });
+
+ return issues;
+ }, MIN_TOUCH_TARGET);
+
+ // Log issues for debugging but allow some small elements
+ if (smallTargets.length > 0) {
+ console.log(
+ `Small touch targets on ${pageInfo.name}:`,
+ JSON.stringify(smallTargets, null, 2)
+ );
+ }
+
+ // Allow up to 10 small elements (some icons may be small but have large hit areas)
+ expect(
+ smallTargets.length,
+ `${pageInfo.name} should have minimal small touch targets`
+ ).toBeLessThan(10);
+ });
+ }
+});
+
+// ============================================
+// CONTENT NOT BEHIND MOBILE NAV TESTS
+// ============================================
+
+test.describe('All Pages - Content Above Mobile Nav', () => {
+ for (const pageInfo of PAGES) {
+ test(`${pageInfo.name} content not hidden behind mobile nav`, async ({ page, isMobile }) => {
+ if (!isMobile) {
+ test.skip();
+ return;
+ }
+
+ await page.goto(pageInfo.path);
+ await page.waitForLoadState('networkidle');
+
+ // Wait for page-specific content to load
+ if (pageInfo.path === '/settings/') {
+ // Wait for settings to load (spinner to disappear)
+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});
+ await page.waitForTimeout(500);
+ }
+
+ // Scroll to bottom to check last content
+ await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
+ await page.waitForTimeout(300); // Wait for scroll to complete
+
+ const result = await page.evaluate((navSelector) => {
+ const mobileNav = document.querySelector(navSelector);
+ if (!mobileNav) return { hasNav: false, issue: null };
+
+ const navStyle = window.getComputedStyle(mobileNav);
+ if (navStyle.display === 'none') return { hasNav: false, issue: null };
+
+ const navRect = mobileNav.getBoundingClientRect();
+
+ // Find interactive elements that might be hidden behind the nav
+ 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);
+
+ // Skip hidden elements
+ if (style.display === 'none' || style.visibility === 'hidden') return;
+ if (rect.width === 0 || rect.height === 0) return;
+
+ // Check if element is behind the nav
+ if (rect.bottom > navRect.top && rect.top < navRect.bottom) {
+ // Element overlaps with nav vertically
+ // Check if it's not part of the nav itself
+ if (!mobileNav.contains(el)) {
+ hiddenElements.push({
+ tag: el.tagName.toLowerCase(),
+ class: el.className?.toString().slice(0, 50),
+ text: (el.textContent || '').trim().slice(0, 30),
+ bottom: Math.round(rect.bottom),
+ navTop: Math.round(navRect.top),
+ });
+ }
+ }
+ });
+
+ return {
+ hasNav: true,
+ navTop: navRect.top,
+ hiddenElements: hiddenElements.slice(0, 5),
+ };
+ }, MOBILE_NAV_SELECTOR);
+
+ if (result.hasNav && result.hiddenElements && result.hiddenElements.length > 0) {
+ console.log(
+ `Elements hidden behind nav on ${pageInfo.name}:`,
+ JSON.stringify(result.hiddenElements, null, 2)
+ );
+ }
+
+ expect(
+ result.hiddenElements?.length || 0,
+ `${pageInfo.name} should have no interactive elements behind mobile nav`
+ ).toBe(0);
+ });
+ }
+});
+
+// ============================================
+// PAGE LOAD AND BASIC FUNCTIONALITY TESTS
+// ============================================
+
+test.describe('All Pages - Basic Load Tests', () => {
+ for (const pageInfo of PAGES) {
+ test(`${pageInfo.name} loads without errors`, async ({ page }) => {
+ // Collect console errors
+ const errors = [];
+ page.on('console', (msg) => {
+ if (msg.type() === 'error') {
+ errors.push(msg.text());
+ }
+ });
+
+ // Collect page errors
+ const pageErrors = [];
+ page.on('pageerror', (error) => {
+ pageErrors.push(error.message);
+ });
+
+ await page.goto(pageInfo.path);
+ await page.waitForLoadState('networkidle');
+
+ // Filter out known benign errors
+ const criticalErrors = errors.filter(
+ (err) =>
+ !err.includes('favicon') &&
+ !err.includes('404') &&
+ !err.includes('Failed to load resource')
+ );
+
+ expect(pageErrors.length, `${pageInfo.name} should have no page errors`).toBe(0);
+ expect(
+ criticalErrors.length,
+ `${pageInfo.name} should have no critical console errors: ${criticalErrors.join(', ')}`
+ ).toBe(0);
+ });
+ }
+});
+
+// ============================================
+// VISUAL SCREENSHOT TESTS
+// ============================================
+
+test.describe('All Pages - Visual Regression', () => {
+ for (const pageInfo of PAGES) {
+ test(`${pageInfo.name} screenshot`, async ({ page }) => {
+ await page.goto(pageInfo.path);
+ await page.waitForLoadState('networkidle');
+
+ // Wait for any animations to complete
+ await page.waitForTimeout(500);
+
+ // Generate a filename-safe name
+ const safeName = pageInfo.name.toLowerCase().replace(/[^a-z0-9]/g, '-');
+
+ // Check page height - skip full-page screenshots for very tall pages
+ // Screenshots larger than 32767 pixels will fail
+ const pageHeight = await page.evaluate(() => document.body.scrollHeight);
+ const useFullPage = pageHeight < 30000;
+
+ await expect(page).toHaveScreenshot(`${safeName}.png`, {
+ fullPage: useFullPage,
+ maxDiffPixelRatio: 0.02, // Allow 2% difference for anti-aliasing
+ });
+ });
+ }
+});
diff --git a/tests/ui_tests/playwright/tests/auth.setup.js b/tests/ui_tests/playwright/tests/auth.setup.js
new file mode 100644
index 0000000000..eef64c3948
--- /dev/null
+++ b/tests/ui_tests/playwright/tests/auth.setup.js
@@ -0,0 +1,36 @@
+/**
+ * Authentication Setup for Playwright Tests
+ *
+ * This file handles authentication once and saves the session state
+ * so subsequent tests can reuse it without logging in again.
+ * This prevents rate limiting issues from multiple login attempts.
+ */
+
+import { test as setup, expect } from '@playwright/test';
+import path from 'path';
+
+const TEST_USERNAME = process.env.TEST_USERNAME || 'test_admin';
+const TEST_PASSWORD = process.env.TEST_PASSWORD || 'testpass123';
+
+const authFile = path.join(__dirname, '../.auth/user.json');
+
+setup('authenticate', async ({ page }) => {
+ // Navigate to login page
+ await page.goto('/auth/login');
+
+ // Fill in credentials
+ await page.fill('input[name="username"]', TEST_USERNAME);
+ await page.fill('input[name="password"]', TEST_PASSWORD);
+
+ // Submit the form
+ await page.click('button[type="submit"]');
+
+ // Wait for navigation to complete (authentication successful)
+ await page.waitForURL('/', { timeout: 60000 });
+
+ // Verify we're logged in by checking for presence of main content
+ await expect(page.locator('body')).toBeVisible();
+
+ // Save the authentication state
+ await page.context().storageState({ path: authFile });
+});
diff --git a/tests/ui_tests/playwright/tests/helpers/auth.js b/tests/ui_tests/playwright/tests/helpers/auth.js
new file mode 100644
index 0000000000..679a1eac04
--- /dev/null
+++ b/tests/ui_tests/playwright/tests/helpers/auth.js
@@ -0,0 +1,23 @@
+/**
+ * Authentication Helper for Playwright Tests
+ *
+ * Shared authentication utilities for all test files.
+ * Credentials can be overridden via environment variables.
+ */
+
+const TEST_USERNAME = process.env.TEST_USERNAME || 'test_admin';
+const TEST_PASSWORD = process.env.TEST_PASSWORD || 'testpass123';
+
+/**
+ * Authenticate a page by logging in with test credentials
+ * @param {import('@playwright/test').Page} page - Playwright page object
+ */
+async function authenticate(page) {
+ await page.goto('/auth/login');
+ await page.fill('input[name="username"]', TEST_USERNAME);
+ await page.fill('input[name="password"]', TEST_PASSWORD);
+ await page.click('button[type="submit"]');
+ await page.waitForURL('/', { timeout: 30000 });
+}
+
+module.exports = { authenticate, TEST_USERNAME, TEST_PASSWORD };
diff --git a/tests/ui_tests/playwright/tests/research-page.spec.js b/tests/ui_tests/playwright/tests/research-page.spec.js
index ff0c15adfa..0c5769df41 100644
--- a/tests/ui_tests/playwright/tests/research-page.spec.js
+++ b/tests/ui_tests/playwright/tests/research-page.spec.js
@@ -10,6 +10,8 @@
* 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
+ *
+ * Note: Authentication is handled by auth.setup.js via storageState
*/
import { test, expect } from '@playwright/test';
@@ -20,32 +22,17 @@ const MIN_ELEMENT_SPACING = 8;
const MIN_TOUCH_TARGET = 44;
const MIN_NAV_CLEARANCE = 16;
-// Credentials from environment variables (set in CI or local .env)
-const TEST_USERNAME = process.env.TEST_USERNAME || 'test_admin';
-const TEST_PASSWORD = process.env.TEST_PASSWORD || 'testpass123';
-
-// Helper to authenticate
-async function authenticate(page) {
- await page.goto('/auth/login');
- await page.fill('input[name="username"]', TEST_USERNAME);
- await page.fill('input[name="password"]', TEST_PASSWORD);
- await page.click('button[type="submit"]');
- await page.waitForURL('/', { timeout: 10000 });
-}
-
// ============================================
// VISUAL REGRESSION TESTS
// ============================================
test.describe('Research Page - Visual Regression', () => {
test.beforeEach(async ({ page }) => {
- await authenticate(page);
- });
-
- test('full page screenshot matches baseline', 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' });
@@ -59,9 +46,6 @@ test.describe('Research Page - Visual Regression', () => {
});
test('bottom section screenshot matches baseline', async ({ page }) => {
- await page.goto('/');
- await page.waitForLoadState('networkidle');
-
// Scroll to bottom to capture the "mashed together" area
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
// Allow scroll animation to complete
@@ -73,9 +57,6 @@ test.describe('Research Page - Visual Regression', () => {
});
test('form actions area screenshot', async ({ page }) => {
- await page.goto('/');
- await page.waitForLoadState('networkidle');
-
// Capture just the form actions area
const formActions = page.locator('.ldr-form-actions');
if (await formActions.count() > 0) {
@@ -90,7 +71,6 @@ test.describe('Research Page - Visual Regression', () => {
test.describe('Research Page - Element Spacing', () => {
test.beforeEach(async ({ page }) => {
- await authenticate(page);
await page.goto('/');
await page.waitForLoadState('networkidle');
});
@@ -176,7 +156,6 @@ test.describe('Research Page - Element Spacing', () => {
test.describe('Research Page - Touch Targets', () => {
test.beforeEach(async ({ page }) => {
- await authenticate(page);
await page.goto('/');
await page.waitForLoadState('networkidle');
});
@@ -241,7 +220,6 @@ test.describe('Research Page - Touch Targets', () => {
test.describe('Research Page - Mobile Nav Clearance', () => {
test.beforeEach(async ({ page }) => {
- await authenticate(page);
await page.goto('/');
await page.waitForLoadState('networkidle');
// Wait for mobile nav to initialize (if present)
@@ -318,7 +296,6 @@ test.describe('Research Page - Mobile Nav Clearance', () => {
test.describe('Research Page - Scrollability', () => {
test.beforeEach(async ({ page }) => {
- await authenticate(page);
await page.goto('/');
await page.waitForLoadState('networkidle');
});
@@ -355,7 +332,6 @@ test.describe('Research Page - Scrollability', () => {
test.describe('Research Page - Advanced Options', () => {
test.beforeEach(async ({ page }) => {
- await authenticate(page);
await page.goto('/');
await page.waitForLoadState('networkidle');
});