~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
refactor: replace waitForTimeout calls in theme-visual-regression tests (#2230)
LearningCircuitc66166333152
diff --git a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.jsindex 35d8305392..b880cf5e3f 100644--- a/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/all-pages-mobile.spec.js@@ -61,7 +61,7 @@ async function waitForPageLoad(page, pageInfo) {await page.waitForSelector('#settings-form, form, .ldr-card', { timeout: 10000 }).catch(() => {});} else if (pageInfo.path.includes('/metrics')) {// Wait for metrics content to load- await page.waitForTimeout(500);+ await page.waitForSelector('#metrics-content, .ldr-metrics-grid, .ldr-metric-card', { timeout: 10000 }).catch(() => {});}}@@ -268,12 +268,13 @@ test.describe('All Pages - Content Above Mobile Nav', () => {await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});// Wait for settings form to be fully renderedawait page.waitForSelector('.ldr-settings-form, #settings-form', { timeout: 10000 }).catch(() => {});- await page.waitForTimeout(1000); // Extra time for dynamic rendering+ // Wait for form inputs to render (dynamic content)+ await page.waitForSelector('.ldr-settings-form input, .ldr-settings-form select, #settings-form input, #settings-form select', { timeout: 10000 }).catch(() => {});} else if (pageInfo.path === '/benchmark/') {// Wait for benchmark form to loadawait page.waitForSelector('#settings-form', { timeout: 10000 }).catch(() => {});- // Wait for form and layout to fully render - benchmark has complex form content- await page.waitForTimeout(1000);+ // Wait for form inputs to fully render - benchmark has complex form content+ await page.waitForSelector('#settings-form input, #settings-form select, #settings-form textarea', { timeout: 10000 }).catch(() => {});}// Collapse all help panels before checking - they can expand from localStorage state@@ -286,11 +287,18 @@ test.describe('All Pages - Content Above Mobile Nav', () => {el.style.display = 'none';});});- await page.waitForTimeout(500); // Wait for collapse animation+ // Wait for help panels to finish collapsing+ await page.waitForFunction(() => {+ const panels = document.querySelectorAll('.ldr-help-panel-content');+ return panels.length === 0 || Array.from(panels).every(el => el.style.display === 'none' || el.offsetHeight === 0);+ }, { timeout: 5000 }).catch(() => {});// Scroll to bottom to check last contentawait page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300); // Wait for scroll to complete+ // Wait for scroll to settle at the bottom+ await page.waitForFunction(() => {+ return (window.innerHeight + window.scrollY) >= document.body.scrollHeight - 1;+ }, { timeout: 5000 }).catch(() => {});const result = await page.evaluate((navSelector) => {const mobileNav = document.querySelector(navSelector);@@ -413,9 +421,6 @@ test.describe('All Pages - Visual Regression', () => {await page.goto(pageInfo.path);await waitForPageLoad(page, pageInfo);- // Wait for any animations to complete- await page.waitForTimeout(500);-// CRITICAL: Ensure any open sheets/modals are closed before screenshot// This prevents the "More" menu from overlapping page content in baselinesif (isMobile) {diff --git a/tests/ui_tests/playwright/tests/auth-pages-mobile.spec.js b/tests/ui_tests/playwright/tests/auth-pages-mobile.spec.jsindex ee330ddb48..8a24df661c 100644--- a/tests/ui_tests/playwright/tests/auth-pages-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/auth-pages-mobile.spec.js@@ -40,7 +40,6 @@ test.describe('Auth Pages Mobile', () => {test(`${pageInfo.name} - no horizontal overflow`, async ({ page }) => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const hasOverflow = await page.evaluate(() =>document.documentElement.scrollWidth > window.innerWidth@@ -93,7 +92,6 @@ test.describe('Auth Pages Mobile', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check form inputs have adequate heightconst inputs = page.locator('input[type="text"], input[type="password"], input[type="email"]');@@ -125,7 +123,6 @@ test.describe('Auth Pages Mobile', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const submitButton = page.locator('button[type="submit"]');await expect(submitButton).toBeVisible();@@ -158,7 +155,6 @@ test.describe('Auth Pages Mobile', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const criticalErrors = errors.filter((err) =>@@ -184,7 +180,6 @@ test.describe('Auth Pages Mobile', () => {test('displays login form correctly', async ({ page }) => {await page.goto('/auth/login');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check for page title/headerawait expect(page.locator('h1')).toContainText(/Local Deep Research|Login/i);@@ -215,7 +210,6 @@ test.describe('Auth Pages Mobile', () => {await page.goto('/auth/login');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const rememberCheckbox = page.locator('input[name="remember"]');if (await rememberCheckbox.count() > 0) {@@ -232,7 +226,6 @@ test.describe('Auth Pages Mobile', () => {test('displays registration form correctly', async ({ page }) => {await page.goto('/auth/register');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check for page headerawait expect(page.locator('h1')).toContainText(/Create Account|Register/i);@@ -251,7 +244,6 @@ test.describe('Auth Pages Mobile', () => {test('password requirements section is visible', async ({ page }) => {await page.goto('/auth/register');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const passwordRequirements = page.locator('.ldr-password-requirements');if (await passwordRequirements.count() > 0) {@@ -273,7 +265,6 @@ test.describe('Auth Pages Mobile', () => {await page.goto('/auth/register');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const acknowledgeBox = page.locator('.ldr-acknowledge-box');if (await acknowledgeBox.count() > 0) {@@ -294,13 +285,11 @@ test.describe('Auth Pages Mobile', () => {test('can navigate from login to register', async ({ page }) => {await page.goto('/auth/login');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const registerLink = page.locator('a[href*="register"]');if (await registerLink.count() > 0) {await registerLink.click();await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);expect(page.url()).toContain('/auth/register');}@@ -309,13 +298,11 @@ test.describe('Auth Pages Mobile', () => {test('can navigate from register to login', async ({ page }) => {await page.goto('/auth/register');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const loginLink = page.locator('a[href*="login"]');await expect(loginLink).toBeVisible();await loginLink.click();await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);expect(page.url()).toContain('/auth/login');});@@ -341,7 +328,6 @@ test.describe('Auth Pages Mobile', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check no horizontal overflowconst hasOverflow = await page.evaluate(() =>@@ -367,7 +353,6 @@ test.describe('Auth Pages Mobile', () => {test(`${pageInfo.name} - screenshot`, async ({ page, isMobile }) => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Ensure sheets are closed on mobileif (isMobile) {diff --git a/tests/ui_tests/playwright/tests/benchmark-page-mobile.spec.js b/tests/ui_tests/playwright/tests/benchmark-page-mobile.spec.jsindex b33f4449fe..f20ddc55eb 100644--- a/tests/ui_tests/playwright/tests/benchmark-page-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/benchmark-page-mobile.spec.js@@ -36,7 +36,6 @@ test.describe('Benchmark Page - Load Tests', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const criticalErrors = errors.filter((err) =>@@ -55,7 +54,6 @@ test.describe('Benchmark Page - Load Tests', () => {test('has no horizontal overflow', async ({ page }) => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const hasOverflow = await page.evaluate(() =>document.documentElement.scrollWidth > window.innerWidth@@ -78,7 +76,6 @@ test.describe('Benchmark Page - Load Tests', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator(MOBILE_NAV_SELECTOR);await expect(mobileNav).toBeVisible();@@ -93,7 +90,6 @@ test.describe('Benchmark Page - Content', () => {test('shows page heading', async ({ page }) => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check for Benchmark headingconst heading = page.locator('h1, h2, .ldr-page-title').filter({ hasText: /benchmark/i });@@ -103,7 +99,6 @@ test.describe('Benchmark Page - Content', () => {test('shows benchmark form or controls', async ({ page }) => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check for form elements or benchmark controlsconst formElements = page.locator('form, input, select, button, .ldr-benchmark-form, .ldr-benchmark-controls');@@ -115,7 +110,6 @@ test.describe('Benchmark Page - Content', () => {test('shows description or instructions', async ({ page }) => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check for description textconst description = page.locator('p, .ldr-description, .ldr-instructions');@@ -133,7 +127,6 @@ test.describe('Benchmark Page - Form Elements', () => {test('input fields are accessible', async ({ page }) => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const inputs = page.locator('input:visible, select:visible, textarea:visible');const count = await inputs.count();@@ -154,7 +147,6 @@ test.describe('Benchmark Page - Form Elements', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const inputs = page.locator('input:visible, select:visible');const count = await inputs.count();@@ -179,7 +171,6 @@ test.describe('Benchmark Page - Form Elements', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const buttons = page.locator('button:visible');const count = await buttons.count();@@ -199,7 +190,6 @@ test.describe('Benchmark Page - Form Elements', () => {test('dropdowns/selects work correctly', async ({ page }) => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const selects = page.locator('select:visible');const count = await selects.count();@@ -226,7 +216,7 @@ test.describe('Benchmark Page - Visual Regression', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-benchmark-chart, canvas, .ldr-chart', { timeout: 15000 }).catch(() => {});await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('benchmark-page-full.png', {@@ -243,7 +233,6 @@ test.describe('Benchmark Page - Visual Regression', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Scroll to top to capture headerawait page.evaluate(() => window.scrollTo(0, 0));@@ -264,7 +253,7 @@ test.describe('Benchmark Page - Visual Regression', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);+ await page.waitForSelector('.ldr-benchmark-chart, canvas, .ldr-chart', { timeout: 15000 }).catch(() => {});await ensureSheetsClosed(page);// Take viewport screenshot of the form area instead of element screenshot@@ -283,7 +272,7 @@ test.describe('Benchmark Page - Visual Regression', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);+ await page.waitForSelector('.ldr-benchmark-chart, canvas, .ldr-chart', { timeout: 15000 }).catch(() => {});await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('benchmark-viewport.png', {@@ -301,7 +290,6 @@ test.describe('Benchmark Page - Results Display', () => {test('results area exists or shows placeholder', async ({ page }) => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check for results area, chart, or placeholderconst resultsArea = page.locator('.ldr-benchmark-results, .ldr-results, canvas, [data-testid="results"], .ldr-chart');@@ -334,11 +322,10 @@ test.describe('Benchmark Page - Content Visibility', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Scroll to bottomawait page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);const mobileNav = page.locator(MOBILE_NAV_SELECTOR);const navBox = await mobileNav.boundingBox();@@ -377,11 +364,11 @@ test.describe('Benchmark Page - Scrolled Views', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);+ await page.waitForSelector('.ldr-benchmark-chart, canvas, .ldr-chart', { timeout: 15000 }).catch(() => {});// Scroll down to show more contentawait page.evaluate(() => window.scrollTo(0, 300));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('benchmark-scrolled.png', {diff --git a/tests/ui_tests/playwright/tests/breakpoint-edge-cases.spec.js b/tests/ui_tests/playwright/tests/breakpoint-edge-cases.spec.jsindex 70227b7644..38b217226c 100644--- a/tests/ui_tests/playwright/tests/breakpoint-edge-cases.spec.js+++ b/tests/ui_tests/playwright/tests/breakpoint-edge-cases.spec.js@@ -37,7 +37,6 @@ test.describe('Breakpoint Edge Cases - Mobile Nav Boundary', () => {const page = await context.newPage();await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator('.ldr-mobile-bottom-nav');await expect(mobileNav, 'Mobile nav visible at 766px').toBeVisible();@@ -53,7 +52,6 @@ test.describe('Breakpoint Edge Cases - Mobile Nav Boundary', () => {const page = await context.newPage();await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator('.ldr-mobile-bottom-nav');await expect(mobileNav, 'Mobile nav visible at 767px').toBeVisible();@@ -69,7 +67,6 @@ test.describe('Breakpoint Edge Cases - Mobile Nav Boundary', () => {const page = await context.newPage();await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator('.ldr-mobile-bottom-nav');await expect(mobileNav, 'Mobile nav hidden at 768px').not.toBeVisible();@@ -85,7 +82,6 @@ test.describe('Breakpoint Edge Cases - Mobile Nav Boundary', () => {const page = await context.newPage();await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator('.ldr-mobile-bottom-nav');await expect(mobileNav, 'Mobile nav hidden at 769px').not.toBeVisible();@@ -109,7 +105,6 @@ test.describe('Breakpoint Edge Cases - Sidebar Width', () => {const page = await context.newPage();await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const sidebar = page.locator('.ldr-sidebar');@@ -150,12 +145,10 @@ test.describe('Breakpoint Edge Cases - No Overflow', () => {const page = await context.newPage();await page.goto(path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Wait for settings spinner to disappear if on settings pageif (path === '/settings/') {await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);}const hasOverflow = await page.evaluate(() =>@@ -179,7 +172,6 @@ test.describe('Breakpoint Edge Cases - Content Layout', () => {const page = await context.newPage();await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Mobile nav should be visibleconst mobileNav = page.locator('.ldr-mobile-bottom-nav');@@ -202,7 +194,6 @@ test.describe('Breakpoint Edge Cases - Content Layout', () => {const page = await context.newPage();await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Mobile nav should NOT be visibleconst mobileNav = page.locator('.ldr-mobile-bottom-nav');@@ -228,7 +219,6 @@ test.describe('Breakpoint Edge Cases - Content Layout', () => {const page = await context.newPage();await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Sidebar should be visible and expandedconst sidebar = page.locator('.ldr-sidebar');@@ -253,7 +243,6 @@ test.describe('Breakpoint Edge Cases - Touch Targets at Boundaries', () => {const page = await context.newPage();await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check mobile nav touch targetsconst navItems = page.locator('.ldr-mobile-bottom-nav a, .ldr-mobile-bottom-nav button');@@ -280,7 +269,6 @@ test.describe('Breakpoint Edge Cases - Touch Targets at Boundaries', () => {const page = await context.newPage();await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check sidebar nav touch targets (if visible)const sidebarItems = page.locator('.ldr-sidebar a, .ldr-sidebar button');diff --git a/tests/ui_tests/playwright/tests/desktop-layout.spec.js b/tests/ui_tests/playwright/tests/desktop-layout.spec.jsindex b59e499910..efce1ab9c3 100644--- a/tests/ui_tests/playwright/tests/desktop-layout.spec.js+++ b/tests/ui_tests/playwright/tests/desktop-layout.spec.js@@ -59,7 +59,6 @@ async function setupDesktopPage(page, path, width = 1200, height = 800) {await page.setViewportSize({ width, height });await page.goto(path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);}/**@@ -225,7 +224,6 @@ test.describe('Auth Pages - Desktop Layout', () => {await page.setViewportSize({ width: 1200, height: 800 });await page.goto('/auth/login');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// When authenticated, may redirect to main page or show sidebar// Just verify page loads and check sidebar if present@@ -246,7 +244,6 @@ test.describe('Auth Pages - Desktop Layout', () => {await page.setViewportSize({ width: 1200, height: 800 });await page.goto('/auth/register');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// When authenticated, may redirect or show different contentif (await hasSidebar(page)) {@@ -395,7 +392,7 @@ test.describe('Desktop Screenshots - Auth Pages', () => {await page.setViewportSize({ width: 1200, height: 800 });await page.goto('/auth/login');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);+ await page.waitForTimeout(200);await expect(page).toHaveScreenshot('desktop-auth-login-1200px.png', {maxDiffPixelRatio: 0.02,@@ -408,7 +405,7 @@ test.describe('Desktop Screenshots - Auth Pages', () => {await page.setViewportSize({ width: 1200, height: 800 });await page.goto('/auth/register');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);+ await page.waitForTimeout(200);await expect(page).toHaveScreenshot('desktop-auth-register-1200px.png', {maxDiffPixelRatio: 0.02,diff --git a/tests/ui_tests/playwright/tests/empty-states-mobile.spec.js b/tests/ui_tests/playwright/tests/empty-states-mobile.spec.jsindex 63880594fd..29569ce84d 100644--- a/tests/ui_tests/playwright/tests/empty-states-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/empty-states-mobile.spec.js@@ -27,7 +27,6 @@ test.describe('Empty States - History', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);// Check for empty state indicator@@ -50,7 +49,6 @@ test.describe('Empty States - History', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);const contentArea = page.locator('.ldr-history-content, .ldr-content, main').first();@@ -75,7 +73,6 @@ test.describe('Empty States - Library', () => {await page.goto('/library/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('empty-state-library.png', {@@ -92,7 +89,6 @@ test.describe('Empty States - Library', () => {await page.goto('/library/collections');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);// Check for empty collections indicator@@ -115,7 +111,6 @@ test.describe('Empty States - Library', () => {await page.goto('/library/download-manager');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('empty-state-downloads.png', {@@ -138,7 +133,7 @@ test.describe('Empty States - News', () => {await page.goto('/news/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1500); // Allow time for feed to load+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('empty-state-news-feed.png', {@@ -155,7 +150,6 @@ test.describe('Empty States - News', () => {await page.goto('/news/subscriptions');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);// Check for empty subscriptions indicator@@ -184,7 +178,6 @@ test.describe('Empty States - Metrics', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('empty-state-metrics-dashboard.png', {@@ -201,7 +194,6 @@ test.describe('Empty States - Metrics', () => {await page.goto('/metrics/context-overflow');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('empty-state-context-overflow.png', {@@ -218,7 +210,6 @@ test.describe('Empty States - Metrics', () => {await page.goto('/metrics/star-reviews');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('empty-state-star-reviews.png', {@@ -235,7 +226,6 @@ test.describe('Empty States - Metrics', () => {await page.goto('/metrics/costs');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('empty-state-cost-analytics.png', {@@ -252,7 +242,6 @@ test.describe('Empty States - Metrics', () => {await page.goto('/metrics/links');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('empty-state-link-analytics.png', {@@ -282,7 +271,6 @@ test.describe('Empty States - Styling Verification', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);// Look for empty state textconst emptyText = page.locator('text=/no.*found|empty|create.*first|get.*started/i');@@ -314,7 +302,6 @@ test.describe('Empty States - Styling Verification', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);// Look for empty state textconst emptyText = page.locator('text=/no.*found|empty|create.*first|get.*started/i');@@ -344,7 +331,6 @@ test.describe('Empty States - Call to Action', () => {await page.goto('/library/collections');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);// Take screenshot to verify create button is present visually@@ -362,7 +348,6 @@ test.describe('Empty States - Call to Action', () => {await page.goto('/news/subscriptions');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);await ensureSheetsClosed(page);// Take screenshot to verify create button is present visually@@ -380,7 +365,6 @@ test.describe('Empty States - Call to Action', () => {await page.goto('/news/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);// Look for create subscription linkconst createLink = page.locator('a, button').filter({ hasText: /create.*subscription|new.*subscription|subscribe/i });diff --git a/tests/ui_tests/playwright/tests/helpers/mobile-utils.js b/tests/ui_tests/playwright/tests/helpers/mobile-utils.jsindex 89aad529b1..f5a571e7d0 100644--- a/tests/ui_tests/playwright/tests/helpers/mobile-utils.js+++ b/tests/ui_tests/playwright/tests/helpers/mobile-utils.js@@ -51,15 +51,15 @@ async function waitForPageLoad(page, pageInfoOrPath) {const loadState = pageInfo.loadState || 'domcontentloaded';await page.waitForLoadState(loadState);- await page.waitForTimeout(500);+ await page.waitForTimeout(200);// Additional waits for specific pagesif (path === '/settings/' || path === '/settings') {await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});} else if (path.includes('/benchmark')) {- await page.waitForTimeout(500);- } else if (path.includes('/metrics')) {await page.waitForTimeout(300);+ } else if (path.includes('/metrics')) {+ await page.waitForTimeout(200);}}diff --git a/tests/ui_tests/playwright/tests/history-page-mobile.spec.js b/tests/ui_tests/playwright/tests/history-page-mobile.spec.jsindex 6c97c4749b..58eb950692 100644--- a/tests/ui_tests/playwright/tests/history-page-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/history-page-mobile.spec.js@@ -37,7 +37,6 @@ test.describe('History Page - Load Tests', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const criticalErrors = errors.filter((err) =>@@ -56,7 +55,6 @@ test.describe('History Page - Load Tests', () => {test('has no horizontal overflow', async ({ page }) => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const hasOverflow = await page.evaluate(() =>document.documentElement.scrollWidth > window.innerWidth@@ -79,7 +77,6 @@ test.describe('History Page - Load Tests', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator(MOBILE_NAV_SELECTOR);await expect(mobileNav).toBeVisible();@@ -94,7 +91,6 @@ test.describe('History Page - Content', () => {test('shows page heading', async ({ page }) => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check for Research History headingconst heading = page.locator('h1, h2, .ldr-page-title').filter({ hasText: /history/i });@@ -104,7 +100,6 @@ test.describe('History Page - Content', () => {test('shows search input', async ({ page }) => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check for search inputconst searchInput = page.locator('input[type="search"], input[placeholder*="search" i], input[placeholder*="Search" i]');@@ -119,7 +114,6 @@ test.describe('History Page - Content', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const searchInput = page.locator('input[type="search"], input[placeholder*="search" i], input[placeholder*="Search" i]').first();@@ -132,7 +126,7 @@ test.describe('History Page - Content', () => {test('shows empty state or history items', async ({ page }) => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-content, main, .ldr-history-list', { timeout: 5000 });// Either shows empty state message or history itemsconst emptyState = page.locator('text=/no.*history.*found|no.*research.*found|empty/i');@@ -161,7 +155,7 @@ test.describe('History Page - Empty State', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-content, main, .ldr-history-list', { timeout: 5000 });const emptyState = page.locator('text=/no.*history|no.*research|empty/i');@@ -186,7 +180,7 @@ test.describe('History Page - Empty State', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);+ await page.waitForTimeout(200);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('history-empty-state.png', {@@ -204,7 +198,6 @@ test.describe('History Page - Search Functionality', () => {test('search input is focusable', async ({ page }) => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const searchInput = page.locator('input[type="search"], input[placeholder*="search" i]').first();@@ -217,7 +210,6 @@ test.describe('History Page - Search Functionality', () => {test('search input accepts text', async ({ page }) => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const searchInput = page.locator('input[type="search"], input[placeholder*="search" i]').first();@@ -235,13 +227,12 @@ test.describe('History Page - Search Functionality', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const searchInput = page.locator('input[type="search"], input[placeholder*="search" i]').first();if (await searchInput.isVisible()) {await searchInput.fill('climate change');- await page.waitForTimeout(300);+ await page.waitForTimeout(200);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('history-search-active.png', {@@ -265,7 +256,7 @@ test.describe('History Page - Visual Regression', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);+ await page.waitForTimeout(200);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('history-page-full.png', {@@ -282,7 +273,6 @@ test.describe('History Page - Visual Regression', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Scroll to top to capture headerawait page.evaluate(() => window.scrollTo(0, 0));@@ -309,7 +299,7 @@ test.describe('History Page - Visual Regression', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);+ await page.waitForTimeout(200);await ensureSheetsClosed(page);// Capture mobile nav area to verify History is highlighted@@ -335,7 +325,6 @@ test.describe('History Page - Touch Targets', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check buttonsconst buttons = page.locator('button:visible');@@ -388,11 +377,10 @@ test.describe('History Page - Content Visibility', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Scroll to bottomawait page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);const mobileNav = page.locator(MOBILE_NAV_SELECTOR);const navBox = await mobileNav.boundingBox();diff --git a/tests/ui_tests/playwright/tests/interactive-states.spec.js b/tests/ui_tests/playwright/tests/interactive-states.spec.jsindex 923ff305d0..0e20c06c2a 100644--- a/tests/ui_tests/playwright/tests/interactive-states.spec.js+++ b/tests/ui_tests/playwright/tests/interactive-states.spec.js@@ -37,10 +37,10 @@ test.describe('Research - Advanced Options Expanded', () => {if (await toggleBtn.count() > 0 && await toggleBtn.isVisible()) {// Click to expandawait toggleBtn.click();- await page.waitForTimeout(500); // Wait for animation// Check panel is visibleconst panel = page.locator('.ldr-advanced-options-panel, #advanced-options-panel');+ await panel.first().waitFor({ state: 'visible' });if (await panel.count() > 0) {await expect(panel.first()).toBeVisible();}@@ -77,7 +77,7 @@ test.describe('Research - Advanced Options Expanded', () => {if (await toggleBtn.count() > 0 && await toggleBtn.isVisible()) {await toggleBtn.click();- await page.waitForTimeout(500);+ await page.waitForTimeout(200);if (isMobile) {await ensureSheetsClosed(page);@@ -106,7 +106,7 @@ test.describe('Research - Advanced Options Expanded', () => {if (await toggleBtn.count() > 0 && await toggleBtn.isVisible()) {await toggleBtn.click();- await page.waitForTimeout(500);+ await page.locator('.ldr-advanced-options-panel, #advanced-options-panel').first().waitFor({ state: 'visible' });const panel = page.locator('.ldr-advanced-options-panel, #advanced-options-panel');if (await panel.count() > 0 && await panel.first().isVisible()) {@@ -140,7 +140,7 @@ test.describe('Settings - Search Filtering', () => {if (await searchInput.count() > 0 && await searchInput.isVisible()) {await searchInput.fill('model');- await page.waitForTimeout(500); // Wait for filter to apply+ await page.locator('.ldr-settings-group, .ldr-setting-item, [class*="setting"]').first().waitFor({ state: 'visible' });// Some settings should be visible (matching "model")const visibleSettings = await page.evaluate(() => {@@ -166,7 +166,7 @@ test.describe('Settings - Search Filtering', () => {if (await searchInput.count() > 0 && await searchInput.isVisible()) {await searchInput.fill('model');- await page.waitForTimeout(500);+ await page.waitForTimeout(200);if (isMobile) {await ensureSheetsClosed(page);@@ -184,7 +184,17 @@ test.describe('Settings - Search Filtering', () => {if (await searchInput.count() > 0 && await searchInput.isVisible()) {await searchInput.fill('zzz_nonexistent_setting_xyz');- await page.waitForTimeout(500);+ await page.waitForFunction(() => {+ const items = document.querySelectorAll('.ldr-settings-group, .ldr-setting-item, [class*="setting"]');+ let visibleCount = 0;+ items.forEach(el => {+ const style = window.getComputedStyle(el);+ if (style.display !== 'none' && style.visibility !== 'hidden' && el.getBoundingClientRect().height > 0) {+ visibleCount++;+ }+ });+ return visibleCount < 5;+ }, { timeout: 5000 }).catch(() => {});// Check that no settings are visible or an empty state is shownconst visibleSettings = await page.evaluate(() => {@@ -212,7 +222,7 @@ test.describe('Settings - Search Filtering', () => {if (await searchInput.count() > 0 && await searchInput.isVisible()) {await searchInput.fill('zzz_nonexistent_setting_xyz');- await page.waitForTimeout(500);+ await page.waitForTimeout(200);if (isMobile) {await ensureSheetsClosed(page);@@ -251,15 +261,14 @@ test.describe('Mobile More Menu - Navigation', () => {if (await moreBtn.count() > 0) {await moreBtn.click();- await page.waitForTimeout(300);// Look for Metrics link in the opened menu/sheetconst metricsLink = page.locator('a:has-text("Metrics"), [href*="metrics"]');+ await metricsLink.first().waitFor({ state: 'visible' });if (await metricsLink.count() > 0 && await metricsLink.first().isVisible()) {await metricsLink.first().click();await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Should now be on the metrics pageexpect(page.url()).toContain('/metrics');@@ -286,14 +295,13 @@ test.describe('Mobile More Menu - Navigation', () => {if (await moreBtn.count() > 0) {await moreBtn.click();- await page.waitForTimeout(300);const libraryLink = page.locator('a:has-text("Library"), [href*="library"]');+ await libraryLink.first().waitFor({ state: 'visible' });if (await libraryLink.count() > 0 && await libraryLink.first().isVisible()) {await libraryLink.first().click();await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);expect(page.url()).toContain('/library');}@@ -319,7 +327,7 @@ test.describe('Mobile More Menu - Navigation', () => {if (await moreBtn.count() > 0) {await moreBtn.click();- await page.waitForTimeout(500);+ await page.waitForTimeout(200);await expect(page).toHaveScreenshot('mobile-more-menu-open.png', {fullPage: false,@@ -337,7 +345,6 @@ test.describe('Benchmark Form - Visual Regression', () => {test.beforeEach(async ({ page }) => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Wait for benchmark form to loadawait page.waitForSelector('#settings-form, form, .ldr-card', { timeout: 10000 }).catch(() => {});});@@ -363,7 +370,7 @@ test.describe('Benchmark Form - Visual Regression', () => {// Scroll to bottom of the formawait page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);await expect(page).toHaveScreenshot('benchmark-form-bottom.png', {fullPage: false,@@ -394,7 +401,7 @@ test.describe('Help Panel - Expanded State', () => {if (await helpToggle.count() > 0 && await helpToggle.first().isVisible()) {await helpToggle.first().click();- await page.waitForTimeout(500);+ await page.locator('.ldr-help-panel, [class*="help-panel"]').first().waitFor({ state: 'visible' });// Check for overflowconst hasOverflow = await page.evaluate(() =>@@ -413,7 +420,7 @@ test.describe('Help Panel - Expanded State', () => {if (await helpToggle.count() > 0 && await helpToggle.first().isVisible()) {await helpToggle.first().click();- await page.waitForTimeout(500);+ await page.locator('.ldr-help-panel, [class*="help-panel"]').first().waitFor({ state: 'visible' });if (isMobile) {// Don't remove sheets for this test since we want to see the help panel@@ -439,7 +446,7 @@ test.describe('Help Panel - Expanded State', () => {if (await helpToggle.count() > 0 && await helpToggle.first().isVisible()) {await helpToggle.first().click();- await page.waitForTimeout(500);+ await page.locator('.ldr-help-panel, [class*="help-panel"]').first().waitFor({ state: 'visible' });if (isMobile) {await ensureSheetsClosed(page);diff --git a/tests/ui_tests/playwright/tests/library-subpages-mobile.spec.js b/tests/ui_tests/playwright/tests/library-subpages-mobile.spec.jsindex e1e9db428c..37e0a2d08f 100644--- a/tests/ui_tests/playwright/tests/library-subpages-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/library-subpages-mobile.spec.js@@ -53,7 +53,6 @@ test.describe('Library Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const criticalErrors = errors.filter((err) =>@@ -72,7 +71,6 @@ test.describe('Library Subpages - Common Mobile Tests', () => {test('has no horizontal overflow', async ({ page }) => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const hasOverflow = await page.evaluate(() =>document.documentElement.scrollWidth > window.innerWidth@@ -95,7 +93,6 @@ test.describe('Library Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator(MOBILE_NAV_SELECTOR);await expect(mobileNav, 'Mobile nav should be visible').toBeVisible();@@ -115,7 +112,6 @@ test.describe('Library Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const smallTargets = await page.evaluate((MIN_SIZE) => {const elements = document.querySelectorAll(@@ -169,10 +165,9 @@ test.describe('Library Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);const result = await page.evaluate((navSelector) => {const mobileNav = document.querySelector(navSelector);@@ -227,7 +222,6 @@ test.describe('Library Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);await page.evaluate(() => window.scrollTo(0, 0));await page.waitForTimeout(200);@@ -251,7 +245,6 @@ test.describe('Collections Page - Specific Tests', () => {test.beforeEach(async ({ page }) => {await page.goto('/library/collections');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('page content loads', async ({ page }) => {@@ -304,7 +297,6 @@ test.describe('Create Collection Page - Specific Tests', () => {test.beforeEach(async ({ page }) => {await page.goto('/library/collections/create');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('displays form or creation UI', async ({ page }) => {@@ -371,7 +363,6 @@ test.describe('Download Manager Page - Specific Tests', () => {test.beforeEach(async ({ page }) => {await page.goto('/library/download-manager');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('page content loads', async ({ page }) => {@@ -434,7 +425,6 @@ test.describe('Embedding Settings Page - Specific Tests', () => {test.beforeEach(async ({ page }) => {await page.goto('/library/embedding-settings');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('page content loads', async ({ page }) => {diff --git a/tests/ui_tests/playwright/tests/loading-states-mobile.spec.js b/tests/ui_tests/playwright/tests/loading-states-mobile.spec.jsindex d41979a9ad..8d9556e86f 100644--- a/tests/ui_tests/playwright/tests/loading-states-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/loading-states-mobile.spec.js@@ -105,7 +105,6 @@ test.describe('Loading States - Settings Page', () => {// Wait for loading spinner to disappearawait page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(500);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('loaded-state-settings.png', {@@ -153,7 +152,7 @@ test.describe('Loading States - News Page', () => {await page.goto('/news/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1500); // Allow feed content to load+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('loaded-state-news.png', {@@ -200,7 +199,7 @@ test.describe('Loading States - Metrics Page', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('loaded-state-metrics.png', {@@ -223,7 +222,7 @@ test.describe('Loading States - Library Page', () => {await page.goto('/library/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('loaded-state-library.png', {@@ -240,7 +239,7 @@ test.describe('Loading States - Library Page', () => {await page.goto('/library/collections');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('loaded-state-collections.png', {@@ -326,17 +325,16 @@ test.describe('Loading States - Page Transitions', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Click on settings in mobile navconst moreButton = page.locator('.ldr-mobile-bottom-nav a, .ldr-mobile-bottom-nav button').filter({ hasText: /more/i });if (await moreButton.isVisible()) {await moreButton.click();- await page.waitForTimeout(300);// Look for settings linkconst settingsLink = page.locator('a').filter({ hasText: /settings/i });+ await settingsLink.first().waitFor({ state: 'visible', timeout: 5000 }).catch(() => {});if (await settingsLink.first().isVisible()) {await settingsLink.first().click();@@ -345,7 +343,6 @@ test.describe('Loading States - Page Transitions', () => {// Wait for page loadawait page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Verify we're on settings pageconst isOnSettings = page.url().includes('/settings');@@ -368,7 +365,7 @@ test.describe('Loading States - Button States', () => {await page.goto('/news/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});// Find refresh buttonconst refreshButton = page.locator('button').filter({ hasText: /refresh/i });@@ -382,8 +379,8 @@ test.describe('Loading States - Button States', () => {// Click and try to capture loading stateawait refreshButton.first().click();- // The button might show a loading state briefly- await page.waitForTimeout(200);+ // Wait for button to settle after click+ await refreshButton.first().waitFor({ state: 'visible', timeout: 5000 }).catch(() => {});// Note: Loading state may be too brief to capture consistently}@@ -411,7 +408,8 @@ test.describe('Loading States - Component Loading', () => {const llmTab = page.locator('[data-tab="llm"]');if (await llmTab.isVisible()) {await llmTab.click();- await page.waitForTimeout(1000);+ await llmTab.waitFor({ state: 'visible', timeout: 5000 }).catch(() => {});+ await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});// Model dropdowns may show refresh buttonsconst refreshButtons = page.locator('button[title*="refresh" i], button[aria-label*="refresh" i], .ldr-refresh-btn');diff --git a/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.js b/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.jsindex e7057b9215..411ca6853e 100644--- a/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/metrics-subpages-mobile.spec.js@@ -44,7 +44,6 @@ test.describe('Metrics Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const criticalErrors = errors.filter((err) =>@@ -65,7 +64,6 @@ test.describe('Metrics Subpages - Common Mobile Tests', () => {test('has no horizontal overflow', async ({ page }) => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const hasOverflow = await page.evaluate(() =>document.documentElement.scrollWidth > window.innerWidth@@ -89,7 +87,6 @@ test.describe('Metrics Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator(MOBILE_NAV_SELECTOR);await expect(mobileNav, 'Mobile nav should be visible').toBeVisible();@@ -110,7 +107,6 @@ test.describe('Metrics Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const smallTargets = await page.evaluate((MIN_SIZE) => {const elements = document.querySelectorAll(@@ -150,7 +146,6 @@ test.describe('Metrics Subpages - Common Mobile Tests', () => {test('Back to Metrics button is visible and tappable', async ({ page, isMobile }) => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Find the Back to Metrics link/buttonconst backButton = page.locator('a:has-text("Back to Metrics"), button:has-text("Back to Metrics")').first();@@ -167,7 +162,6 @@ test.describe('Metrics Subpages - Common Mobile Tests', () => {// Click and verify navigationawait backButton.click();await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);expect(page.url()).toContain('/metrics');expect(page.url()).not.toContain(pageInfo.path.replace('/metrics/', ''));@@ -188,11 +182,10 @@ test.describe('Metrics Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Scroll to bottomawait page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);const result = await page.evaluate((navSelector) => {const mobileNav = document.querySelector(navSelector);@@ -242,7 +235,6 @@ test.describe('Metrics Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);// Scroll to top@@ -268,7 +260,6 @@ test.describe('Context Overflow Page - Specific Tests', () => {test.beforeEach(async ({ page }) => {await page.goto('/metrics/context-overflow');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('displays page header correctly', async ({ page }) => {@@ -330,7 +321,7 @@ test.describe('Context Overflow Page - Specific Tests', () => {// Click to change time rangeawait btn7d.click();- await page.waitForTimeout(300);+ await btn7d.waitFor({ state: 'attached' });// Should now be activeawait expect(btn7d).toHaveClass(/active/);@@ -345,7 +336,6 @@ test.describe('Star Reviews Page - Specific Tests', () => {test.beforeEach(async ({ page }) => {await page.goto('/metrics/star-reviews');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('displays page header correctly', async ({ page }) => {@@ -361,7 +351,7 @@ test.describe('Star Reviews Page - Specific Tests', () => {});test('overall stats section visible after loading', async ({ page }) => {- await page.waitForTimeout(1000); // Wait for data to load+ await page.waitForSelector('.ldr-metric-card, .ldr-chart, canvas, .ldr-metrics-content', { timeout: 15000 }).catch(() => {});const statsSection = page.locator('.ldr-overall-stats');if (await statsSection.count() > 0 && await statsSection.isVisible()) {@@ -373,7 +363,7 @@ test.describe('Star Reviews Page - Specific Tests', () => {});test('rating distribution bars visible', async ({ page }) => {- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-metric-card, .ldr-chart, canvas, .ldr-metrics-content', { timeout: 15000 }).catch(() => {});const ratingDistribution = page.locator('.ldr-rating-distribution, .ldr-rating-bar').first();if (await ratingDistribution.count() > 0) {@@ -382,7 +372,7 @@ test.describe('Star Reviews Page - Specific Tests', () => {});test('charts containers present', async ({ page }) => {- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-metric-card, .ldr-chart, canvas, .ldr-metrics-content', { timeout: 15000 }).catch(() => {});// Check for chart containersconst chartContainers = page.locator('.ldr-chart-container, .ldr-metric-card canvas').first();@@ -400,7 +390,6 @@ test.describe('Cost Analytics Page - Specific Tests', () => {test.beforeEach(async ({ page }) => {await page.goto('/metrics/costs');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('displays page header correctly', async ({ page }) => {@@ -422,7 +411,7 @@ test.describe('Cost Analytics Page - Specific Tests', () => {test('shows content or disabled state', async ({ page }) => {// Cost analytics may show a disabled message or content grid- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-metric-card, .ldr-chart, canvas, .ldr-metrics-content', { timeout: 15000 }).catch(() => {});// Check if any content is visible (either enabled content or disabled message)const contentGrid = page.locator('.ldr-cost-grid');@@ -460,7 +449,6 @@ test.describe('Link Analytics Page - Specific Tests', () => {test.beforeEach(async ({ page }) => {await page.goto('/metrics/links');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('displays page header correctly', async ({ page }) => {@@ -476,7 +464,7 @@ test.describe('Link Analytics Page - Specific Tests', () => {});test('overall stats cards visible after loading', async ({ page }) => {- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-metric-card, .ldr-chart, canvas, .ldr-metrics-content', { timeout: 15000 }).catch(() => {});const statsSection = page.locator('.ldr-overall-stats');if (await statsSection.count() > 0 && await statsSection.isVisible()) {@@ -487,7 +475,7 @@ test.describe('Link Analytics Page - Specific Tests', () => {});test('charts or metric cards present', async ({ page }) => {- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-metric-card, .ldr-chart, canvas, .ldr-metrics-content', { timeout: 15000 }).catch(() => {});// Look for chart containers or metric cards - check if any are visibleconst chartContainers = page.locator('.ldr-chart-container:visible, .ldr-metric-card:visible');@@ -499,7 +487,7 @@ test.describe('Link Analytics Page - Specific Tests', () => {});test('page has main content container', async ({ page }) => {- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-metric-card, .ldr-chart, canvas, .ldr-metrics-content', { timeout: 15000 }).catch(() => {});// Check that the page has main content - either domain list, charts, or statsconst mainContainer = page.locator('.ldr-link-analytics-container, .ldr-metrics-grid, .ldr-overall-stats').first();@@ -529,9 +517,7 @@ test.describe('Metrics Subpages - Component Screenshots', () => {await page.goto('/metrics/context-overflow');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('#loading', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);await ensureSheetsClosed(page);const overflowGrid = page.locator('.ldr-overflow-grid').first();@@ -550,8 +536,7 @@ test.describe('Metrics Subpages - Component Screenshots', () => {await page.goto('/metrics/star-reviews');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-metric-card, .ldr-chart, canvas, .ldr-metrics-content', { timeout: 15000 }).catch(() => {});await ensureSheetsClosed(page);const statsSection = page.locator('.ldr-overall-stats').first();@@ -570,8 +555,7 @@ test.describe('Metrics Subpages - Component Screenshots', () => {await page.goto('/metrics/links');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);- await page.waitForTimeout(1000);+ await page.waitForSelector('.ldr-metric-card, .ldr-chart, canvas, .ldr-metrics-content', { timeout: 15000 }).catch(() => {});await ensureSheetsClosed(page);const statsSection = page.locator('.ldr-overall-stats').first();@@ -590,7 +574,6 @@ test.describe('Metrics Subpages - Component Screenshots', () => {await page.goto('/metrics/costs');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const headerSection = page.locator('.ldr-cost-header, .ldr-cost-title').first();diff --git a/tests/ui_tests/playwright/tests/mobile-components.spec.js b/tests/ui_tests/playwright/tests/mobile-components.spec.jsindex 210d4faad9..de16917611 100644--- a/tests/ui_tests/playwright/tests/mobile-components.spec.js+++ b/tests/ui_tests/playwright/tests/mobile-components.spec.js@@ -36,7 +36,6 @@ test.describe('Mobile Navigation Components', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page, { preserveMobileNav: true });const nav = page.locator('.ldr-mobile-bottom-nav');@@ -62,17 +61,16 @@ test.describe('Mobile Navigation Components', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page, { preserveMobileNav: true });// Find and click the More buttonconst moreBtn = page.locator('[data-nav="more"], .ldr-nav-more-btn, .ldr-mobile-bottom-nav button:has-text("More")');if (await moreBtn.count() > 0) {await moreBtn.first().click();- await page.waitForTimeout(300);// Take screenshot of the sheetconst sheet = page.locator('.ldr-mobile-sheet');+ await sheet.waitFor({ state: 'visible', timeout: 5000 }).catch(() => {});if (await sheet.isVisible()) {await expect(sheet).toHaveScreenshot('mobile-nav-more-open.png', {maxDiffPixelRatio: 0.02,@@ -102,7 +100,6 @@ test.describe('Mobile Navigation Components', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const navItems = page.locator('.ldr-mobile-bottom-nav a, .ldr-mobile-bottom-nav button');const count = await navItems.count();@@ -132,7 +129,6 @@ test.describe('Form Components', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const textarea = page.locator('#query, textarea[name="query"], .ldr-research-textarea');if (await textarea.count() > 0) {@@ -150,7 +146,6 @@ test.describe('Form Components', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const startBtn = page.locator('#start-research-btn, button:has-text("Start Research")');if (await startBtn.count() > 0) {@@ -168,13 +163,12 @@ test.describe('Form Components', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const modeSelection = page.locator('.ldr-mode-selection');if (await modeSelection.count() > 0) {await modeSelection.first().scrollIntoViewIfNeeded();- await page.waitForTimeout(300);+ await page.waitForTimeout(200);await expect(modeSelection.first()).toHaveScreenshot('mode-selection.png', {maxDiffPixelRatio: 0.02,timeout: 10000,@@ -190,9 +184,7 @@ test.describe('Form Components', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);// Find a settings item with a checkboxconst settingItem = page.locator('.ldr-settings-item').filter({@@ -214,9 +206,7 @@ test.describe('Form Components', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);// Find a settings item with a select dropdownconst settingItem = page.locator('.ldr-settings-item').filter({@@ -238,9 +228,7 @@ test.describe('Form Components', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);// Find a settings item with a text inputconst settingItem = page.locator('.ldr-settings-item').filter({@@ -268,7 +256,6 @@ test.describe('Card Components', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Look for empty state message or card containerconst emptyState = page.locator('.ldr-empty-state, [class*="empty"], :text("No research history")');@@ -297,7 +284,6 @@ test.describe('Card Components', () => {await page.goto('/library/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Look for empty state or document listconst emptyState = page.locator('.ldr-empty-state, [class*="empty"], :text("No documents")');@@ -325,7 +311,6 @@ test.describe('Card Components', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const metricLink = page.locator('.ldr-metric-link').first();if (await metricLink.isVisible()) {@@ -349,7 +334,6 @@ test.describe('News Page Components', () => {await page.goto('/news/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Look for template cardsconst template = page.locator('[class*="template"], .news-template, .ldr-subscription-template').first();@@ -368,7 +352,6 @@ test.describe('News Page Components', () => {await page.goto('/news/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const createBtn = page.locator('button, a').filter({hasText: /Create.*Subscription/i,@@ -395,7 +378,6 @@ test.describe('Interaction States', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const toggle = page.locator('.ldr-advanced-options-toggle').first();if ((await toggle.count()) === 0 || !(await toggle.isVisible())) {@@ -407,7 +389,7 @@ test.describe('Interaction States', () => {const panel = page.locator('.ldr-advanced-options-panel');if (await panel.isVisible()) {await toggle.click();- await page.waitForTimeout(300);+ await panel.waitFor({ state: 'hidden' });}await expect(toggle).toHaveScreenshot('advanced-options-collapsed.png', {@@ -423,7 +405,6 @@ test.describe('Interaction States', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const toggle = page.locator('.ldr-advanced-options-toggle').first();if ((await toggle.count()) === 0 || !(await toggle.isVisible())) {@@ -435,7 +416,7 @@ test.describe('Interaction States', () => {const panel = page.locator('.ldr-advanced-options-panel');if (!(await panel.isVisible())) {await toggle.click();- await page.waitForTimeout(300);+ await panel.waitFor({ state: 'visible' });}if (!(await panel.isVisible())) {@@ -457,9 +438,7 @@ test.describe('Interaction States', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);const tabNav = page.locator('.ldr-settings-tabs, .ldr-tab-navigation, [role="tablist"]').first();if ((await tabNav.count()) === 0 || !(await tabNav.isVisible())) {@@ -480,7 +459,6 @@ test.describe('Interaction States', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const textarea = page.locator('#query, textarea[name="query"], .ldr-research-textarea').first();if (await textarea.isVisible()) {@@ -519,7 +497,6 @@ test.describe('Interaction States', () => {for (const pageInfo of pages) {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page, { preserveMobileNav: true });const nav = page.locator('.ldr-mobile-bottom-nav');@@ -569,7 +546,6 @@ test.describe('Loading and Error States', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Inject an error message element for testingawait page.evaluate(() => {@@ -599,7 +575,6 @@ test.describe('Loading and Error States', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);// Check for empty state message@@ -620,7 +595,6 @@ test.describe('Loading and Error States', () => {await page.goto('/library/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);// Check for empty state message@@ -653,7 +627,6 @@ test.describe('Metrics Page Sections', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(1000);// Find the System Overview header sectionconst overviewSection = page.locator('.ldr-metrics-grid').first();@@ -674,7 +647,6 @@ test.describe('Metrics Page Sections', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(1000);// Find the token chart containerconst chartContainer = page.locator('#time-series-chart').locator('..');@@ -695,7 +667,6 @@ test.describe('Metrics Page Sections', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(1000);// Find the search activity chartconst chartContainer = page.locator('#search-activity-chart').locator('..');@@ -716,7 +687,6 @@ test.describe('Metrics Page Sections', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(1000);// Find the model usage listconst modelUsageList = page.locator('#model-usage-list');@@ -737,7 +707,6 @@ test.describe('Metrics Page Sections', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(1000);// Find research analytics sectionconst analyticsSection = page.locator('#mode-breakdown').locator('..').locator('..');@@ -758,13 +727,12 @@ test.describe('Metrics Page Sections', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(1000);// Scroll to rate limiting sectionconst rateLimitSection = page.locator('#rate-limit-success-rate').locator('..').locator('..');if (await rateLimitSection.count() > 0) {await rateLimitSection.scrollIntoViewIfNeeded();- await page.waitForTimeout(300);+ await page.waitForTimeout(200);if (await rateLimitSection.isVisible()) {await ensureSheetsClosed(page);@@ -784,7 +752,6 @@ test.describe('Metrics Page Sections', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('#metrics-content', { state: 'visible', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(1000);await ensureSheetsClosed(page);// Take a viewport-only screenshot (not fullPage) for reliable baseline@@ -824,7 +791,6 @@ test.describe('Full Page Mobile Layouts', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page, { preserveMobileNav: true });await expect(page).toHaveScreenshot(`${pageInfo.name}-full-mobile.png`, {@@ -855,7 +821,6 @@ test.describe('Tablet Sidebar Navigation', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const sidebar = page.locator('.ldr-sidebar, nav[class*="sidebar"], aside');if (await sidebar.first().isVisible()) {@@ -879,7 +844,6 @@ test.describe('Tablet Sidebar Navigation', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('tablet-research-layout.png', {@@ -902,21 +866,20 @@ test.describe('Button States', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);// Clear the textarea to trigger disabled stateconst textarea = page.locator('#query, textarea[name="query"]');if (await textarea.isVisible()) {await textarea.clear();- await page.waitForTimeout(500);+ await page.locator('#start-research-btn, button:has-text("Start Research")').waitFor({ state: 'visible' });}const startBtn = page.locator('#start-research-btn, button:has-text("Start Research")');if (await startBtn.isVisible()) {// Wait for element to be stableawait startBtn.scrollIntoViewIfNeeded();- await page.waitForTimeout(300);+ await page.waitForTimeout(200);await expect(startBtn).toHaveScreenshot('start-research-btn-disabled.png', {maxDiffPixelRatio: 0.02,timeout: 10000,@@ -932,20 +895,19 @@ test.describe('Button States', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);// Fill textarea to enable the buttonconst textarea = page.locator('#query, textarea[name="query"]');if (await textarea.isVisible()) {await textarea.fill('Test research query');- await page.waitForTimeout(500);+ await page.locator('#start-research-btn, button:has-text("Start Research")').waitFor({ state: 'visible' });}const startBtn = page.locator('#start-research-btn, button:has-text("Start Research")');if (await startBtn.isVisible()) {await startBtn.scrollIntoViewIfNeeded();- await page.waitForTimeout(300);+ await page.waitForTimeout(200);await expect(startBtn).toHaveScreenshot('start-research-btn-enabled.png', {maxDiffPixelRatio: 0.02,timeout: 10000,@@ -961,15 +923,13 @@ test.describe('Button States', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(1000);await ensureSheetsClosed(page);const saveBtn = page.locator('button:has-text("Save"), button[type="submit"], .ldr-save-btn').first();if (await saveBtn.isVisible()) {await saveBtn.scrollIntoViewIfNeeded();- await page.waitForTimeout(300);+ await page.waitForTimeout(200);await expect(saveBtn).toHaveScreenshot('settings-save-button.png', {maxDiffPixelRatio: 0.02,timeout: 10000,@@ -998,17 +958,16 @@ test.describe('Modal and Sheet Components', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Open the More menu to show a sheetconst moreBtn = page.locator('[data-nav="more"], .ldr-nav-more-btn, .ldr-mobile-bottom-nav button:has-text("More")');if (await moreBtn.count() > 0) {await moreBtn.first().click();- // Wait for sheet animation to complete- await page.waitForTimeout(800);+ // Wait for sheet to appear+ const sheet = page.locator('.ldr-mobile-sheet');+ await sheet.waitFor({ state: 'visible', timeout: 5000 }).catch(() => {});// Capture the sheet element instead of full page for stability- const sheet = page.locator('.ldr-mobile-sheet');if (await sheet.isVisible()) {await expect(sheet).toHaveScreenshot('mobile-sheet-with-backdrop.png', {maxDiffPixelRatio: 0.02,@@ -1026,18 +985,17 @@ test.describe('Modal and Sheet Components', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Look for delete buttons that might trigger a confirmationconst deleteBtn = page.locator('button:has-text("Delete"), [aria-label*="delete"], .ldr-delete-btn').first();if (await deleteBtn.isVisible()) {await deleteBtn.click();- await page.waitForTimeout(300);// Check for confirmation dialogconst dialog = page.locator('[role="dialog"], .ldr-modal, .ldr-confirm-dialog');- if (await dialog.isVisible()) {- await expect(dialog).toHaveScreenshot('confirmation-dialog.png', {+ await dialog.first().waitFor({ state: 'visible', timeout: 3000 }).catch(() => {});+ if (await dialog.first().isVisible()) {+ await expect(dialog.first()).toHaveScreenshot('confirmation-dialog.png', {maxDiffPixelRatio: 0.02,});}@@ -1058,15 +1016,13 @@ test.describe('Settings Page Sections', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);// Click on General tab if tabs existconst generalTab = page.locator('[data-tab="general"], button:has-text("General"), a:has-text("General")').first();if (await generalTab.isVisible()) {await generalTab.click();- await page.waitForTimeout(300);+ await page.locator('.ldr-settings-content, .ldr-tab-content, [role="tabpanel"]').first().waitFor({ state: 'visible', timeout: 5000 }).catch(() => {});}const settingsContent = page.locator('.ldr-settings-content, .ldr-tab-content, [role="tabpanel"]').first();@@ -1085,15 +1041,13 @@ test.describe('Settings Page Sections', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);// Click on LLM tabconst llmTab = page.locator('[data-tab="llm"], button:has-text("LLM"), a:has-text("LLM")').first();if (await llmTab.isVisible()) {await llmTab.click();- await page.waitForTimeout(300);+ await page.locator('.ldr-settings-content, .ldr-tab-content, [role="tabpanel"]').first().waitFor({ state: 'visible', timeout: 5000 }).catch(() => {});const settingsContent = page.locator('.ldr-settings-content, .ldr-tab-content, [role="tabpanel"]').first();if (await settingsContent.isVisible()) {@@ -1112,15 +1066,13 @@ test.describe('Settings Page Sections', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);// Click on Search tabconst searchTab = page.locator('[data-tab="search"], button:has-text("Search"), a:has-text("Search")').first();if (await searchTab.isVisible()) {await searchTab.click();- await page.waitForTimeout(300);+ await page.locator('.ldr-settings-content, .ldr-tab-content, [role="tabpanel"]').first().waitFor({ state: 'visible', timeout: 5000 }).catch(() => {});const settingsContent = page.locator('.ldr-settings-content, .ldr-tab-content, [role="tabpanel"]').first();if (await settingsContent.isVisible()) {@@ -1139,15 +1091,13 @@ test.describe('Settings Page Sections', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);// Click on Reporting tabconst reportingTab = page.locator('[data-tab="reporting"], button:has-text("Reporting"), a:has-text("Reporting")').first();if (await reportingTab.isVisible()) {await reportingTab.click();- await page.waitForTimeout(300);+ await page.locator('.ldr-settings-content, .ldr-tab-content, [role="tabpanel"]').first().waitFor({ state: 'visible', timeout: 5000 }).catch(() => {});const settingsContent = page.locator('.ldr-settings-content, .ldr-tab-content, [role="tabpanel"]').first();if (await settingsContent.isVisible()) {@@ -1172,7 +1122,6 @@ test.describe('News Page Additional', () => {await page.goto('/news/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const subscriptionList = page.locator('.ldr-subscription-list, [class*="subscription"]');if (await subscriptionList.count() > 0 && await subscriptionList.first().isVisible()) {@@ -1190,7 +1139,6 @@ test.describe('News Page Additional', () => {await page.goto('/news/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const emptyState = page.locator('.ldr-empty-state, :text("No subscriptions"), :text("no news")').first();if (await emptyState.isVisible()) {@@ -1208,7 +1156,6 @@ test.describe('News Page Additional', () => {await page.goto('/news/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Capture the header area with any action buttonsconst headerArea = page.locator('.ldr-page-header, header, .ldr-news-header').first();@@ -1233,7 +1180,6 @@ test.describe('Library Page Additional', () => {await page.goto('/library/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const uploadArea = page.locator('.ldr-upload-area, [class*="upload"], .ldr-dropzone').first();if (await uploadArea.isVisible()) {@@ -1251,7 +1197,6 @@ test.describe('Library Page Additional', () => {await page.goto('/library/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const headerArea = page.locator('.ldr-page-header, header, .ldr-library-header').first();if (await headerArea.isVisible()) {@@ -1269,7 +1214,6 @@ test.describe('Library Page Additional', () => {await page.goto('/library/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const searchBar = page.locator('.ldr-search-bar, input[type="search"], .ldr-filter-bar').first();if (await searchBar.isVisible()) {@@ -1293,7 +1237,6 @@ test.describe('History Page Additional', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const headerArea = page.locator('.ldr-page-header, header, .ldr-history-header').first();if (await headerArea.isVisible()) {@@ -1311,7 +1254,6 @@ test.describe('History Page Additional', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const filterBar = page.locator('.ldr-search-bar, .ldr-filter-bar, [class*="filter"]').first();if (await filterBar.isVisible()) {@@ -1335,7 +1277,6 @@ test.describe('Research Page Additional', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page, { preserveMobileNav: true });// Capture the entire research form area@@ -1355,14 +1296,13 @@ test.describe('Research Page Additional', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);// Find the first mode option (radio button label)const modeOption = page.locator('.ldr-mode-selection label, .ldr-mode-option').first();if (await modeOption.isVisible()) {await modeOption.scrollIntoViewIfNeeded();- await page.waitForTimeout(300);+ await page.waitForTimeout(200);await expect(modeOption).toHaveScreenshot('research-mode-option.png', {maxDiffPixelRatio: 0.02,timeout: 10000,@@ -1378,7 +1318,6 @@ test.describe('Research Page Additional', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const quickActions = page.locator('.ldr-quick-actions, .ldr-action-bar, [class*="quick-action"]');if (await quickActions.count() > 0 && await quickActions.first().isVisible()) {@@ -1412,7 +1351,6 @@ test.describe('Page Headers', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);// Find the main header/title area@@ -1442,7 +1380,6 @@ test.describe('Auth Pages', () => {await page.goto('/auth/login');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check if we're on a login pageconst loginForm = page.locator('form, .ldr-login-form, [class*="login"]');@@ -1465,7 +1402,6 @@ test.describe('Auth Pages', () => {await page.goto('/auth/register');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check if we're on a register pageconst registerForm = page.locator('form, .ldr-register-form, [class*="register"]');@@ -1491,7 +1427,6 @@ test.describe('Collections Pages', () => {await page.goto('/library/collections/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);// Check if collections page loaded (may redirect or show list)@@ -1512,7 +1447,6 @@ test.describe('Collections Pages', () => {await page.goto('/library/collections/create/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const createForm = page.locator('form, .ldr-create-collection-form');@@ -1542,7 +1476,6 @@ test.describe('News Subscription Form', () => {for (const url of urls) {await page.goto(url);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const form = page.locator('form, .ldr-subscription-form');if (await form.count() > 0 && await form.first().isVisible()) {@@ -1570,7 +1503,6 @@ test.describe('Analytics Pages', () => {await page.goto('/cost-analytics/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-cost-analytics');@@ -1590,7 +1522,6 @@ test.describe('Analytics Pages', () => {await page.goto('/link-analytics/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-link-analytics');@@ -1616,7 +1547,6 @@ test.describe('Benchmark Page', () => {await page.goto('/benchmark/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-benchmark');@@ -1642,7 +1572,6 @@ test.describe('Star Reviews Page', () => {await page.goto('/star-reviews/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-star-reviews');@@ -1668,7 +1597,6 @@ test.describe('Subscriptions Page', () => {await page.goto('/subscriptions/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-subscriptions');@@ -1694,9 +1622,7 @@ test.describe('Embedding Settings Page', () => {await page.goto('/embedding-settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-embedding-settings');@@ -1722,7 +1648,6 @@ test.describe('Download Manager Page', () => {await page.goto('/download-manager/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-download-manager');@@ -1748,7 +1673,6 @@ test.describe('News Sub-Pages', () => {await page.goto('/news/insights');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-insights');@@ -1768,7 +1692,6 @@ test.describe('News Sub-Pages', () => {await page.goto('/news/preferences');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-preferences');@@ -1788,7 +1711,6 @@ test.describe('News Sub-Pages', () => {await page.goto('/news/subscriptions');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-subscriptions');@@ -1808,7 +1730,6 @@ test.describe('News Sub-Pages', () => {await page.goto('/news/subscriptions/new');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, form');@@ -1834,7 +1755,6 @@ test.describe('Metrics Sub-Pages', () => {await page.goto('/metrics/context-overflow');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-context-overflow');@@ -1854,7 +1774,6 @@ test.describe('Metrics Sub-Pages', () => {await page.goto('/metrics/costs');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-costs');@@ -1880,7 +1799,6 @@ test.describe('Auth Change Password', () => {await page.goto('/auth/change-password');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const pageContent = page.locator('main, .ldr-page, form');if (await pageContent.first().isVisible()) {@@ -1905,9 +1823,7 @@ test.describe('Settings Sub-Pages', () => {await page.goto('/settings/main');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-settings');@@ -1927,9 +1843,7 @@ test.describe('Settings Sub-Pages', () => {await page.goto('/settings/collections');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-settings');@@ -1949,9 +1863,7 @@ test.describe('Settings Sub-Pages', () => {await page.goto('/settings/api_keys');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-settings');@@ -1971,9 +1883,7 @@ test.describe('Settings Sub-Pages', () => {await page.goto('/settings/search_engines');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-settings');@@ -1993,9 +1903,7 @@ test.describe('Settings Sub-Pages', () => {await page.goto('/settings/llm');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-settings');@@ -2021,7 +1929,6 @@ test.describe('Library Sub-Pages', () => {await page.goto('/library/download-manager');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-download-manager');@@ -2041,9 +1948,7 @@ test.describe('Library Sub-Pages', () => {await page.goto('/library/embedding-settings');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-embedding-settings');@@ -2063,7 +1968,6 @@ test.describe('Library Sub-Pages', () => {await page.goto('/library/collections');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, .ldr-collections');@@ -2083,7 +1987,6 @@ test.describe('Library Sub-Pages', () => {await page.goto('/library/collections/create');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);const pageContent = page.locator('main, .ldr-page, form');diff --git a/tests/ui_tests/playwright/tests/mobile-ui-audit.spec.js b/tests/ui_tests/playwright/tests/mobile-ui-audit.spec.jsindex 9dbbec76b4..d5dd8f60e3 100644--- a/tests/ui_tests/playwright/tests/mobile-ui-audit.spec.js+++ b/tests/ui_tests/playwright/tests/mobile-ui-audit.spec.js@@ -28,14 +28,13 @@ test.describe('Mobile UI Audit - Issue Detection', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Wait for dynamic contentif (pageInfo.path === '/settings/') {await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});// Wait for settings form to be renderedawait page.waitForSelector('.ldr-settings-form, #settings-form, .ldr-settings-item', { timeout: 10000 }).catch(() => {});- await page.waitForTimeout(1000); // Extra time for dynamic rendering+ await page.locator('.ldr-settings-item, input[id], select[id]').first().waitFor({ state: 'visible', timeout: 10000 }).catch(() => {});}const auditResults = await page.evaluate((MIN_SIZE) => {@@ -279,7 +278,6 @@ test.describe('Mobile UI Audit - Specific Elements', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const formElements = await page.evaluate(() => {const elements = [];@@ -360,12 +358,11 @@ test.describe('Mobile UI Audit - Specific Elements', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});// Wait for settings tabs or settings items to be renderedawait page.waitForSelector('[data-tab], .ldr-settings-tab, .ldr-settings-item, input[id], select[id]', { timeout: 15000 }).catch(() => {});- await page.waitForTimeout(1500); // Extra time for dynamic rendering+ await page.locator('.ldr-settings-item, input[id], select[id]').first().waitFor({ state: 'visible', timeout: 10000 }).catch(() => {});const settingsInfo = await page.evaluate(() => {const info = {@@ -422,7 +419,6 @@ test.describe('Mobile UI Audit - Specific Elements', () => {await page.goto('/news/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const newsInfo = await page.evaluate(() => {const info = {@@ -486,7 +482,6 @@ test.describe('Mobile UI Audit - Specific Elements', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const metricsInfo = await page.evaluate(() => {const info = {@@ -547,7 +542,6 @@ test.describe('Mobile UI Audit - Navigation', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const navInfo = await page.evaluate(() => {const nav = document.querySelector('.ldr-mobile-bottom-nav');diff --git a/tests/ui_tests/playwright/tests/mobile-ui-issues.spec.js b/tests/ui_tests/playwright/tests/mobile-ui-issues.spec.jsindex e0d46b8142..a0cb274080 100644--- a/tests/ui_tests/playwright/tests/mobile-ui-issues.spec.js+++ b/tests/ui_tests/playwright/tests/mobile-ui-issues.spec.js@@ -549,15 +549,13 @@ test.describe('Mobile - Scroll Behavior', () => {await page.goto('/metrics/');await waitForPageLoad(page, '/metrics/');- // Wait for metrics content to load- await page.waitForTimeout(1000);// Get initial scroll positionconst initialScroll = await page.evaluate(() => window.scrollY);// Scroll to bottom- await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(500); // Increased wait time+ await page.evaluate(() => window.scrollTo({ top: document.body.scrollHeight, left: 0, behavior: 'instant' }));+ await page.waitForTimeout(200);// Get new scroll positionconst scrolledPosition = await page.evaluate(() => window.scrollY);@@ -576,7 +574,7 @@ test.describe('Mobile - Scroll Behavior', () => {document.documentElement.scrollTop = 0;document.body.scrollTop = 0;});- await page.waitForTimeout(500); // Extra time for scroll to settle+ await page.waitForTimeout(200);const backToTop = await page.evaluate(() => window.scrollY);console.log(`Metrics page scroll test - backToTop: ${backToTop}, pageHeight: ${pageHeight}, viewport: ${viewportHeight}`);@@ -699,7 +697,6 @@ test.describe('Mobile - Navigation Interactions', () => {await historyNav.click();// Wait for navigation with longer timeout and catch potential failuresawait page.waitForURL('**/history/**', { timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);// Check URL contains history (allow partial match)expect(page.url()).toMatch(/history/i);}@@ -757,7 +754,11 @@ test.describe('Mobile - Research Page Elements', () => {// Click toggleawait toggle.first().click();- await page.waitForTimeout(300);+ if (initiallyVisible) {+ await panel.waitFor({ state: 'hidden', timeout: 5000 });+ } else {+ await panel.waitFor({ state: 'visible', timeout: 5000 });+ }// Panel visibility should changeconst afterClickVisible = await panel.isVisible().catch(() => false);@@ -765,7 +766,11 @@ test.describe('Mobile - Research Page Elements', () => {// Click toggle again to closeawait toggle.first().click();- await page.waitForTimeout(300);+ if (initiallyVisible) {+ await panel.waitFor({ state: 'visible', timeout: 5000 });+ } else {+ await panel.waitFor({ state: 'hidden', timeout: 5000 });+ }// Panel should return to initial stateconst finalVisible = await panel.isVisible().catch(() => false);@@ -864,10 +869,10 @@ test.describe('Mobile - Modal Focus Trap', () => {}await createBtn.click();- await page.waitForTimeout(500);// Check if modal actually openedconst modal = page.locator('.ldr-modal, [role="dialog"]');+ await modal.first().waitFor({ state: 'visible', timeout: 5000 }).catch(() => {});if (!(await modal.isVisible().catch(() => false))) {// Modal didn't open, skip focus trap testreturn;diff --git a/tests/ui_tests/playwright/tests/news-subpages-mobile.spec.js b/tests/ui_tests/playwright/tests/news-subpages-mobile.spec.jsindex e819e3d28f..4c89334fb3 100644--- a/tests/ui_tests/playwright/tests/news-subpages-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/news-subpages-mobile.spec.js@@ -49,7 +49,6 @@ test.describe('News Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const criticalErrors = errors.filter((err) =>@@ -68,7 +67,6 @@ test.describe('News Subpages - Common Mobile Tests', () => {test('has no horizontal overflow', async ({ page }) => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const hasOverflow = await page.evaluate(() =>document.documentElement.scrollWidth > window.innerWidth@@ -91,7 +89,6 @@ test.describe('News Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator(MOBILE_NAV_SELECTOR);await expect(mobileNav, 'Mobile nav should be visible').toBeVisible();@@ -111,7 +108,6 @@ test.describe('News Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const smallTargets = await page.evaluate((MIN_SIZE) => {const elements = document.querySelectorAll(@@ -165,10 +161,9 @@ test.describe('News Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);const result = await page.evaluate((navSelector) => {const mobileNav = document.querySelector(navSelector);@@ -223,7 +218,6 @@ test.describe('News Subpages - Common Mobile Tests', () => {await page.goto(pageInfo.path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await ensureSheetsClosed(page);await page.evaluate(() => window.scrollTo(0, 0));await page.waitForTimeout(200);@@ -247,7 +241,6 @@ test.describe('Subscriptions List - Specific Tests', () => {test.beforeEach(async ({ page }) => {await page.goto('/news/subscriptions');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('page content loads', async ({ page }) => {@@ -303,7 +296,6 @@ test.describe('New Subscription Form - Specific Tests', () => {test.beforeEach(async ({ page }) => {await page.goto('/news/subscriptions/new');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('displays form elements', async ({ page }) => {diff --git a/tests/ui_tests/playwright/tests/orientation-change.spec.js b/tests/ui_tests/playwright/tests/orientation-change.spec.jsindex caba663c0a..1a910f5e19 100644--- a/tests/ui_tests/playwright/tests/orientation-change.spec.js+++ b/tests/ui_tests/playwright/tests/orientation-change.spec.js@@ -52,7 +52,6 @@ test.describe('Orientation Change - Layout Adaptation', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Verify no overflow in portraitlet hasOverflow = await page.evaluate(() =>@@ -62,7 +61,7 @@ test.describe('Orientation Change - Layout Adaptation', () => {// Rotate to landscapeawait page.setViewportSize(DEVICES.IPHONE_14.landscape);- await page.waitForTimeout(300);+ await page.waitForTimeout(200);// Verify no overflow in landscapehasOverflow = await page.evaluate(() =>@@ -83,7 +82,6 @@ test.describe('Orientation Change - Layout Adaptation', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Verify no overflow in landscapelet hasOverflow = await page.evaluate(() =>@@ -93,7 +91,7 @@ test.describe('Orientation Change - Layout Adaptation', () => {// Rotate to portraitawait page.setViewportSize(DEVICES.IPHONE_14.portrait);- await page.waitForTimeout(300);+ await page.waitForTimeout(200);// Verify no overflow in portraithasOverflow = await page.evaluate(() =>@@ -116,14 +114,13 @@ test.describe('Orientation Change - Form State Preservation', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const textarea = page.locator('#query');await textarea.fill('Test query in portrait');// Rotate to landscapeawait page.setViewportSize(DEVICES.IPHONE_14.landscape);- await page.waitForTimeout(300);+ await page.waitForTimeout(200);// Value should be preservedconst value = await textarea.inputValue();@@ -131,7 +128,7 @@ test.describe('Orientation Change - Form State Preservation', () => {// Rotate back to portraitawait page.setViewportSize(DEVICES.IPHONE_14.portrait);- await page.waitForTimeout(300);+ await page.waitForTimeout(200);// Value should still be preservedconst valueAfterReturn = await textarea.inputValue();@@ -151,7 +148,6 @@ test.describe('Orientation Change - Form State Preservation', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);// Find a text input and fill itconst textInputs = page.locator('input[type="text"], input[type="number"]');@@ -163,7 +159,7 @@ test.describe('Orientation Change - Form State Preservation', () => {// Rotate to landscapeawait page.setViewportSize(DEVICES.IPHONE_14.landscape);- await page.waitForTimeout(300);+ await page.waitForTimeout(200);// Value should be preservedconst valueAfterRotation = await firstInput.inputValue();@@ -186,7 +182,6 @@ test.describe('Orientation Change - Navigation Visibility', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator('.ldr-mobile-bottom-nav');await expect(mobileNav, 'Mobile nav visible at 667px (iPhone SE landscape)').toBeVisible();@@ -205,7 +200,6 @@ test.describe('Orientation Change - Navigation Visibility', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// At 780px, should be tablet layoutconst sidebar = page.locator('.ldr-sidebar');@@ -234,7 +228,6 @@ test.describe('Orientation Change - Navigation Visibility', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const mobileNav = page.locator('.ldr-mobile-bottom-nav');await expect(mobileNav, 'Mobile nav hidden at 844px (iPhone 14 landscape)').not.toBeVisible();@@ -254,7 +247,6 @@ test.describe('Orientation Change - Content Accessibility', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// Check main content visible in portraitconst mainContent = page.locator('main, .ldr-main-content, .ldr-content, #content');@@ -264,7 +256,7 @@ test.describe('Orientation Change - Content Accessibility', () => {// Rotate to landscapeawait page.setViewportSize(DEVICES.IPHONE_14.landscape);- await page.waitForTimeout(300);+ await page.waitForTimeout(200);// Main content should still be visibleif (await mainContent.count() > 0) {@@ -284,7 +276,6 @@ test.describe('Orientation Change - Content Accessibility', () => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const startButton = page.locator('#start-research-btn, button:has-text("Start Research")');if (await startButton.count() > 0) {@@ -293,7 +284,7 @@ test.describe('Orientation Change - Content Accessibility', () => {// Rotate to landscapeawait page.setViewportSize(DEVICES.IPHONE_14.landscape);- await page.waitForTimeout(300);+ await page.waitForTimeout(200);box = await startButton.first().boundingBox();expect(box?.height, 'Start button >= 44px in landscape').toBeGreaterThanOrEqual(44);@@ -326,7 +317,7 @@ test.describe('Orientation Change - Visual Regression', () => {await page.goto(path);await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);+ await page.waitForTimeout(200);// Portrait screenshotawait expect(page).toHaveScreenshot(`orientation-${name}-portrait.png`, {@@ -335,7 +326,7 @@ test.describe('Orientation Change - Visual Regression', () => {// Rotate to landscapeawait page.setViewportSize(DEVICES.IPHONE_14.landscape);- await page.waitForTimeout(500);+ await page.waitForTimeout(200);// Landscape screenshotawait expect(page).toHaveScreenshot(`orientation-${name}-landscape.png`, {@@ -358,7 +349,6 @@ test.describe('Orientation Change - Page-Specific Tests', () => {await page.goto('/history/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// No overflow in portraitlet hasOverflow = await page.evaluate(() =>@@ -368,7 +358,7 @@ test.describe('Orientation Change - Page-Specific Tests', () => {// Rotateawait page.setViewportSize(DEVICES.IPHONE_14.landscape);- await page.waitForTimeout(300);+ await page.waitForTimeout(200);// No overflow in landscapehasOverflow = await page.evaluate(() =>@@ -390,7 +380,6 @@ test.describe('Orientation Change - Page-Specific Tests', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 10000 }).catch(() => {});- await page.waitForTimeout(500);// No overflow in portraitlet hasOverflow = await page.evaluate(() =>@@ -400,7 +389,7 @@ test.describe('Orientation Change - Page-Specific Tests', () => {// Rotateawait page.setViewportSize(DEVICES.IPHONE_14.landscape);- await page.waitForTimeout(300);+ await page.waitForTimeout(200);// No overflow in landscapehasOverflow = await page.evaluate(() =>@@ -421,7 +410,6 @@ test.describe('Orientation Change - Page-Specific Tests', () => {await page.goto('/metrics/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// No overflow in portraitlet hasOverflow = await page.evaluate(() =>@@ -431,7 +419,7 @@ test.describe('Orientation Change - Page-Specific Tests', () => {// Rotateawait page.setViewportSize(DEVICES.IPHONE_14.landscape);- await page.waitForTimeout(300);+ await page.waitForTimeout(200);// No overflow in landscapehasOverflow = await page.evaluate(() =>diff --git a/tests/ui_tests/playwright/tests/research-page.spec.js b/tests/ui_tests/playwright/tests/research-page.spec.jsindex e3a77e69b5..9ebd2a47e6 100644--- a/tests/ui_tests/playwright/tests/research-page.spec.js+++ b/tests/ui_tests/playwright/tests/research-page.spec.js@@ -30,7 +30,6 @@ test.describe('Research Page - Element Spacing', () => {test.beforeEach(async ({ page }) => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('adequate spacing between form elements', async ({ page }) => {@@ -135,7 +134,6 @@ test.describe('Research Page - Mobile Nav Clearance', () => {test.beforeEach(async ({ page }) => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);// 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' });@@ -157,7 +155,7 @@ test.describe('Research Page - Mobile Nav Clearance', () => {// Scroll to bottom to bring content elements into view relative to the navawait page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(500);+ await page.locator('.ldr-mobile-bottom-nav').waitFor({ state: 'visible' });const result = await page.evaluate(() => {const mobileNav = document.querySelector('.ldr-mobile-bottom-nav');@@ -251,7 +249,6 @@ test.describe('Research Page - Advanced Options', () => {test.beforeEach(async ({ page }) => {await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('advanced options toggle works on mobile', async ({ page }) => {@@ -268,7 +265,11 @@ test.describe('Research Page - Advanced Options', () => {// Click to toggleawait toggle.click();- await page.waitForTimeout(300);+ if (isPanelInitiallyVisible) {+ await panel.waitFor({ state: 'hidden' });+ } else {+ await panel.waitFor({ state: 'visible' });+ }// Panel visibility should changeconst isPanelNowVisible = await panel.isVisible().catch(() => false);@@ -296,7 +297,7 @@ test.describe('Research Page - Advanced Options', () => {}await toggle.click();- await page.waitForTimeout(300);+ await panel.waitFor({ state: 'visible' });// Check panel is visibleconst isPanelVisible = await panel.isVisible().catch(() => false);diff --git a/tests/ui_tests/playwright/tests/settings-subpages-mobile.spec.js b/tests/ui_tests/playwright/tests/settings-subpages-mobile.spec.jsindex 2c7d9f871b..477a125203 100644--- a/tests/ui_tests/playwright/tests/settings-subpages-mobile.spec.js+++ b/tests/ui_tests/playwright/tests/settings-subpages-mobile.spec.js@@ -42,7 +42,6 @@ test.describe('Settings Page - Mobile', () => {await page.waitForLoadState('domcontentloaded');// Wait for settings to loadawait page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(500);});test('page loads without errors', async ({ page }) => {@@ -133,7 +132,6 @@ test.describe('Settings Tab Navigation', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(500);});test('all tabs are visible', async ({ page }) => {@@ -143,7 +141,7 @@ test.describe('Settings Tab Navigation', () => {// Tabs might be scrollable on mobile, so just check they exist in DOMif (!isVisible) {- const exists = await tabElement.count() > 0;+ const exists = (await tabElement.count()) > 0;expect(exists, `Tab ${tab.name} should exist`).toBe(true);}}@@ -164,8 +162,6 @@ test.describe('Settings Tab Navigation', () => {if (await tabElement.isVisible()) {await tabElement.click();- await page.waitForTimeout(300);-await expect(tabElement).toHaveClass(/active/);}}@@ -184,8 +180,8 @@ test.describe('Settings Tab Navigation', () => {expect(box).not.toBeNull();// The tabs container should be scrollable or all tabs visible- const scrollWidth = await tabsContainer.evaluate(el => el.scrollWidth);- const clientWidth = await tabsContainer.evaluate(el => el.clientWidth);+ const scrollWidth = await tabsContainer.evaluate((el) => el.scrollWidth);+ const clientWidth = await tabsContainer.evaluate((el) => el.clientWidth);// Either all tabs fit, or container is scrollableexpect(scrollWidth >= clientWidth).toBe(true);@@ -201,7 +197,6 @@ test.describe('Settings Form - Mobile', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(500);});test('form inputs have adequate size', async ({ page, isMobile }, testInfo) => {@@ -216,7 +211,9 @@ test.describe('Settings Form - Mobile', () => {return;}- const inputs = page.locator('#settings-form input:visible, #settings-form select:visible, #settings-form textarea:visible');+ const inputs = page.locator(+ '#settings-form input:visible, #settings-form select:visible, #settings-form textarea:visible'+ );const inputCount = await inputs.count();let tooSmallInputs = 0;@@ -289,7 +286,7 @@ test.describe('Settings Form - Mobile', () => {// Scroll to bottomawait page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);const result = await page.evaluate((navSelector) => {const mobileNav = document.querySelector(navSelector);@@ -341,13 +338,12 @@ test.describe('Settings Tab Content', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(500);});test('All Settings tab shows content', async ({ page }) => {const allTab = page.locator('[data-tab="all"]');await allTab.click();- await page.waitForTimeout(300);+ await expect(allTab).toHaveClass(/active/);// Settings content should be visibleconst content = page.locator('#settings-content');@@ -360,7 +356,7 @@ test.describe('Settings Tab Content', () => {if (await llmTab.isVisible()) {await llmTab.click();- await page.waitForTimeout(300);+ await expect(llmTab).toHaveClass(/active/);// Should filter to show LLM settingsconst content = page.locator('#settings-content');@@ -374,7 +370,7 @@ test.describe('Settings Tab Content', () => {if (await searchTab.isVisible()) {await searchTab.click();- await page.waitForTimeout(300);+ await expect(searchTab).toHaveClass(/active/);const content = page.locator('#settings-content');await expect(content).toBeVisible();@@ -391,7 +387,6 @@ test.describe('Settings Search', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(500);});test('search input accepts text', async ({ page }) => {@@ -423,7 +418,6 @@ test.describe('Settings Tab Screenshots', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(500);});for (const tab of SETTINGS_TABS) {@@ -459,7 +453,7 @@ test.describe('Settings Tab Screenshots', () => {return;}- await page.waitForTimeout(500);+ await page.locator(tab.selector).waitFor({ state: 'visible' });await ensureSheetsClosed(page);await page.waitForTimeout(200);@@ -481,7 +475,6 @@ test.describe('Settings Tab Content - Scrolled', () => {await page.goto('/settings/');await page.waitForLoadState('domcontentloaded');await page.waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 }).catch(() => {});- await page.waitForTimeout(500);});test('LLM tab - scrolled content screenshot', async ({ page, isMobile }) => {@@ -495,12 +488,14 @@ test.describe('Settings Tab Content - Scrolled', () => {if (await llmTab.isVisible()) {await llmTab.click();// LLM tab has dynamic content - wait for models to load- await page.waitForTimeout(1000);+ await page+ .waitForSelector('.ldr-loading-spinner', { state: 'hidden', timeout: 15000 })+ .catch(() => {});}// Scroll down to show more contentawait page.evaluate(() => window.scrollTo(0, 400));- await page.waitForTimeout(500);+ await page.waitForTimeout(200);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('settings-llm-scrolled.png', {@@ -519,11 +514,11 @@ test.describe('Settings Tab Content - Scrolled', () => {await searchTab.scrollIntoViewIfNeeded().catch(() => {});if (await searchTab.isVisible()) {await searchTab.click();- await page.waitForTimeout(500);+ await expect(searchTab).toHaveClass(/active/);}await page.evaluate(() => window.scrollTo(0, 400));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('settings-search-scrolled.png', {@@ -542,11 +537,11 @@ test.describe('Settings Tab Content - Scrolled', () => {await appTab.scrollIntoViewIfNeeded().catch(() => {});if (await appTab.isVisible()) {await appTab.click();- await page.waitForTimeout(500);+ await expect(appTab).toHaveClass(/active/);}await page.evaluate(() => window.scrollTo(0, 400));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);await ensureSheetsClosed(page);await expect(page).toHaveScreenshot('settings-app-scrolled.png', {diff --git a/tests/ui_tests/playwright/tests/theme-visual-regression.spec.js b/tests/ui_tests/playwright/tests/theme-visual-regression.spec.jsindex beb0219171..cc44aa2001 100644--- a/tests/ui_tests/playwright/tests/theme-visual-regression.spec.js+++ b/tests/ui_tests/playwright/tests/theme-visual-regression.spec.js@@ -46,7 +46,7 @@ async function applyTheme(page, themeId) {document.documentElement.setAttribute('data-theme', theme);}, themeId);// Wait for theme CSS to apply- await page.waitForTimeout(300);+ await page.waitForTimeout(200);}/**@@ -355,7 +355,7 @@ test.describe('Theme - Mobile Navigation Styling', () => {await expect(mobileNav, `Mobile nav should be visible in ${theme.name} theme`).toBeVisible();// Wait for theme to fully apply to mobile nav- await page.waitForTimeout(500);+ await page.waitForTimeout(200);// Screenshot the mobile nav areaconst safeName = theme.id;@@ -381,7 +381,6 @@ test.describe('Theme - Desktop Sidebar Styling', () => {await page.setViewportSize({ width: 1200, height: 800 });await page.goto('/');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await applyTheme(page, theme.id);const sidebar = page.locator('.ldr-sidebar');@@ -405,7 +404,6 @@ test.describe('Theme - Change Password Page', () => {test(`${theme.name} theme on Change Password`, async ({ page, isMobile }) => {await page.goto('/auth/change-password');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);await applyTheme(page, theme.id);if (isMobile) {diff --git a/tests/ui_tests/playwright/tests/untested-subpages.spec.js b/tests/ui_tests/playwright/tests/untested-subpages.spec.jsindex d09caf4839..0f68ec28bb 100644--- a/tests/ui_tests/playwright/tests/untested-subpages.spec.js+++ b/tests/ui_tests/playwright/tests/untested-subpages.spec.js@@ -43,7 +43,6 @@ test.describe('Broken Routes - News Subpages', () => {// If it loads, check for page errorsconst pageErrors = [];page.on('pageerror', (error) => pageErrors.push(error.message));- await page.waitForTimeout(500);expect(pageErrors.length).toBe(0);} else {// Unexpected status code - may be a redirect@@ -65,7 +64,6 @@ test.describe('Broken Routes - News Subpages', () => {const pageErrors = [];page.on('pageerror', (error) => pageErrors.push(error.message));- await page.waitForTimeout(500);expect(pageErrors.length).toBe(0);} else {console.log(`/news/preferences returned unexpected status: ${status}`);@@ -82,7 +80,6 @@ test.describe('Benchmark Results Page', () => {test.beforeEach(async ({ page }) => {await page.goto('/benchmark/results');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('page loads without critical errors', async ({ page }) => {@@ -102,7 +99,6 @@ test.describe('Benchmark Results Page', () => {// Navigate fresh to capture all errorsawait page.goto('/benchmark/results');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const criticalErrors = errors.filter((err) =>@@ -237,7 +233,7 @@ test.describe('Benchmark Results Page', () => {// Scroll to bottomawait page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300);+ await page.waitForTimeout(200);const result = await page.evaluate((navSelector) => {const mobileNav = document.querySelector(navSelector);@@ -331,7 +327,7 @@ test.describe('Benchmark Results Page', () => {await page.setViewportSize({ width: 1200, height: 800 });await page.goto('/benchmark/results');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);+ await page.waitForTimeout(200);await expect(page).toHaveScreenshot('benchmark-results-desktop.png', {maxDiffPixelRatio: 0.02,@@ -347,7 +343,6 @@ test.describe('Change Password Page', () => {test.beforeEach(async ({ page }) => {await page.goto('/auth/change-password');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);});test('page loads without critical errors', async ({ page }) => {@@ -365,7 +360,6 @@ test.describe('Change Password Page', () => {await page.goto('/auth/change-password');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);const criticalErrors = errors.filter((err) =>@@ -474,7 +468,7 @@ test.describe('Change Password Page', () => {await page.setViewportSize({ width: 1200, height: 800 });await page.goto('/auth/change-password');await page.waitForLoadState('domcontentloaded');- await page.waitForTimeout(500);+ await page.waitForTimeout(200);await expect(page).toHaveScreenshot('change-password-desktop.png', {maxDiffPixelRatio: 0.02,