~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
fix: Comprehensive mobile UI responsive improvements (#1558)
LearningCircuit5324113eb97c
diff --git a/.gitignore b/.gitignoreindex dbd0d6f37d..2252720b1a 100644--- a/.gitignore+++ b/.gitignore@@ -237,6 +237,11 @@ web*.pngtests/screenshots/screenshots/+# Block mobile UI test artifacts (html/json reports, screenshot directories)+tests/ui_tests/mobile/**/*.html+tests/ui_tests/mobile/**/*.json+tests/ui_tests/mobile/*-screenshots/+# Ignore cookiecutter-generated files.docker-compose.*.ymlbackup/diff --git a/src/local_deep_research/web/static/css/mobile-responsive.css b/src/local_deep_research/web/static/css/mobile-responsive.cssindex 8a17134faa..334b30e73a 100644--- a/src/local_deep_research/web/static/css/mobile-responsive.css+++ b/src/local_deep_research/web/static/css/mobile-responsive.css@@ -541,3 +541,349 @@margin-bottom: 1rem !important;}}++/* 19. Fix results page header buttons on mobile */+@media (max-width: 767px) {+ .ldr-results-header {+ flex-direction: column;+ align-items: stretch;+ gap: 1rem;+ }++ .ldr-results-actions {+ display: flex;+ flex-wrap: wrap;+ gap: 0.5rem;+ justify-content: center;+ }++ .ldr-results-actions button,+ .ldr-results-actions .btn {+ flex: 1 1 calc(50% - 0.5rem);+ min-width: 140px;+ max-width: calc(50% - 0.25rem);+ font-size: 0.8rem !important;+ padding: 0.5rem 0.75rem !important;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ }++ /* Make back button full width at the bottom */+ .ldr-results-actions #back-to-history {+ flex: 1 1 100%;+ max-width: 100%;+ }++ .ldr-page-header {+ padding: 1rem;+ }++ .ldr-page-title {+ font-size: 1.25rem;+ }+}++/* Extra small phones - stack all buttons */+@media (max-width: 380px) {+ .ldr-results-actions button,+ .ldr-results-actions .btn {+ flex: 1 1 100%;+ max-width: 100%;+ font-size: 0.85rem !important;+ }+}++/* 20. Fix library page grid for small phones */+/* Note: These selectors target existing classes defined in library.html inline styles */+@media (max-width: 767px) {+ [class~="library-container"],+ .ldr-library-container {+ padding: 0.5rem;+ }++ [class~="library-header"],+ .ldr-library-header {+ flex-direction: column;+ align-items: stretch;+ gap: 1rem;+ }++ [class~="header-actions"],+ .ldr-header-actions {+ flex-direction: column;+ gap: 0.75rem;+ }++ [class~="library-stats"],+ .ldr-library-stats {+ flex-wrap: wrap;+ justify-content: center;+ }++ [class~="library-status-bar"],+ .ldr-library-status-bar {+ flex-direction: column;+ align-items: stretch;+ gap: 0.75rem;+ }++ [class~="filters-section"] [class~="filter-row"],+ .ldr-filters-section .ldr-filter-row {+ flex-direction: column;+ gap: 0.75rem;+ }++ [class~="filter-group"],+ .ldr-filter-group {+ width: 100%;+ }++ [class~="filter-group"] [class~="form-control"],+ .ldr-filter-group .ldr-form-control {+ width: 100%;+ }++ /* Make document grid single column on mobile with smaller min-width */+ [class~="documents-grid"],+ .ldr-documents-grid {+ grid-template-columns: 1fr !important;+ gap: 1rem;+ }++ [class~="document-card"],+ .ldr-document-card {+ max-width: 100%;+ }++ .ldr-action-buttons {+ flex-direction: column;+ }++ .ldr-action-btn {+ min-width: unset;+ flex: 1;+ }++ /* Button groups - using Bootstrap class */+ [class~="btn-group"],+ .ldr-btn-group {+ flex-direction: column;+ width: 100%;+ }++ [class~="btn-group"] [class~="btn"],+ .ldr-btn-group .ldr-btn {+ border-radius: 4px !important;+ margin-bottom: 0.25rem;+ }+}++/* 21. Fix download manager and other pages with header actions */+@media (max-width: 767px) {+ .ldr-header-actions,+ .ldr-research-header {+ flex-direction: column;+ gap: 0.5rem;+ align-items: stretch;+ }++ .ldr-collection-selector select {+ width: 100% !important;+ }++ /* Fix metrics grid */+ [class~="download-stats-grid"],+ .ldr-download-stats-grid,+ .ldr-stats-grid {+ grid-template-columns: repeat(2, 1fr) !important;+ gap: 0.5rem;+ }+}++/* 22. Fix metrics page overflow at all viewports */+#metrics,+.ldr-metrics-page,+[id*="context-overflow"],+[id*="costs"] {+ max-width: 100%;+ overflow-x: hidden;+}++/* Ensure metrics tables don't cause overflow */+#metrics table,+.ldr-metrics-page table {+ max-width: 100%;+ display: block;+ overflow-x: auto;+}++/* Fix metrics page header at all viewports */+#metrics .ldr-page-header {+ flex-wrap: wrap;+ gap: 1rem;+}++#metrics .ldr-page-header > div {+ flex-wrap: wrap;+ gap: 0.5rem;+}++/* Fix tooltip width that can cause overflow */+.ldr-tooltip::after {+ max-width: min(280px, 90vw) !important;+}++/* 23. Fix content behind mobile navigation */+@media (max-width: 767px) {+ /* Ensure News and Subscriptions pages have proper bottom padding */+ .ldr-news-container,+ .ldr-news-page,+ .ldr-subscriptions-page,+ .ldr-news-feed {+ padding-bottom: 100px !important;+ }++ /* Ensure last items are not hidden behind nav */+ .ldr-news-item:last-child,+ .ldr-subscription-card:last-child,+ .ldr-news-card:last-child {+ margin-bottom: 80px;+ }++ /* Ensure scrollable containers account for mobile nav */+ .ldr-news-list,+ .ldr-subscriptions-grid {+ padding-bottom: 80px;+ }+}++/* 24. Fix Download Manager page for mobile */+/* Note: Some selectors target existing classes in download_manager.html */+@media (max-width: 767px) {+ /* Download manager container */+ .ldr-download-manager,+ [class~="download-manager-page"] {+ padding: 0.5rem;+ max-width: 100%;+ overflow-x: hidden;+ }++ /* Header section */+ .ldr-download-manager .ldr-research-header,+ .ldr-download-manager .ldr-header-actions {+ flex-direction: column;+ gap: 0.75rem;+ align-items: stretch;+ }++ .ldr-download-manager [class~="btn-group"],+ .ldr-download-manager .ldr-btn-group {+ flex-direction: column;+ width: 100%;+ }++ .ldr-download-manager [class~="btn-group"] [class~="btn"],+ .ldr-download-manager .ldr-btn-group .ldr-btn {+ border-radius: 4px !important;+ margin-bottom: 0.25rem;+ }++ /* Stats grid */+ .ldr-summary-stats {+ grid-template-columns: repeat(2, 1fr) !important;+ gap: 10px;+ }++ .ldr-stat-card {+ padding: 15px 10px;+ }++ .ldr-stat-card h3 {+ font-size: 24px;+ }++ /* Filter row */+ .ldr-filter-row {+ flex-direction: column;+ gap: 0.75rem;+ }++ .ldr-filter-group {+ width: 100%;+ }++ .ldr-filter-group select,+ .ldr-filter-group input {+ width: 100%;+ min-height: 44px;+ }++ /* Collection selector */+ .ldr-collection-selector {+ width: 100% !important;+ }++ .ldr-collection-selector select {+ width: 100% !important;+ min-width: unset !important;+ }++ /* Documents table */+ .ldr-documents-table {+ display: block;+ overflow-x: auto;+ }++ /* Action buttons */+ .ldr-action-buttons {+ flex-wrap: wrap;+ gap: 0.5rem;+ }++ .ldr-action-btn {+ flex: 1 1 calc(50% - 0.25rem);+ min-width: 100px;+ }+}++/* Extra small phones - download manager */+@media (max-width: 380px) {+ .ldr-summary-stats {+ grid-template-columns: 1fr !important;+ }++ .ldr-stat-card h3 {+ font-size: 20px;+ }+}++/* 25. Fix Settings subpages (Collections, Embeddings) */+/* Note: Some selectors target existing classes in templates */+@media (max-width: 767px) {+ /* Collections page */+ [class~="collections-page"],+ .ldr-collections-page,+ #collections {+ padding: 0.5rem;+ max-width: 100%;+ overflow-x: hidden;+ }++ /* Embeddings page */+ [class~="embedding-settings-page"],+ .ldr-embedding-settings-page,+ #embedding-settings {+ padding: 0.5rem;+ max-width: 100%;+ overflow-x: hidden;+ }++ /* Ensure these pages show mobile navigation */+ [class~="collections-page"] .ldr-mobile-bottom-nav,+ .ldr-collections-page .ldr-mobile-bottom-nav,+ [class~="embedding-settings-page"] .ldr-mobile-bottom-nav,+ .ldr-embedding-settings-page .ldr-mobile-bottom-nav {+ display: flex !important;+ }+}diff --git a/src/local_deep_research/web/static/css/news.css b/src/local_deep_research/web/static/css/news.cssindex 0789672780..9f1756fab2 100644--- a/src/local_deep_research/web/static/css/news.css+++ b/src/local_deep_research/web/static/css/news.css@@ -95,6 +95,185 @@}}+/* Mobile-specific styles for small phones */+@media (max-width: 767px) {+ .ldr-news-container {+ grid-template-columns: 1fr;+ gap: 1rem;+ height: auto;+ min-height: calc(100vh - 180px);+ margin: 0.5rem;+ width: calc(100% - 1rem);+ max-width: calc(100vw - 1rem);+ }++ .ldr-news-page-wrapper {+ padding: 0;+ }++ /* Feed header section */+ .ldr-feed-header-section {+ padding: 1rem;+ margin-bottom: 1rem;+ }++ .ldr-feed-header {+ flex-direction: column;+ align-items: flex-start;+ gap: 1rem;+ }++ .ldr-feed-header h1 {+ font-size: 1.25rem;+ }++ /* Search container */+ .ldr-news-search-container {+ flex-direction: column;+ gap: 0.5rem;+ }++ .ldr-news-search-box {+ width: 100%;+ }++ /* Filters bar */+ .ldr-filters-bar {+ padding: 0.75rem;+ }++ .ldr-filter-section {+ flex-direction: column;+ align-items: stretch;+ gap: 0.75rem;+ }++ .ldr-subscriptions-horizontal {+ max-width: 100%;+ }++ .ldr-time-filter-group,+ .ldr-impact-filter-group {+ flex-wrap: wrap;+ justify-content: flex-start;+ }++ .ldr-filter-btn {+ padding: 0.5rem 0.75rem;+ font-size: 0.8rem;+ min-height: 44px;+ }++ /* News items */+ .ldr-news-item {+ padding: 1.25rem;+ min-height: auto;+ }++ .ldr-news-card {+ padding: 1.25rem;+ min-height: auto;+ }++ .ldr-news-headline,+ .ldr-news-title {+ font-size: 1.2rem;+ line-height: 1.4;+ }++ .ldr-news-findings {+ font-size: 0.95rem;+ line-height: 1.6;+ }++ .ldr-news-summary {+ font-size: 0.9rem;+ }++ .ldr-news-meta {+ flex-wrap: wrap;+ gap: 0.5rem;+ font-size: 0.85rem;+ }++ .ldr-news-actions {+ flex-direction: column;+ gap: 1rem;+ }++ .ldr-vote-buttons {+ width: 100%;+ justify-content: center;+ }++ .ldr-action-buttons {+ width: 100%;+ justify-content: center;+ flex-wrap: wrap;+ }++ /* Topic tags */+ .ldr-topic-tags {+ gap: 0.375rem;+ }++ .ldr-topic-tag {+ padding: 0.375rem 0.625rem;+ font-size: 0.8rem;+ }++ /* Quick actions */+ .ldr-quick-actions-row {+ flex-direction: column;+ }++ .ldr-quick-actions-row .btn {+ width: 100%;+ min-width: unset;+ }++ /* Sources list */+ .ldr-sources-list {+ flex-direction: column;+ }++ .ldr-source-link {+ max-width: 100%;+ }++ /* Integrated search */+ .ldr-integrated-search-section {+ padding: 1rem;+ }++ .ldr-search-controls {+ flex-wrap: wrap;+ }+}++/* Extra small phones (360px and below) */+@media (max-width: 380px) {+ .ldr-news-container {+ margin: 0.25rem;+ width: calc(100% - 0.5rem);+ }++ .ldr-news-headline,+ .ldr-news-title {+ font-size: 1.1rem;+ }++ .ldr-news-item,+ .ldr-news-card {+ padding: 1rem;+ }++ .ldr-filter-btn {+ padding: 0.4rem 0.5rem;+ font-size: 0.75rem;+ }+}+/* Integrated Search Section */.ldr-integrated-search-section {background: var(--bg-secondary);diff --git a/src/local_deep_research/web/static/css/settings.css b/src/local_deep_research/web/static/css/settings.cssindex 2b46b46489..f1ab00264b 100644--- a/src/local_deep_research/web/static/css/settings.css+++ b/src/local_deep_research/web/static/css/settings.css@@ -1420,4 +1420,159 @@background: var(--accent-primary);border-radius: 3px;}++ /* Fix grid layouts for mobile - CRITICAL for preventing overflow */+ .ldr-settings-cards,+ .ldr-settings-row,+ .ldr-search-engine-grid,+ .ldr-quick-actions {+ grid-template-columns: 1fr !important;+ gap: 0.75rem;+ }++ /* Settings container */+ .ldr-settings-container {+ padding: 0.5rem;+ max-width: 100%;+ overflow-x: hidden;+ }++ /* Settings page wrapper */+ .ldr-settings-page,+ #settings {+ max-width: 100%;+ overflow-x: hidden;+ padding: 0.5rem;+ }++ /* Settings header */+ .ldr-settings-header {+ padding: 0 0.5rem;+ }++ .ldr-settings-header h1 {+ font-size: 1.5rem;+ }++ /* Settings cards */+ .ldr-settings-card {+ padding: 1rem;+ max-width: 100%;+ }++ .ldr-settings-card h3 {+ font-size: 1rem;+ }++ /* Settings sections */+ .ldr-settings-section {+ margin: 0 0 1rem 0;+ }++ .ldr-settings-section-header {+ flex-direction: column;+ align-items: flex-start;+ gap: 0.5rem;+ padding: 0.75rem 1rem;+ }++ .ldr-settings-section-title {+ font-size: 1rem;+ }++ .ldr-settings-section-content {+ padding: 0.75rem;+ }++ /* Settings items */+ .ldr-settings-item {+ flex-direction: column;+ align-items: stretch;+ gap: 0.5rem;+ padding: 0.75rem 0;+ }++ .ldr-settings-item-label {+ min-width: unset;+ width: 100%;+ }++ .ldr-settings-item-control {+ width: 100%;+ }++ /* Form controls */+ .ldr-settings-item input[type="text"],+ .ldr-settings-item input[type="number"],+ .ldr-settings-item input[type="url"],+ .ldr-settings-item select,+ .ldr-settings-item textarea {+ width: 100%;+ min-height: 44px;+ }++ /* Buttons */+ .ldr-settings-actions {+ flex-direction: column;+ gap: 0.5rem;+ }++ .ldr-settings-actions button,+ .ldr-settings-actions .btn {+ width: 100%;+ min-height: 44px;+ }++ /* JSON controls */+ .ldr-json-controls {+ flex-direction: column;+ gap: 0.5rem;+ }++ .ldr-json-controls button {+ width: 100%;+ }++ /* Community note */+ .ldr-community-note {+ font-size: 0.8rem;+ padding: 0.5rem 0.75rem;+ }++ /* Support note */+ .ldr-support-note {+ font-size: 0.75rem;+ }++ /* Card content padding */+ .ldr-card-content {+ padding: 1rem;+ }++ /* Description text */+ .ldr-settings-description {+ font-size: 0.85rem;+ }+}++/* Extra small phones */+@media (max-width: 380px) {+ .ldr-settings-page,+ #settings,+ .ldr-settings-container {+ padding: 0.25rem;+ }++ .ldr-settings-header h1 {+ font-size: 1.25rem;+ }++ .ldr-settings-tab {+ font-size: 0.8rem;+ padding: 0.4rem 0.75rem;+ }++ .ldr-settings-card {+ padding: 0.75rem;+ }}diff --git a/src/local_deep_research/web/static/css/subscriptions.css b/src/local_deep_research/web/static/css/subscriptions.cssindex 82f88917c8..0ac4a82082 100644--- a/src/local_deep_research/web/static/css/subscriptions.css+++ b/src/local_deep_research/web/static/css/subscriptions.css@@ -562,3 +562,155 @@width: 100%;}}++/* Mobile-specific fixes for small phones */+@media (max-width: 767px) {+ .ldr-subscriptions-page {+ padding: 10px;+ max-width: 100%;+ overflow-x: hidden;+ }++ .ldr-page-header {+ flex-direction: column;+ align-items: stretch;+ gap: 1rem;+ }++ .ldr-header-actions {+ flex-direction: column;+ gap: 0.5rem;+ }++ .ldr-header-actions .btn {+ width: 100%;+ }++ .ldr-header-content h1 {+ font-size: 1.5rem;+ }++ .ldr-stats-overview {+ grid-template-columns: repeat(2, 1fr);+ gap: 10px;+ }++ .ldr-stat-card {+ padding: 15px 10px;+ }++ .ldr-stat-value {+ font-size: 1.75rem;+ }++ .ldr-scheduler-status-bar {+ flex-direction: column;+ gap: 1rem;+ align-items: stretch;+ }++ .ldr-scheduler-info {+ flex-wrap: wrap;+ }++ .ldr-subscriptions-container {+ flex-direction: column;+ gap: 15px;+ }++ .ldr-folders-sidebar {+ width: 100%;+ padding: 15px;+ }++ .ldr-folder-item {+ padding: 12px 15px;+ min-height: 44px;+ }++ .ldr-filter-bar {+ flex-direction: column;+ gap: 10px;+ padding: 10px;+ }++ .ldr-search-box {+ width: 100%;+ }++ .ldr-search-box input {+ width: 100%;+ min-height: 44px;+ }++ .ldr-filter-options {+ width: 100%;+ flex-direction: column;+ gap: 0.5rem;+ }++ .ldr-filter-options select {+ width: 100%;+ min-width: unset;+ min-height: 44px;+ }++ .ldr-subscriptions-grid {+ grid-template-columns: 1fr !important;+ gap: 15px;+ }++ .ldr-subscription-card {+ max-width: 100%;+ }++ .ldr-card-header {+ flex-direction: column;+ align-items: stretch;+ gap: 10px;+ }++ .ldr-card-header h4 {+ white-space: normal;+ text-overflow: clip;+ }++ .ldr-card-actions {+ justify-content: flex-end;+ }++ .ldr-subscription-meta {+ flex-direction: column;+ gap: 5px;+ }++ .ldr-subscription-stats {+ flex-direction: column;+ gap: 5px;+ }++ /* Ensure no horizontal overflow */+ .ldr-subscriptions-main {+ max-width: 100%;+ overflow-x: hidden;+ }+}++/* Extra small phones */+@media (max-width: 380px) {+ .ldr-subscriptions-page {+ padding: 8px;+ }++ .ldr-stats-overview {+ grid-template-columns: 1fr;+ }++ .ldr-stat-value {+ font-size: 1.5rem;+ }++ .ldr-header-content h1 {+ font-size: 1.25rem;+ }+}diff --git a/tests/ui_tests/mobile/test_all_pages_mobile.js b/tests/ui_tests/mobile/test_all_pages_mobile.jsnew file mode 100755index 0000000000..af852440fd--- /dev/null+++ b/tests/ui_tests/mobile/test_all_pages_mobile.js@@ -0,0 +1,690 @@+#!/usr/bin/env node+/**+ * Comprehensive Mobile Test - All Pages+ * Tests ALL pages in the LDR application across multiple mobile viewports+ *+ * Features:+ * - Tests 3 mobile viewports: 360px (small Android), 375px (iPhone SE), 430px (iPhone 14)+ * - Tests ALL pages including auth, settings subpages, metrics subpages+ * - Checks for horizontal overflow, mobile nav, sidebar, touch targets, text readability+ * - Takes screenshots of each page at each viewport+ * - Generates comprehensive summary report+ */++const puppeteer = require('puppeteer');+const AuthHelper = require('../auth_helper');+const { getPuppeteerLaunchOptions } = require('../puppeteer_config');+const path = require('path');+const fs = require('fs').promises;++// Test configuration+const CONFIG = {+ baseUrl: process.env.TEST_BASE_URL || 'http://127.0.0.1:5000',+ timeout: 30000,+ screenshotDir: path.join(__dirname, 'screenshots'),+};++// Mobile viewports to test+const VIEWPORTS = {+ 'Android_360': { width: 360, height: 640, isMobile: true, hasTouch: true, label: 'Small Android (360px)' },+ 'iPhone_SE': { width: 375, height: 667, isMobile: true, hasTouch: true, label: 'iPhone SE (375px)' },+ 'iPhone_14': { width: 430, height: 932, isMobile: true, hasTouch: true, label: 'iPhone 14 (430px)' },+};++// ALL pages to test+const PAGES = [+ // Main pages+ { path: '/', name: 'Research', requiresAuth: true, category: 'Main' },+ { path: '/history/', name: 'History', requiresAuth: true, category: 'Main' },+ { path: '/news/', name: 'News', requiresAuth: true, category: 'Main' },+ { path: '/news/subscriptions', name: 'News-Subscriptions', requiresAuth: true, category: 'News' },++ // Settings pages+ { path: '/settings/', name: 'Settings', requiresAuth: true, category: 'Settings' },+ { path: '/settings/collections', name: 'Settings-Collections', requiresAuth: true, category: 'Settings' },+ { path: '/settings/embeddings', name: 'Settings-Embeddings', requiresAuth: true, category: 'Settings' },++ // Metrics pages+ { path: '/metrics/', name: 'Metrics', requiresAuth: true, category: 'Metrics' },+ { path: '/metrics/costs', name: 'Metrics-Costs', requiresAuth: true, category: 'Metrics' },+ { path: '/metrics/context-overflow', name: 'Metrics-ContextOverflow', requiresAuth: true, category: 'Metrics' },+ { path: '/metrics/star-reviews', name: 'Metrics-StarReviews', requiresAuth: true, category: 'Metrics' },++ // Other pages+ { path: '/benchmark/', name: 'Benchmark', requiresAuth: true, category: 'Other' },+ { path: '/library/', name: 'Library', requiresAuth: true, category: 'Other' },+ { path: '/library/download-manager', name: 'Library-DownloadManager', requiresAuth: true, category: 'Other' },++ // Auth pages+ { path: '/auth/login', name: 'Login', requiresAuth: false, category: 'Auth' },+ { path: '/auth/register', name: 'Register', requiresAuth: false, category: 'Auth' },+];++class ComprehensiveMobileTest {+ constructor() {+ this.results = {+ startTime: new Date(),+ viewportResults: {},+ pageResults: {},+ issues: [],+ screenshots: [],+ summary: {+ total: 0,+ passed: 0,+ failed: 0,+ warnings: 0,+ pagesTestedPerViewport: {},+ criticalIssues: [],+ viewportStats: {}+ }+ };+ }++ async run() {+ console.log('🚀 Comprehensive Mobile Test - All Pages');+ console.log('='.repeat(70));+ console.log(`Testing ${Object.keys(VIEWPORTS).length} viewports × ${PAGES.length} pages = ${Object.keys(VIEWPORTS).length * PAGES.length} tests`);+ console.log('='.repeat(70));++ let browser;+ try {+ // Ensure screenshot directory exists+ await fs.mkdir(CONFIG.screenshotDir, { recursive: true });++ browser = await puppeteer.launch(getPuppeteerLaunchOptions());++ for (const [deviceName, viewport] of Object.entries(VIEWPORTS)) {+ await this.testDevice(browser, deviceName, viewport);+ }++ await this.generateReport();++ // Exit with error code if there are failed tests+ process.exit(this.results.summary.failed > 0 ? 1 : 0);++ } catch (error) {+ console.error('❌ Test suite failed:', error);+ process.exit(1);+ } finally {+ if (browser) await browser.close();+ }+ }++ async testDevice(browser, deviceName, viewport) {+ console.log(`\n${'='.repeat(70)}`);+ console.log(`📱 Testing ${viewport.label}`);+ console.log(`${'='.repeat(70)}`);++ this.results.viewportResults[deviceName] = {+ viewport: viewport.label,+ tests: [],+ passed: 0,+ failed: 0,+ warnings: 0+ };++ const page = await browser.newPage();+ await page.setViewport(viewport);++ // Authenticate for auth-required pages+ const authHelper = new AuthHelper(page, CONFIG.baseUrl);+ let authenticated = false;+ try {+ await authHelper.ensureAuthenticated();+ authenticated = true;+ console.log('✅ Authentication successful\n');+ } catch (error) {+ console.log('⚠️ Authentication failed, testing unauthenticated pages only\n');+ }++ // Test each page+ for (const pageInfo of PAGES) {+ if (pageInfo.requiresAuth && !authenticated) {+ console.log(` ⏭️ Skipping ${pageInfo.name} (requires auth)`);+ continue;+ }+ await this.testPage(page, deviceName, viewport, pageInfo);+ }++ await page.close();++ // Display viewport summary+ const vpResult = this.results.viewportResults[deviceName];+ console.log(`\n${'─'.repeat(70)}`);+ console.log(`${viewport.label} Summary: ${vpResult.passed}/${vpResult.tests.length} passed, ${vpResult.failed} failed, ${vpResult.warnings} warnings`);+ console.log(`${'─'.repeat(70)}`);+ }++ async testPage(page, deviceName, viewport, pageInfo) {+ const testName = `${deviceName}/${pageInfo.name}`;+ const startTime = Date.now();++ try {+ // Navigate to page+ await page.goto(CONFIG.baseUrl + pageInfo.path, {+ waitUntil: 'networkidle2',+ timeout: CONFIG.timeout+ });++ // Wait for page to settle+ await new Promise(resolve => setTimeout(resolve, 1500));++ // Take screenshot+ const screenshotName = `${deviceName}_${pageInfo.name}.png`;+ const screenshotPath = path.join(CONFIG.screenshotDir, screenshotName);+ await page.screenshot({+ path: screenshotPath,+ fullPage: true+ });+ this.results.screenshots.push({+ viewport: deviceName,+ page: pageInfo.name,+ path: screenshotPath+ });++ // Run comprehensive checks+ const checks = await page.evaluate(() => {+ const results = {+ horizontalOverflow: false,+ overflowAmount: 0,+ mobileNavExists: false,+ mobileNavVisible: false,+ sidebarHidden: true,+ smallTouchTargets: 0,+ touchTargetDetails: [],+ textReadability: {+ tooSmall: 0,+ elements: []+ },+ viewportWidth: window.innerWidth,+ scrollWidth: document.body.scrollWidth,+ errors: [],+ warnings: []+ };++ // 1. Check horizontal overflow (CRITICAL)+ const threshold = 5; // Allow 5px tolerance+ if (document.body.scrollWidth > window.innerWidth + threshold) {+ results.horizontalOverflow = true;+ results.overflowAmount = document.body.scrollWidth - window.innerWidth;+ results.errors.push(`Horizontal overflow: ${results.overflowAmount}px beyond viewport`);+ }++ // 2. Check mobile navigation visibility+ const mobileNav = document.querySelector('.ldr-mobile-bottom-nav');+ results.mobileNavExists = !!mobileNav;+ if (mobileNav) {+ const style = window.getComputedStyle(mobileNav);+ results.mobileNavVisible = style.display !== 'none' &&+ mobileNav.classList.contains('visible');+ }++ // 3. Check sidebar hidden on mobile+ const sidebar = document.querySelector('.ldr-sidebar');+ if (sidebar) {+ const style = window.getComputedStyle(sidebar);+ results.sidebarHidden = style.display === 'none' ||+ style.visibility === 'hidden' ||+ parseFloat(style.opacity) === 0;++ if (!results.sidebarHidden && window.innerWidth <= 768) {+ results.errors.push('Desktop sidebar visible on mobile viewport');+ }+ }++ // 4. Check touch target sizes (minimum 44x44px recommended)+ const interactiveSelectors = [+ 'button:not([disabled])',+ 'a:not([disabled])',+ 'input[type="button"]:not([disabled])',+ 'input[type="submit"]:not([disabled])',+ '.ldr-mobile-nav-tab',+ '[role="button"]'+ ];++ document.querySelectorAll(interactiveSelectors.join(', ')).forEach(el => {+ const rect = el.getBoundingClientRect();+ // Only check visible elements+ if (rect.width > 0 && rect.height > 0) {+ const minDimension = Math.min(rect.width, rect.height);+ if (minDimension < 44) {+ results.smallTouchTargets++;+ if (results.touchTargetDetails.length < 5) { // Limit details to first 5+ const identifier = el.id || el.className || el.tagName;+ results.touchTargetDetails.push({+ element: identifier.substring(0, 50),+ size: `${Math.round(rect.width)}×${Math.round(rect.height)}px`+ });+ }+ }+ }+ });++ // 5. Check text readability (minimum 16px for body text)+ const textElements = document.querySelectorAll('p, li, span, div, td, th, label');+ textElements.forEach(el => {+ const style = window.getComputedStyle(el);+ const fontSize = parseFloat(style.fontSize);+ const hasText = el.textContent.trim().length > 20; // Only check substantial text++ if (hasText && fontSize < 14) {+ results.textReadability.tooSmall++;+ if (results.textReadability.elements.length < 3) {+ results.textReadability.elements.push({+ size: `${fontSize}px`,+ text: el.textContent.substring(0, 30) + '...'+ });+ }+ }+ });++ // Add warnings+ if (results.smallTouchTargets > 5) {+ results.warnings.push(`${results.smallTouchTargets} touch targets < 44px`);+ }+ if (results.textReadability.tooSmall > 0) {+ results.warnings.push(`${results.textReadability.tooSmall} text elements < 14px`);+ }++ return results;+ });++ // Analyze results+ const testResult = {+ name: testName,+ page: pageInfo.name,+ path: pageInfo.path,+ viewport: deviceName,+ status: 'passed',+ issues: [],+ warnings: [],+ checks: checks,+ duration: (Date.now() - startTime) / 1000,+ screenshot: screenshotName+ };++ // Critical issues (fail test)+ if (checks.horizontalOverflow) {+ testResult.status = 'failed';+ testResult.issues.push(`❌ CRITICAL: Horizontal overflow (${checks.overflowAmount}px)`);+ this.results.issues.push({+ severity: 'critical',+ page: pageInfo.name,+ viewport: deviceName,+ issue: `Horizontal overflow: ${checks.overflowAmount}px`+ });+ }++ // Check mobile nav visibility (only for authenticated pages, not auth pages)+ if (pageInfo.requiresAuth && !pageInfo.path.includes('/auth/')) {+ const currentUrl = page.url();+ // Only require mobile nav if we're actually on the page (not redirected to login)+ if (!currentUrl.includes('/auth/') && !checks.mobileNavVisible) {+ testResult.status = 'failed';+ testResult.issues.push('❌ CRITICAL: Mobile navigation not visible');+ this.results.issues.push({+ severity: 'critical',+ page: pageInfo.name,+ viewport: deviceName,+ issue: 'Mobile navigation not visible'+ });+ }+ }++ if (!checks.sidebarHidden) {+ testResult.status = 'failed';+ testResult.issues.push('❌ CRITICAL: Desktop sidebar visible on mobile');+ this.results.issues.push({+ severity: 'critical',+ page: pageInfo.name,+ viewport: deviceName,+ issue: 'Desktop sidebar visible'+ });+ }++ // Warnings (don't fail test)+ if (checks.smallTouchTargets > 10) {+ testResult.warnings.push(`⚠️ ${checks.smallTouchTargets} small touch targets (< 44px)`);+ if (checks.touchTargetDetails.length > 0) {+ testResult.warnings.push(` Examples: ${checks.touchTargetDetails.map(t => `${t.element} ${t.size}`).join(', ')}`);+ }+ }++ if (checks.textReadability.tooSmall > 5) {+ testResult.warnings.push(`⚠️ ${checks.textReadability.tooSmall} text elements too small (< 14px)`);+ }++ // Update counters+ this.results.summary.total++;+ if (testResult.status === 'passed') {+ this.results.summary.passed++;+ this.results.viewportResults[deviceName].passed++;+ } else {+ this.results.summary.failed++;+ this.results.viewportResults[deviceName].failed++;+ }++ if (testResult.warnings.length > 0) {+ this.results.summary.warnings++;+ this.results.viewportResults[deviceName].warnings++;+ }++ // Store result+ this.results.viewportResults[deviceName].tests.push(testResult);++ if (!this.results.pageResults[pageInfo.name]) {+ this.results.pageResults[pageInfo.name] = [];+ }+ this.results.pageResults[pageInfo.name].push(testResult);++ // Display result+ const status = testResult.status === 'passed' ? '✅' : '❌';+ const category = pageInfo.category ? `[${pageInfo.category}]` : '';+ console.log(` ${status} ${category} ${pageInfo.name.padEnd(30)} | ${checks.viewportWidth}×${checks.scrollWidth}px`);++ if (testResult.issues.length > 0) {+ testResult.issues.forEach(issue => console.log(` ${issue}`));+ }+ if (testResult.warnings.length > 0) {+ testResult.warnings.forEach(warning => console.log(` ${warning}`));+ }++ } catch (error) {+ this.results.summary.total++;+ this.results.summary.failed++;+ this.results.viewportResults[deviceName].failed++;++ const errorResult = {+ name: testName,+ page: pageInfo.name,+ path: pageInfo.path,+ viewport: deviceName,+ status: 'failed',+ issues: [`❌ ERROR: ${error.message}`],+ warnings: [],+ duration: (Date.now() - startTime) / 1000+ };++ this.results.viewportResults[deviceName].tests.push(errorResult);+ console.log(` ❌ ${pageInfo.name} - ERROR: ${error.message}`);+ }+ }++ async generateReport() {+ this.results.endTime = new Date();+ this.results.duration = (this.results.endTime - this.results.startTime) / 1000;++ console.log('\n' + '='.repeat(70));+ console.log('📊 COMPREHENSIVE TEST REPORT');+ console.log('='.repeat(70));++ // Overall summary+ console.log('\n📈 Overall Summary:');+ console.log(` Total Tests: ${this.results.summary.total}`);+ console.log(` ✅ Passed: ${this.results.summary.passed}`);+ console.log(` ❌ Failed: ${this.results.summary.failed}`);+ console.log(` ⚠️ Warnings: ${this.results.summary.warnings}`);+ console.log(` ⏱️ Duration: ${this.results.duration.toFixed(2)}s`);+ console.log(` 📸 Screenshots: ${this.results.screenshots.length}`);++ // Viewport breakdown+ console.log('\n📱 Viewport Breakdown:');+ for (const [deviceName, vpResult] of Object.entries(this.results.viewportResults)) {+ const passRate = vpResult.tests.length > 0+ ? ((vpResult.passed / vpResult.tests.length) * 100).toFixed(1)+ : 0;+ console.log(` ${VIEWPORTS[deviceName].label}:`);+ console.log(` ${vpResult.passed}/${vpResult.tests.length} passed (${passRate}%) | ${vpResult.failed} failed | ${vpResult.warnings} warnings`);+ }++ // Critical issues+ if (this.results.summary.failed > 0) {+ console.log('\n❌ CRITICAL ISSUES:');+ const criticalIssues = this.results.issues.filter(i => i.severity === 'critical');++ // Group by issue type+ const issuesByType = {};+ criticalIssues.forEach(issue => {+ const type = issue.issue.split(':')[0];+ if (!issuesByType[type]) {+ issuesByType[type] = [];+ }+ issuesByType[type].push(issue);+ });++ for (const [type, issues] of Object.entries(issuesByType)) {+ console.log(`\n ${type}:`);+ issues.forEach(issue => {+ console.log(` - ${issue.page} @ ${issue.viewport}: ${issue.issue}`);+ });+ }+ }++ // Failed pages+ if (this.results.summary.failed > 0) {+ console.log('\n🚨 Failed Pages:');+ for (const [pageName, results] of Object.entries(this.results.pageResults)) {+ const failed = results.filter(r => r.status === 'failed');+ if (failed.length > 0) {+ console.log(` ${pageName}:`);+ failed.forEach(r => {+ console.log(` - ${VIEWPORTS[r.viewport].label}: ${r.issues.join(', ')}`);+ });+ }+ }+ }++ // Page category summary+ console.log('\n📑 Page Category Summary:');+ const categorySummary = {};+ for (const page of PAGES) {+ if (!categorySummary[page.category]) {+ categorySummary[page.category] = { total: 0, passed: 0, failed: 0 };+ }+ const pageResults = this.results.pageResults[page.name] || [];+ pageResults.forEach(r => {+ categorySummary[page.category].total++;+ if (r.status === 'passed') {+ categorySummary[page.category].passed++;+ } else {+ categorySummary[page.category].failed++;+ }+ });+ }++ for (const [category, stats] of Object.entries(categorySummary)) {+ const passRate = stats.total > 0 ? ((stats.passed / stats.total) * 100).toFixed(1) : 0;+ console.log(` ${category}: ${stats.passed}/${stats.total} passed (${passRate}%)`);+ }++ // Screenshot info+ console.log(`\n📸 Screenshots saved to: ${CONFIG.screenshotDir}/`);+ console.log(` Total screenshots: ${this.results.screenshots.length}`);++ // Save detailed JSON report+ const reportPath = path.join(__dirname, 'mobile-test-report.json');+ await fs.writeFile(reportPath, JSON.stringify(this.results, null, 2));+ console.log(`\n💾 Detailed report saved to: ${reportPath}`);++ // Generate HTML report+ await this.generateHtmlReport();++ console.log('\n' + '='.repeat(70));+ if (this.results.summary.failed === 0) {+ console.log('🎉 ALL TESTS PASSED!');+ } else {+ console.log(`⚠️ ${this.results.summary.failed} TEST(S) FAILED`);+ }+ console.log('='.repeat(70) + '\n');+ }++ async generateHtmlReport() {+ const html = `<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>Mobile Test Report - ${new Date().toLocaleDateString()}</title>+ <style>+ * { margin: 0; padding: 0; box-sizing: border-box; }+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; padding: 20px; background: #f5f5f5; }+ .container { max-width: 1400px; margin: 0 auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }+ h1 { color: #333; margin-bottom: 20px; }+ h2 { color: #555; margin: 30px 0 15px; padding-bottom: 10px; border-bottom: 2px solid #eee; }+ h3 { color: #666; margin: 20px 0 10px; }+ .summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin: 20px 0; }+ .stat-card { padding: 20px; border-radius: 6px; background: #f8f9fa; }+ .stat-card.passed { border-left: 4px solid #28a745; }+ .stat-card.failed { border-left: 4px solid #dc3545; }+ .stat-card.warning { border-left: 4px solid #ffc107; }+ .stat-label { font-size: 14px; color: #666; margin-bottom: 5px; }+ .stat-value { font-size: 32px; font-weight: bold; color: #333; }+ .viewport-results { margin: 20px 0; }+ .viewport { margin-bottom: 30px; padding: 20px; background: #f8f9fa; border-radius: 6px; }+ .test-grid { display: grid; gap: 15px; margin-top: 15px; }+ .test-item { padding: 15px; background: white; border-radius: 4px; border-left: 4px solid #28a745; }+ .test-item.failed { border-left-color: #dc3545; }+ .test-item.warning { border-left-color: #ffc107; }+ .test-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }+ .test-name { font-weight: 600; color: #333; }+ .test-status { padding: 4px 12px; border-radius: 4px; font-size: 12px; font-weight: 600; }+ .test-status.passed { background: #d4edda; color: #155724; }+ .test-status.failed { background: #f8d7da; color: #721c24; }+ .test-details { font-size: 14px; color: #666; margin-top: 8px; }+ .issue { color: #dc3545; margin-top: 5px; }+ .warning { color: #ffc107; margin-top: 5px; }+ .screenshot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin: 20px 0; }+ .screenshot { border: 1px solid #ddd; border-radius: 4px; padding: 10px; background: white; }+ .screenshot img { width: 100%; border-radius: 4px; }+ .screenshot-label { text-align: center; margin-top: 8px; font-size: 12px; color: #666; }+ .category-summary { display: grid; gap: 10px; }+ .category-item { padding: 12px; background: #f8f9fa; border-radius: 4px; display: flex; justify-content: space-between; align-items: center; }+ .progress-bar { width: 200px; height: 20px; background: #e9ecef; border-radius: 10px; overflow: hidden; }+ .progress-fill { height: 100%; background: #28a745; transition: width 0.3s; }+ </style>+</head>+<body>+ <div class="container">+ <h1>📱 Mobile Test Report</h1>+ <p style="color: #666; margin-bottom: 20px;">Generated on ${new Date().toLocaleString()}</p>++ <h2>📈 Overall Summary</h2>+ <div class="summary">+ <div class="stat-card">+ <div class="stat-label">Total Tests</div>+ <div class="stat-value">${this.results.summary.total}</div>+ </div>+ <div class="stat-card passed">+ <div class="stat-label">Passed</div>+ <div class="stat-value">${this.results.summary.passed}</div>+ </div>+ <div class="stat-card failed">+ <div class="stat-label">Failed</div>+ <div class="stat-value">${this.results.summary.failed}</div>+ </div>+ <div class="stat-card warning">+ <div class="stat-label">Warnings</div>+ <div class="stat-value">${this.results.summary.warnings}</div>+ </div>+ <div class="stat-card">+ <div class="stat-label">Duration</div>+ <div class="stat-value">${this.results.duration.toFixed(1)}s</div>+ </div>+ <div class="stat-card">+ <div class="stat-label">Screenshots</div>+ <div class="stat-value">${this.results.screenshots.length}</div>+ </div>+ </div>++ <h2>📱 Viewport Results</h2>+ <div class="viewport-results">+ ${Object.entries(this.results.viewportResults).map(([deviceName, vpResult]) => `+ <div class="viewport">+ <h3>${VIEWPORTS[deviceName].label} (${VIEWPORTS[deviceName].width}px)</h3>+ <p style="margin: 10px 0;">+ <strong>${vpResult.passed}/${vpResult.tests.length}</strong> tests passed+ (${vpResult.tests.length > 0 ? ((vpResult.passed / vpResult.tests.length) * 100).toFixed(1) : 0}%)+ </p>+ <div class="test-grid">+ ${vpResult.tests.map(test => `+ <div class="test-item ${test.status} ${test.warnings.length > 0 ? 'warning' : ''}">+ <div class="test-header">+ <span class="test-name">${test.page}</span>+ <span class="test-status ${test.status}">${test.status.toUpperCase()}</span>+ </div>+ <div class="test-details">+ <div>Path: ${test.path}</div>+ <div>Duration: ${test.duration.toFixed(2)}s</div>+ ${test.screenshot ? `<div>Screenshot: ${test.screenshot}</div>` : ''}+ ${test.issues.length > 0 ? test.issues.map(issue => `<div class="issue">${issue}</div>`).join('') : ''}+ ${test.warnings.length > 0 ? test.warnings.map(warning => `<div class="warning">${warning}</div>`).join('') : ''}+ </div>+ </div>+ `).join('')}+ </div>+ </div>+ `).join('')}+ </div>++ <h2>📑 Page Category Summary</h2>+ <div class="category-summary">+ ${(() => {+ const categorySummary = {};+ for (const page of PAGES) {+ if (!categorySummary[page.category]) {+ categorySummary[page.category] = { total: 0, passed: 0, failed: 0 };+ }+ const pageResults = this.results.pageResults[page.name] || [];+ pageResults.forEach(r => {+ categorySummary[page.category].total++;+ if (r.status === 'passed') {+ categorySummary[page.category].passed++;+ } else {+ categorySummary[page.category].failed++;+ }+ });+ }+ return Object.entries(categorySummary).map(([category, stats]) => {+ const passRate = stats.total > 0 ? ((stats.passed / stats.total) * 100) : 0;+ return `+ <div class="category-item">+ <div>+ <strong>${category}</strong>+ <div style="font-size: 14px; color: #666;">${stats.passed}/${stats.total} passed</div>+ </div>+ <div class="progress-bar">+ <div class="progress-fill" style="width: ${passRate}%"></div>+ </div>+ </div>+ `;+ }).join('');+ })()}+ </div>++ ${this.results.summary.failed > 0 ? `+ <h2>❌ Critical Issues</h2>+ <div style="background: #f8d7da; padding: 15px; border-radius: 6px; border-left: 4px solid #dc3545;">+ ${this.results.issues.map(issue => `+ <div style="margin: 8px 0;">+ <strong>${issue.page}</strong> @ ${issue.viewport}: ${issue.issue}+ </div>+ `).join('')}+ </div>+ ` : ''}++ <h2>📸 Screenshots</h2>+ <p style="color: #666; margin-bottom: 15px;">All screenshots saved to: ${CONFIG.screenshotDir}/</p>+ <p style="color: #666;">Total screenshots: ${this.results.screenshots.length}</p>+ </div>+</body>+</html>`;++ const htmlPath = path.join(__dirname, 'mobile-test-report.html');+ await fs.writeFile(htmlPath, html);+ console.log(`📄 HTML report saved to: ${htmlPath}`);+ }+}++// Run+const test = new ComprehensiveMobileTest();+test.run();diff --git a/tests/ui_tests/mobile/test_mobile_fixes_verification.js b/tests/ui_tests/mobile/test_mobile_fixes_verification.jsnew file mode 100644index 0000000000..825614c551--- /dev/null+++ b/tests/ui_tests/mobile/test_mobile_fixes_verification.js@@ -0,0 +1,380 @@+#!/usr/bin/env node+/**+ * Mobile Fixes Verification Test+ *+ * Purpose: Verify mobile CSS fixes work correctly on small phone viewports+ * Tests: News, Results, Library, and main research page+ * Viewports: 360px (small Android), 375px (iPhone SE)+ *+ * Usage: node test_mobile_fixes_verification.js+ */++const puppeteer = require('puppeteer');+const path = require('path');+const fs = require('fs').promises;++// Test devices - focus on SMALL phones+const DEVICES = {+ 'Small_Android_360': {+ width: 360,+ height: 640,+ deviceScaleFactor: 2,+ isMobile: true,+ hasTouch: true+ },+ 'iPhone_SE_375': {+ width: 375,+ height: 667,+ deviceScaleFactor: 2,+ isMobile: true,+ hasTouch: true+ },+ 'iPhone_14_430': {+ width: 430,+ height: 932,+ deviceScaleFactor: 3,+ isMobile: true,+ hasTouch: true+ }+};++// Pages to test (focus on fixed pages)+const PAGES = [+ { path: '/', name: 'Research_Main' },+ { path: '/news/', name: 'News' },+ { path: '/library/', name: 'Library' },+ { path: '/history/', name: 'History' },+ { path: '/settings/', name: 'Settings' },+];++class MobileFixesTest {+ constructor() {+ this.baseUrl = process.env.TEST_BASE_URL || 'http://127.0.0.1:5000';+ this.timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5);+ this.outputDir = path.join(__dirname, 'mobile-fixes-screenshots', this.timestamp);+ this.results = [];+ this.passed = 0;+ this.failed = 0;+ }++ async run() {+ console.log('📱 Mobile Fixes Verification Test');+ console.log('='.repeat(60));+ console.log(`📁 Output: ${this.outputDir}`);+ console.log('='.repeat(60));++ await fs.mkdir(this.outputDir, { recursive: true });++ let browser;+ try {+ browser = await puppeteer.launch({+ headless: process.env.HEADLESS !== 'false',+ args: ['--no-sandbox', '--disable-setuid-sandbox']+ });++ for (const [deviceName, viewport] of Object.entries(DEVICES)) {+ await this.testDevice(browser, deviceName, viewport);+ }++ await this.generateReport();+ console.log('\n' + '='.repeat(60));+ console.log(`✅ Tests passed: ${this.passed}`);+ console.log(`❌ Tests failed: ${this.failed}`);+ console.log(`📁 Screenshots: ${this.outputDir}`);+ console.log('='.repeat(60));++ // Exit with error code if any failures+ process.exit(this.failed > 0 ? 1 : 0);++ } finally {+ if (browser) await browser.close();+ }+ }++ async testDevice(browser, deviceName, viewport) {+ console.log(`\n📱 Testing ${deviceName} (${viewport.width}x${viewport.height})`);+ console.log('─'.repeat(50));++ const deviceDir = path.join(this.outputDir, deviceName);+ await fs.mkdir(deviceDir, { recursive: true });++ const page = await browser.newPage();+ await page.setViewport(viewport);++ // Try to authenticate+ try {+ await this.authenticate(page);+ console.log(' ✅ Authenticated');+ } catch (error) {+ console.log(' ⚠️ Auth failed, testing public pages:', error.message);+ }++ for (const pageInfo of PAGES) {+ await this.testPage(page, deviceName, deviceDir, pageInfo, viewport);+ }++ await page.close();+ }++ async authenticate(page) {+ // Go to login page+ await page.goto(`${this.baseUrl}/auth/login`, { waitUntil: 'networkidle2', timeout: 30000 });++ // Check if already logged in+ const url = page.url();+ if (!url.includes('/auth/login')) {+ return; // Already authenticated+ }++ // Try to login with test credentials+ const username = process.env.TEST_USERNAME || '[email protected]';+ const password = process.env.TEST_PASSWORD || 'testpassword';++ await page.type('input[name="email"], input[name="username"], #email, #username', username);+ await page.type('input[name="password"], #password', password);+ await page.click('button[type="submit"]');+ await page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 10000 }).catch(() => {});+ }++ async testPage(page, deviceName, deviceDir, pageInfo, viewport) {+ console.log(` 📄 ${pageInfo.name}...`);++ const result = {+ device: deviceName,+ page: pageInfo.name,+ viewport: viewport,+ issues: [],+ screenshot: null+ };++ try {+ await page.goto(this.baseUrl + pageInfo.path, {+ waitUntil: 'networkidle2',+ timeout: 30000+ });++ // Wait for mobile nav and page to settle+ await new Promise(resolve => setTimeout(resolve, 1500));++ // Run diagnostic checks+ const diagnostics = await page.evaluate(() => {+ const issues = [];++ // Check for horizontal scroll (most critical mobile issue)+ const hasHorizontalScroll = document.documentElement.scrollWidth > window.innerWidth;+ if (hasHorizontalScroll) {+ issues.push({+ type: 'HORIZONTAL_SCROLL',+ severity: 'HIGH',+ message: `Page has horizontal scroll: ${document.documentElement.scrollWidth}px > ${window.innerWidth}px`+ });++ // Find elements causing overflow+ const overflowingElements = [];+ document.querySelectorAll('*').forEach(el => {+ const rect = el.getBoundingClientRect();+ if (rect.right > window.innerWidth + 5) {+ overflowingElements.push({+ tag: el.tagName,+ class: el.className,+ width: rect.width,+ overflow: rect.right - window.innerWidth+ });+ }+ });++ if (overflowingElements.length > 0) {+ issues.push({+ type: 'OVERFLOW_ELEMENTS',+ severity: 'HIGH',+ message: `${overflowingElements.length} elements overflow viewport`,+ details: overflowingElements.slice(0, 5)+ });+ }+ }++ // Check sidebar visibility (should be hidden on mobile)+ const sidebar = document.querySelector('.ldr-sidebar');+ if (sidebar) {+ const sidebarStyle = window.getComputedStyle(sidebar);+ if (sidebarStyle.display !== 'none' && sidebarStyle.visibility !== 'hidden') {+ issues.push({+ type: 'SIDEBAR_VISIBLE',+ severity: 'MEDIUM',+ message: 'Desktop sidebar is visible on mobile'+ });+ }+ }++ // Check mobile nav visibility+ const mobileNav = document.querySelector('.ldr-mobile-bottom-nav');+ if (mobileNav) {+ const navStyle = window.getComputedStyle(mobileNav);+ if (navStyle.display === 'none') {+ issues.push({+ type: 'MOBILE_NAV_HIDDEN',+ severity: 'MEDIUM',+ message: 'Mobile navigation is hidden'+ });+ }+ }++ // Check touch targets (44px minimum)+ const smallButtons = [];+ document.querySelectorAll('button, a.btn, [role="button"]').forEach(btn => {+ const rect = btn.getBoundingClientRect();+ if (rect.width > 0 && rect.height > 0 && (rect.width < 40 || rect.height < 40)) {+ smallButtons.push({+ text: btn.textContent.trim().substring(0, 30),+ size: `${Math.round(rect.width)}x${Math.round(rect.height)}`+ });+ }+ });++ if (smallButtons.length > 3) {+ issues.push({+ type: 'SMALL_TOUCH_TARGETS',+ severity: 'LOW',+ message: `${smallButtons.length} buttons below 44px touch target`,+ details: smallButtons.slice(0, 5)+ });+ }++ // Check text readability+ const tooSmallText = [];+ document.querySelectorAll('p, span, label, button, a').forEach(el => {+ const style = window.getComputedStyle(el);+ const fontSize = parseFloat(style.fontSize);+ if (fontSize > 0 && fontSize < 12 && el.textContent.trim()) {+ tooSmallText.push({+ tag: el.tagName,+ text: el.textContent.trim().substring(0, 20),+ size: fontSize+ });+ }+ });++ if (tooSmallText.length > 5) {+ issues.push({+ type: 'SMALL_TEXT',+ severity: 'LOW',+ message: `${tooSmallText.length} elements with text < 12px`,+ details: tooSmallText.slice(0, 5)+ });+ }++ return {+ issues,+ pageWidth: document.documentElement.scrollWidth,+ viewportWidth: window.innerWidth+ };+ });++ result.issues = diagnostics.issues;+ result.pageWidth = diagnostics.pageWidth;+ result.viewportWidth = diagnostics.viewportWidth;++ // Take screenshot+ const screenshotPath = path.join(deviceDir, `${pageInfo.name}.png`);+ await page.screenshot({ path: screenshotPath, fullPage: true });+ result.screenshot = screenshotPath;++ // Report results+ const hasHighIssues = result.issues.some(i => i.severity === 'HIGH');+ if (hasHighIssues) {+ console.log(` ❌ FAILED - ${result.issues.filter(i => i.severity === 'HIGH').length} critical issues`);+ result.issues.filter(i => i.severity === 'HIGH').forEach(i => {+ console.log(` • ${i.message}`);+ });+ this.failed++;+ } else {+ const mediumIssues = result.issues.filter(i => i.severity === 'MEDIUM').length;+ const lowIssues = result.issues.filter(i => i.severity === 'LOW').length;+ if (mediumIssues > 0 || lowIssues > 0) {+ console.log(` ⚠️ PASSED with warnings (${mediumIssues} medium, ${lowIssues} low)`);+ } else {+ console.log(` ✅ PASSED`);+ }+ this.passed++;+ }++ } catch (error) {+ console.log(` ❌ ERROR: ${error.message}`);+ result.issues.push({+ type: 'ERROR',+ severity: 'HIGH',+ message: error.message+ });+ this.failed++;+ }++ this.results.push(result);+ }++ async generateReport() {+ // Generate JSON report+ const jsonPath = path.join(this.outputDir, 'report.json');+ await fs.writeFile(jsonPath, JSON.stringify(this.results, null, 2));++ // Generate HTML report+ const html = `<!DOCTYPE html>+<html>+<head>+ <title>Mobile Fixes Verification Report</title>+ <style>+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; margin: 20px; background: #1a1a2e; color: #eee; }+ h1 { color: #4ecca3; }+ .device { margin: 20px 0; padding: 20px; background: #16213e; border-radius: 8px; }+ .device h2 { color: #4ecca3; margin-top: 0; }+ .page { margin: 10px 0; padding: 15px; background: #0f3460; border-radius: 4px; }+ .page img { max-width: 300px; border: 1px solid #4ecca3; margin-top: 10px; }+ .passed { border-left: 4px solid #4ecca3; }+ .failed { border-left: 4px solid #e94560; }+ .issue { padding: 5px 10px; margin: 5px 0; border-radius: 3px; }+ .issue.HIGH { background: #e94560; }+ .issue.MEDIUM { background: #ff9a00; color: #000; }+ .issue.LOW { background: #4ecca3; color: #000; }+ .summary { padding: 20px; background: #16213e; border-radius: 8px; margin-bottom: 20px; }+ .summary .passed { color: #4ecca3; font-size: 24px; }+ .summary .failed { color: #e94560; font-size: 24px; }+ </style>+</head>+<body>+ <h1>📱 Mobile Fixes Verification Report</h1>+ <p>Generated: ${new Date().toISOString()}</p>++ <div class="summary">+ <span class="passed">✅ Passed: ${this.passed}</span> |+ <span class="failed">❌ Failed: ${this.failed}</span>+ </div>++ ${Object.keys(DEVICES).map(device => `+ <div class="device">+ <h2>📱 ${device} (${DEVICES[device].width}x${DEVICES[device].height})</h2>+ ${this.results.filter(r => r.device === device).map(r => `+ <div class="page ${r.issues.some(i => i.severity === 'HIGH') ? 'failed' : 'passed'}">+ <strong>${r.page}</strong>+ ${r.issues.length > 0 ? `+ <div class="issues">+ ${r.issues.map(i => `<div class="issue ${i.severity}">${i.severity}: ${i.message}</div>`).join('')}+ </div>+ ` : '<div style="color:#4ecca3">No issues</div>'}+ ${r.screenshot ? `<br><img src="${r.device}/${r.page}.png" alt="${r.page}">` : ''}+ </div>+ `).join('')}+ </div>+ `).join('')}+</body>+</html>`;++ const htmlPath = path.join(this.outputDir, 'report.html');+ await fs.writeFile(htmlPath, html);+ }+}++// Run the test+const test = new MobileFixesTest();+test.run().catch(error => {+ console.error('Test failed:', error);+ process.exit(1);+});