~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): convert audit tests to hard failures and add breakpoint/orientation tests
LearningCircuit84b13979167a
diff --git a/tests/ui_tests/playwright/tests/breakpoint-edge-cases.spec.js b/tests/ui_tests/playwright/tests/breakpoint-edge-cases.spec.jsnew file mode 100644index 0000000000..d956a9673d--- /dev/null+++ b/tests/ui_tests/playwright/tests/breakpoint-edge-cases.spec.js@@ -0,0 +1,280 @@+/**+ * Breakpoint Edge Case Tests+ *+ * Tests layout behavior at CSS breakpoint boundaries to catch+ * edge cases where layout transitions between mobile, tablet, and desktop.+ *+ * Breakpoints tested:+ * - 767px: Mobile max (mobile nav visible, sidebar hidden)+ * - 768px: Tablet min (mobile nav hidden, sidebar 60px)+ * - 991px: Tablet max (sidebar 60px)+ * - 992px: Desktop min (sidebar 240px)+ * - 380px: Extra small (single column, icons hidden)+ */++import { test, expect } from '@playwright/test';+const { BREAKPOINTS, PAGES } = require('./helpers/mobile-utils');++test.describe('Breakpoint Edge Cases - Mobile Nav Boundary', () => {+ // Split into individual tests for better isolation and parallelization+ test('Mobile nav visible at 766px', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: { width: 766, height: 800 },+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();+ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const mobileNav = page.locator('.ldr-mobile-bottom-nav');+ await expect(mobileNav, 'Mobile nav visible at 766px').toBeVisible();+ await context.close();+ });++ test('Mobile nav visible at 767px (mobile max)', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: { width: 767, height: 800 },+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();+ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const mobileNav = page.locator('.ldr-mobile-bottom-nav');+ await expect(mobileNav, 'Mobile nav visible at 767px').toBeVisible();+ await context.close();+ });++ test('Mobile nav hidden at 768px (tablet min)', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: { width: 768, height: 800 },+ isMobile: false,+ hasTouch: true,+ });+ const page = await context.newPage();+ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const mobileNav = page.locator('.ldr-mobile-bottom-nav');+ await expect(mobileNav, 'Mobile nav hidden at 768px').not.toBeVisible();+ await context.close();+ });++ test('Mobile nav hidden at 769px', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: { width: 769, height: 800 },+ isMobile: false,+ hasTouch: true,+ });+ const page = await context.newPage();+ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const mobileNav = page.locator('.ldr-mobile-bottom-nav');+ await expect(mobileNav, 'Mobile nav hidden at 769px').not.toBeVisible();+ await context.close();+ });+});++test.describe('Breakpoint Edge Cases - Sidebar Width', () => {+ test('Sidebar width at breakpoints', async ({ browser }) => {+ const tests = [+ { width: 767, expectedSidebar: 0, desc: 'Hidden on mobile' },+ { width: 850, expectedSidebar: 60, desc: 'Collapsed on tablet' },+ { width: 992, expectedSidebar: 240, desc: 'Full on desktop' },+ ];++ for (const { width, expectedSidebar, desc } of tests) {+ const context = await browser.newContext({+ viewport: { width, height: 800 },+ isMobile: width <= BREAKPOINTS.MOBILE_MAX,+ });+ const page = await context.newPage();+ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const sidebar = page.locator('.ldr-sidebar');++ if (expectedSidebar === 0) {+ // Sidebar should be hidden or have 0 width+ const isVisible = await sidebar.isVisible();+ if (isVisible) {+ const box = await sidebar.boundingBox();+ expect(box?.width ?? 0, `${desc}: Sidebar width at ${width}px`).toBe(0);+ }+ } else {+ const isVisible = await sidebar.isVisible();+ if (isVisible) {+ const box = await sidebar.boundingBox();+ // Allow some tolerance (±5px) for different CSS implementations+ expect(box?.width, `${desc}: Sidebar width at ${width}px`).toBeGreaterThanOrEqual(expectedSidebar - 5);+ expect(box?.width, `${desc}: Sidebar width at ${width}px`).toBeLessThanOrEqual(expectedSidebar + 5);+ }+ }++ await context.close();+ }+ });+});++test.describe('Breakpoint Edge Cases - No Overflow', () => {+ const pagesToTest = ['/', '/history/', '/settings/', '/metrics/'];+ const widthsToTest = [380, 767, 768, 991];++ for (const path of pagesToTest) {+ for (const width of widthsToTest) {+ test(`${path} no overflow at ${width}px`, async ({ browser }) => {+ const context = await browser.newContext({+ viewport: { width, height: 800 },+ isMobile: width <= BREAKPOINTS.MOBILE_MAX,+ hasTouch: true,+ });+ const page = await context.newPage();+ await page.goto(path);+ await page.waitForLoadState('networkidle');++ // Wait for settings spinner to disappear if on settings page+ if (path === '/settings/') {+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});+ await page.waitForTimeout(500);+ }++ const hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );++ expect(hasOverflow, `No horizontal overflow at ${width}px`).toBe(false);+ await context.close();+ });+ }+ }+});++test.describe('Breakpoint Edge Cases - Content Layout', () => {+ test('Extra small (380px) shows single column layout', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: { width: 380, height: 800 },+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();+ await page.goto('/');+ await page.waitForLoadState('networkidle');++ // Mobile nav should be visible+ const mobileNav = page.locator('.ldr-mobile-bottom-nav');+ await expect(mobileNav, 'Mobile nav visible at 380px').toBeVisible();++ // No horizontal overflow+ const hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'No overflow at 380px').toBe(false);++ await context.close();+ });++ test('Tablet boundary (768px) shows collapsed sidebar', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: { width: 768, height: 800 },+ isMobile: false,+ });+ const page = await context.newPage();+ await page.goto('/');+ await page.waitForLoadState('networkidle');++ // Mobile nav should NOT be visible+ const mobileNav = page.locator('.ldr-mobile-bottom-nav');+ await expect(mobileNav, 'Mobile nav hidden at 768px').not.toBeVisible();++ // Sidebar should be visible (collapsed)+ const sidebar = page.locator('.ldr-sidebar');+ const sidebarVisible = await sidebar.isVisible();+ if (sidebarVisible) {+ const box = await sidebar.boundingBox();+ // Collapsed sidebar is typically around 60px+ expect(box?.width, 'Sidebar collapsed at 768px').toBeLessThanOrEqual(100);+ }++ await context.close();+ });++ test('Desktop boundary (992px) shows full sidebar', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: { width: 992, height: 800 },+ isMobile: false,+ });+ const page = await context.newPage();+ await page.goto('/');+ await page.waitForLoadState('networkidle');++ // Sidebar should be visible and expanded+ const sidebar = page.locator('.ldr-sidebar');+ const sidebarVisible = await sidebar.isVisible();+ if (sidebarVisible) {+ const box = await sidebar.boundingBox();+ // Full sidebar is typically around 240px+ expect(box?.width, 'Sidebar expanded at 992px').toBeGreaterThanOrEqual(200);+ }++ await context.close();+ });+});++test.describe('Breakpoint Edge Cases - Touch Targets at Boundaries', () => {+ test('Touch targets adequate at 767px (mobile max)', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: { width: 767, height: 800 },+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();+ await page.goto('/');+ await page.waitForLoadState('networkidle');++ // Check mobile nav touch targets+ const navItems = page.locator('.ldr-mobile-bottom-nav a, .ldr-mobile-bottom-nav button');+ const count = await navItems.count();++ for (let i = 0; i < count; i++) {+ const item = navItems.nth(i);+ if (await item.isVisible()) {+ const box = await item.boundingBox();+ expect(box?.height, `Nav item ${i} height >= 44px at 767px`).toBeGreaterThanOrEqual(44);+ expect(box?.width, `Nav item ${i} width >= 44px at 767px`).toBeGreaterThanOrEqual(44);+ }+ }++ await context.close();+ });++ test('Touch targets adequate at 768px (tablet min)', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: { width: 768, height: 800 },+ isMobile: false,+ hasTouch: true,+ });+ const page = await context.newPage();+ await page.goto('/');+ await page.waitForLoadState('networkidle');++ // Check sidebar nav touch targets (if visible)+ const sidebarItems = page.locator('.ldr-sidebar a, .ldr-sidebar button');+ const count = await sidebarItems.count();++ for (let i = 0; i < Math.min(count, 10); i++) {+ const item = sidebarItems.nth(i);+ if (await item.isVisible()) {+ const box = await item.boundingBox();+ // Sidebar items should still be touchable+ if (box && box.height > 0 && box.width > 0) {+ expect(box.height, `Sidebar item ${i} height >= 40px at 768px`).toBeGreaterThanOrEqual(40);+ }+ }+ }++ await context.close();+ });+});diff --git a/tests/ui_tests/playwright/tests/helpers/mobile-utils.js b/tests/ui_tests/playwright/tests/helpers/mobile-utils.jsindex 63af6073b7..2e65f2c7ab 100644--- a/tests/ui_tests/playwright/tests/helpers/mobile-utils.js+++ b/tests/ui_tests/playwright/tests/helpers/mobile-utils.js@@ -8,11 +8,36 @@// Constantsconst MIN_TOUCH_TARGET = 44;const MIN_ELEMENT_SPACING = 8;+const MIN_BUTTON_SPACING = 8;+const MIN_TEXT_SIZE = 12;const MOBILE_NAV_HEIGHT = 56;const MOBILE_NAV_SELECTOR = '.ldr-mobile-bottom-nav';const SIDEBAR_SELECTOR = '.ldr-sidebar';const SHEET_SELECTOR = '.ldr-mobile-sheet, [class*="sheet"]:not([class*="stylesheet"]), [class*="modal"]:not(.ldr-mode-selection), [class*="drawer"], [role="dialog"]';+// Breakpoints (matches CSS breakpoints)+const BREAKPOINTS = {+ MOBILE_MAX: 767,+ TABLET_MIN: 768,+ TABLET_MAX: 991,+ DESKTOP_MIN: 992,+ EXTRA_SMALL: 380,+};++// Pages to test+const PAGES = [+ { path: '/', name: 'Research' },+ { path: '/history/', name: 'History' },+ { path: '/settings/', name: 'Settings' },+ { path: '/news/', name: 'News Feed' },+ { path: '/library/', name: 'Library' },+ { path: '/metrics/', name: 'Metrics' },+ { path: '/metrics/context-overflow', name: 'Context Overflow' },+ { path: '/metrics/star-reviews', name: 'Star Reviews' },+ { path: '/metrics/costs', name: 'Cost Analytics' },+ { path: '/metrics/links', name: 'Link Analytics' },+];+/*** Remove sheet elements from DOM to prevent bleeding in screenshots.*@@ -61,10 +86,14 @@ function isTablet(testInfo) {module.exports = {MIN_TOUCH_TARGET,MIN_ELEMENT_SPACING,+ MIN_BUTTON_SPACING,+ MIN_TEXT_SIZE,MOBILE_NAV_HEIGHT,MOBILE_NAV_SELECTOR,SIDEBAR_SELECTOR,SHEET_SELECTOR,+ BREAKPOINTS,+ PAGES,ensureSheetsClosed,isTablet,};diff --git a/tests/ui_tests/playwright/tests/mobile-ui-audit.spec.js b/tests/ui_tests/playwright/tests/mobile-ui-audit.spec.jsindex a519171219..e900050f93 100644--- a/tests/ui_tests/playwright/tests/mobile-ui-audit.spec.js+++ b/tests/ui_tests/playwright/tests/mobile-ui-audit.spec.js@@ -1,27 +1,18 @@/*** Mobile UI Audit - Comprehensive Issue Detection*- * This test file generates detailed reports of UI issues- * without strict pass/fail thresholds. Used to identify- * areas needing improvement.+ * This test file detects mobile UI issues with strict pass/fail thresholds.+ * Tests will fail CI when critical issues are found.+ *+ * Thresholds:+ * - Overflowing elements: 0 (zero tolerance - breaks layout)+ * - Missing labels: 0 (accessibility requirement)+ * - Small touch targets: < 4 (allow 3 edge cases per page)+ * - Overlapping elements: < 2 (usability issue)*/import { test, expect } from '@playwright/test';--const MIN_TOUCH_TARGET = 44;--const PAGES = [- { path: '/', name: 'Research' },- { path: '/history/', name: 'History' },- { path: '/settings/', name: 'Settings' },- { path: '/news/', name: 'News Feed' },- { path: '/library/', name: 'Library' },- { path: '/metrics/', name: 'Metrics' },- { path: '/metrics/context-overflow', name: 'Context Overflow' },- { path: '/metrics/star-reviews', name: 'Star Reviews' },- { path: '/metrics/costs', name: 'Cost Analytics' },- { path: '/metrics/links', name: 'Link Analytics' },-];+const { MIN_TOUCH_TARGET, PAGES } = require('./helpers/mobile-utils');// ============================================// DETAILED AUDIT TESTS - Report Issues@@ -192,6 +183,7 @@ test.describe('Mobile UI Audit - Issue Detection', () => {`Stats: ${auditResults.stats.totalButtons} buttons, ${auditResults.stats.totalInputs} inputs, ${auditResults.stats.totalLinks} links`);+ // === SMALL TOUCH TARGETS ===if (auditResults.issues.smallTouchTargets.length > 0) {console.log(`\n⚠️ Small Touch Targets (${auditResults.issues.smallTouchTargets.length}):`);auditResults.issues.smallTouchTargets.forEach((item) => {@@ -199,6 +191,13 @@ test.describe('Mobile UI Audit - Issue Detection', () => {});}+ expect(+ auditResults.issues.smallTouchTargets.length,+ `${pageInfo.name} should have at most 3 small touch targets (found ${auditResults.issues.smallTouchTargets.length}): ` ++ auditResults.issues.smallTouchTargets.slice(0, 5).map(t => `${t.tag}[${t.type}] ${t.size}`).join(', ')+ ).toBeLessThan(4);++ // === SMALL TEXT (diagnostic only - context dependent) ===if (auditResults.issues.smallText.length > 0) {console.log(`\n⚠️ Small Text (${auditResults.issues.smallText.length}):`);auditResults.issues.smallText.forEach((item) => {@@ -206,6 +205,7 @@ test.describe('Mobile UI Audit - Issue Detection', () => {});}+ // === OVERFLOWING ELEMENTS (critical - zero tolerance) ===if (auditResults.issues.overflowingElements.length > 0) {console.log(`\n❌ Overflowing Elements (${auditResults.issues.overflowingElements.length}):`);auditResults.issues.overflowingElements.forEach((item) => {@@ -213,6 +213,12 @@ test.describe('Mobile UI Audit - Issue Detection', () => {});}+ expect(+ auditResults.issues.overflowingElements.length,+ `${pageInfo.name} should have no horizontally overflowing elements`+ ).toBe(0);++ // === MISSING LABELS (accessibility - zero tolerance) ===if (auditResults.issues.missingLabels.length > 0) {console.log(`\n⚠️ Inputs Missing Labels (${auditResults.issues.missingLabels.length}):`);auditResults.issues.missingLabels.forEach((item) => {@@ -220,6 +226,11 @@ test.describe('Mobile UI Audit - Issue Detection', () => {});}+ expect(+ auditResults.issues.missingLabels.length,+ `${pageInfo.name} inputs should have accessible labels`+ ).toBe(0);+console.log('\n' + '='.repeat(50));// Take a screenshot for visual reference@@ -227,9 +238,6 @@ test.describe('Mobile UI Audit - Issue Detection', () => {path: `test-results/audit-${pageInfo.name.toLowerCase().replace(/\s+/g, '-')}.png`,fullPage: false,});-- // This test always passes - it's for reporting only- expect(true).toBe(true);});}});@@ -304,7 +312,19 @@ test.describe('Mobile UI Audit - Specific Elements', () => {});console.log('='.repeat(50));- expect(true).toBe(true);+ // Assert on critical form elements+ const textarea = formElements.find(e => e.name === 'Query Textarea');+ if (textarea) {+ const [width, height] = textarea.size.split('x').map(Number);+ expect(height, 'Query textarea should be at least 80px tall').toBeGreaterThanOrEqual(80);+ expect(textarea.fontSize, 'Query textarea font >= 16px (prevents iOS zoom)').toBeGreaterThanOrEqual(16);+ }++ const startBtn = formElements.find(e => e.name === 'Start Research Button');+ if (startBtn) {+ const [width, height] = startBtn.size.split('x').map(Number);+ expect(height, 'Start button meets touch target minimum').toBeGreaterThanOrEqual(44);+ }});test('Settings page - Settings cards audit', async ({ page, isMobile }) => {@@ -358,7 +378,8 @@ test.describe('Mobile UI Audit - Specific Elements', () => {});console.log('='.repeat(50));- expect(true).toBe(true);+ // Settings should load successfully+ expect(settingsInfo.totalSettings, 'Settings page should have settings loaded').toBeGreaterThan(0);});test('News page - News templates audit', async ({ page, isMobile }) => {@@ -412,7 +433,16 @@ test.describe('Mobile UI Audit - Specific Elements', () => {});console.log('='.repeat(50));- expect(true).toBe(true);+ // Check that action buttons meet touch target requirements+ const smallButtons = newsInfo.actionButtons.filter(b => {+ const [width, height] = b.size.split('x').map(Number);+ return height < 44;+ });++ expect(+ smallButtons.length,+ `News page action buttons should meet 44px touch target`+ ).toBe(0);});test('Metrics page - Dashboard cards audit', async ({ page, isMobile }) => {@@ -465,7 +495,8 @@ test.describe('Mobile UI Audit - Specific Elements', () => {console.log(`\nSections: ${metricsInfo.sections.join(', ')}`);console.log('='.repeat(50));- expect(true).toBe(true);+ // Metrics page should have content+ expect(metricsInfo.pageHeight, 'Metrics page should have content').toBeGreaterThan(0);});});@@ -523,6 +554,20 @@ test.describe('Mobile UI Audit - Navigation', () => {}console.log('='.repeat(50));- expect(navInfo.found).toBe(true);+ // Mobile nav assertions+ expect(navInfo.found, 'Mobile bottom nav should exist').toBe(true);++ if (navInfo.found) {+ expect(navInfo.items.length, 'Mobile nav should have items').toBeGreaterThan(0);+ expect(navInfo.position, 'Mobile nav should be fixed').toBe('fixed');+ expect(navInfo.bottom, 'Mobile nav at bottom').toBe('0px');++ const smallNavItems = navInfo.items.filter(item => {+ const [width, height] = item.size.split('x').map(Number);+ return width < 44 || height < 44;+ });++ expect(smallNavItems.length, 'All nav items should meet 44px touch target').toBe(0);+ }});});diff --git a/tests/ui_tests/playwright/tests/mobile-ui-issues.spec.js b/tests/ui_tests/playwright/tests/mobile-ui-issues.spec.jsindex 8aaa4273e4..070bf0e294 100644--- a/tests/ui_tests/playwright/tests/mobile-ui-issues.spec.js+++ b/tests/ui_tests/playwright/tests/mobile-ui-issues.spec.js@@ -12,24 +12,7 @@*/import { test, expect } from '@playwright/test';--// Test configuration-const MIN_TOUCH_TARGET = 44;-const MIN_BUTTON_SPACING = 8;--// Pages to test-const PAGES = [- { path: '/', name: 'Research' },- { path: '/history/', name: 'History' },- { path: '/settings/', name: 'Settings' },- { path: '/news/', name: 'News Feed' },- { path: '/library/', name: 'Library' },- { path: '/metrics/', name: 'Metrics' },- { path: '/metrics/context-overflow', name: 'Context Overflow' },- { path: '/metrics/star-reviews', name: 'Star Reviews' },- { path: '/metrics/costs', name: 'Cost Analytics' },- { path: '/metrics/links', name: 'Link Analytics' },-];+const { MIN_TOUCH_TARGET, MIN_BUTTON_SPACING, PAGES } = require('./helpers/mobile-utils');// ============================================// SHEET/MODAL OVERLAY TESTS@@ -201,8 +184,8 @@ test.describe('Mobile - Form Elements', () => {console.log('Small input fields found:', JSON.stringify(smallInputs, null, 2));}- // Allow some small inputs (like checkboxes which have larger click areas)- expect(smallInputs.length, 'Most inputs should have adequate touch targets').toBeLessThan(2);+ // Zero tolerance for small inputs - all inputs should have adequate touch targets+ expect(smallInputs.length, 'All inputs should have adequate touch targets').toBe(0);});test('News page - Search input has proper sizing', async ({ page, isMobile }) => {@@ -293,8 +276,8 @@ test.describe('Mobile - Button Spacing', () => {}// Allow some close buttons (like in button groups, filter buttons, etc.)- // Pages with intentional button groups (filters, templates) may have up to 18 close pairs- expect(tooClose.length, 'Most buttons should have adequate spacing').toBeLessThan(18);+ // Tightened threshold from 18 to 10 to catch more regressions+ expect(tooClose.length, 'Most buttons should have adequate spacing').toBeLessThan(10);});}});@@ -847,3 +830,36 @@ test.describe('Mobile - News Page Elements', () => {}});});++// ============================================+// MODAL FOCUS TRAP TESTS+// ============================================++test.describe('Mobile - Modal Focus Trap', () => {+ test('Modal traps focus when open', async ({ page, isMobile }) => {+ if (!isMobile) {+ test.skip();+ return;+ }++ await page.goto('/news/');+ await page.waitForLoadState('networkidle');++ const createBtn = page.locator('#create-subscription-btn');+ if (await createBtn.isVisible()) {+ await createBtn.click();+ await page.waitForTimeout(300);++ // Tab through modal+ await page.keyboard.press('Tab');+ await page.keyboard.press('Tab');+ await page.keyboard.press('Tab');++ // Focus should still be in modal+ const activeInModal = await page.evaluate(() =>+ document.activeElement?.closest('.ldr-modal, [role="dialog"]')+ );+ expect(activeInModal, 'Focus should stay within modal').not.toBeNull();+ }+ });+});diff --git a/tests/ui_tests/playwright/tests/orientation-change.spec.js b/tests/ui_tests/playwright/tests/orientation-change.spec.jsnew file mode 100644index 0000000000..7ec23403e6--- /dev/null+++ b/tests/ui_tests/playwright/tests/orientation-change.spec.js@@ -0,0 +1,378 @@+/**+ * Orientation Change Tests+ *+ * Tests layout behavior when device orientation changes between+ * portrait and landscape modes on various mobile devices.+ *+ * Tested scenarios:+ * - Layout adapts without overflow+ * - Form values preserved through rotation+ * - Navigation visibility at landscape widths+ * - Content remains accessible+ */++import { test, expect } from '@playwright/test';+const { BREAKPOINTS } = require('./helpers/mobile-utils');++// Device dimensions for testing+const DEVICES = {+ IPHONE_SE: {+ portrait: { width: 375, height: 667 },+ landscape: { width: 667, height: 375 },+ },+ IPHONE_14: {+ portrait: { width: 390, height: 844 },+ landscape: { width: 844, height: 390 },+ },+ GALAXY_S23: {+ portrait: { width: 360, height: 780 },+ landscape: { width: 780, height: 360 },+ },+};++test.describe('Orientation Change - Layout Adaptation', () => {+ test('Layout adapts from portrait to landscape', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_14.portrait,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ // Verify no overflow in portrait+ let hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'No overflow in portrait').toBe(false);++ // Rotate to landscape+ await page.setViewportSize(DEVICES.IPHONE_14.landscape);+ await page.waitForTimeout(300);++ // Verify no overflow in landscape+ hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'No overflow in landscape').toBe(false);++ await context.close();+ });++ test('Layout adapts from landscape to portrait', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_14.landscape,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ // Verify no overflow in landscape+ let hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'No overflow in landscape').toBe(false);++ // Rotate to portrait+ await page.setViewportSize(DEVICES.IPHONE_14.portrait);+ await page.waitForTimeout(300);++ // Verify no overflow in portrait+ hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'No overflow in portrait').toBe(false);++ await context.close();+ });+});++test.describe('Orientation Change - Form State Preservation', () => {+ test('Form values preserved through rotation', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_14.portrait,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const textarea = page.locator('#query');+ await textarea.fill('Test query in portrait');++ // Rotate to landscape+ await page.setViewportSize(DEVICES.IPHONE_14.landscape);+ await page.waitForTimeout(300);++ // Value should be preserved+ const value = await textarea.inputValue();+ expect(value, 'Query value preserved after rotation').toBe('Test query in portrait');++ // Rotate back to portrait+ await page.setViewportSize(DEVICES.IPHONE_14.portrait);+ await page.waitForTimeout(300);++ // Value should still be preserved+ const valueAfterReturn = await textarea.inputValue();+ expect(valueAfterReturn, 'Query value preserved after returning to portrait').toBe('Test query in portrait');++ await context.close();+ });++ test('Settings form values preserved through rotation', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_14.portrait,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ 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 text input and fill it+ const textInputs = page.locator('input[type="text"], input[type="number"]');+ const count = await textInputs.count();++ if (count > 0) {+ const firstInput = textInputs.first();+ const originalValue = await firstInput.inputValue();++ // Rotate to landscape+ await page.setViewportSize(DEVICES.IPHONE_14.landscape);+ await page.waitForTimeout(300);++ // Value should be preserved+ const valueAfterRotation = await firstInput.inputValue();+ expect(valueAfterRotation, 'Settings input preserved after rotation').toBe(originalValue);+ }++ await context.close();+ });+});++test.describe('Orientation Change - Navigation Visibility', () => {+ test('iPhone SE landscape (667px) still shows mobile nav', async ({ browser }) => {+ // 667px is less than 768px breakpoint, so mobile nav should still show+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_SE.landscape,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const mobileNav = page.locator('.ldr-mobile-bottom-nav');+ await expect(mobileNav, 'Mobile nav visible at 667px (iPhone SE landscape)').toBeVisible();++ await context.close();+ });++ test('Galaxy S23 landscape (780px) shows tablet layout', async ({ browser }) => {+ // 780px is greater than 768px breakpoint, so should show sidebar+ const context = await browser.newContext({+ viewport: DEVICES.GALAXY_S23.landscape,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ // At 780px, should be tablet layout+ const sidebar = page.locator('.ldr-sidebar');+ const sidebarVisible = await sidebar.isVisible();++ const mobileNav = page.locator('.ldr-mobile-bottom-nav');+ const mobileNavVisible = await mobileNav.isVisible();++ // Either sidebar visible OR mobile nav visible (depends on implementation)+ // At 780px > 768px, expect sidebar layout+ if (sidebarVisible) {+ expect(mobileNavVisible, 'Mobile nav hidden when sidebar shows at 780px').toBe(false);+ }++ await context.close();+ });++ test('iPhone 14 landscape (844px) shows tablet layout', async ({ browser }) => {+ // 844px is well above 768px breakpoint+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_14.landscape,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const mobileNav = page.locator('.ldr-mobile-bottom-nav');+ await expect(mobileNav, 'Mobile nav hidden at 844px (iPhone 14 landscape)').not.toBeVisible();++ await context.close();+ });+});++test.describe('Orientation Change - Content Accessibility', () => {+ test('Main content remains accessible after rotation', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_14.portrait,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ // Check main content visible in portrait+ const mainContent = page.locator('main, .ldr-main-content, .ldr-content, #content');+ if (await mainContent.count() > 0) {+ await expect(mainContent.first(), 'Main content visible in portrait').toBeVisible();+ }++ // Rotate to landscape+ await page.setViewportSize(DEVICES.IPHONE_14.landscape);+ await page.waitForTimeout(300);++ // Main content should still be visible+ if (await mainContent.count() > 0) {+ await expect(mainContent.first(), 'Main content visible in landscape').toBeVisible();+ }++ await context.close();+ });++ test('Buttons remain tappable after rotation', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_14.portrait,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/');+ await page.waitForLoadState('networkidle');++ const startButton = page.locator('#start-research-btn, button:has-text("Start Research")');+ if (await startButton.count() > 0) {+ let box = await startButton.first().boundingBox();+ expect(box?.height, 'Start button >= 44px in portrait').toBeGreaterThanOrEqual(44);++ // Rotate to landscape+ await page.setViewportSize(DEVICES.IPHONE_14.landscape);+ await page.waitForTimeout(300);++ box = await startButton.first().boundingBox();+ expect(box?.height, 'Start button >= 44px in landscape').toBeGreaterThanOrEqual(44);+ }++ await context.close();+ });+});++test.describe('Orientation Change - Page-Specific Tests', () => {+ test('History page adapts to orientation change', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_14.portrait,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/history/');+ await page.waitForLoadState('networkidle');++ // No overflow in portrait+ let hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'History: no overflow in portrait').toBe(false);++ // Rotate+ await page.setViewportSize(DEVICES.IPHONE_14.landscape);+ await page.waitForTimeout(300);++ // No overflow in landscape+ hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'History: no overflow in landscape').toBe(false);++ await context.close();+ });++ test('Settings page adapts to orientation change', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_14.portrait,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/settings/');+ await page.waitForLoadState('networkidle');+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});++ // No overflow in portrait+ let hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'Settings: no overflow in portrait').toBe(false);++ // Rotate+ await page.setViewportSize(DEVICES.IPHONE_14.landscape);+ await page.waitForTimeout(300);++ // No overflow in landscape+ hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'Settings: no overflow in landscape').toBe(false);++ await context.close();+ });++ test('Metrics page adapts to orientation change', async ({ browser }) => {+ const context = await browser.newContext({+ viewport: DEVICES.IPHONE_14.portrait,+ isMobile: true,+ hasTouch: true,+ });+ const page = await context.newPage();++ await page.goto('/metrics/');+ await page.waitForLoadState('networkidle');++ // No overflow in portrait+ let hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'Metrics: no overflow in portrait').toBe(false);++ // Rotate+ await page.setViewportSize(DEVICES.IPHONE_14.landscape);+ await page.waitForTimeout(300);++ // No overflow in landscape+ hasOverflow = await page.evaluate(() =>+ document.documentElement.scrollWidth > window.innerWidth+ );+ expect(hasOverflow, 'Metrics: no overflow in landscape').toBe(false);++ await context.close();+ });+});