~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(tests): clean up Playwright PR - remove fallback, add CI/CD
LearningCircuitf524b8956bf5
diff --git a/.github/workflows/playwright-webkit-tests.yml b/.github/workflows/playwright-webkit-tests.ymlnew file mode 100644index 0000000000..2d4bb7d857--- /dev/null+++ b/.github/workflows/playwright-webkit-tests.yml@@ -0,0 +1,139 @@+name: Playwright WebKit Tests++on:+ push:+ branches: [ main, dev, 'fix/*', 'feature/*' ]+ paths:+ - 'src/local_deep_research/web/static/css/**'+ - 'src/local_deep_research/web/static/js/**'+ - 'src/local_deep_research/web/templates/**'+ - 'tests/ui_tests/playwright/**'+ - '.github/workflows/playwright-webkit-tests.yml'+ pull_request:+ branches: [ main, dev ]+ paths:+ - 'src/local_deep_research/web/static/css/**'+ - 'src/local_deep_research/web/static/js/**'+ - 'src/local_deep_research/web/templates/**'+ - 'tests/ui_tests/playwright/**'+ workflow_dispatch:++permissions: {} # Minimal top-level for OSSF Scorecard Token-Permissions++jobs:+ playwright-webkit-tests:+ runs-on: ubuntu-latest+ permissions:+ contents: read+ checks: write++ steps:+ - name: Harden the runner (Audit all outbound calls)+ uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0+ with:+ egress-policy: audit++ - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1+ with:+ persist-credentials: false++ - name: Set up PDM+ uses: pdm-project/setup-pdm@94a823180e06fcde4ad29308721954a521c96ed0 # v4+ with:+ python-version: '3.12'+ version: 2.26.2+ cache: true++ - name: Install Python dependencies+ run: |+ pdm install -d++ - name: Setup Node.js+ uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6+ with:+ node-version: '20'+ cache: 'npm'+ cache-dependency-path: tests/ui_tests/playwright/package.json++ - name: Install Playwright dependencies+ working-directory: tests/ui_tests/playwright+ run: |+ npm ci+ npx playwright install webkit --with-deps++ - name: Setup test directories+ run: |+ mkdir -p data/encrypted_databases+ echo "Created data directories for tests"++ - name: Start LDR server+ env:+ CI: true+ TEST_ENV: true+ FLASK_ENV: testing+ LDR_DATA_DIR: ${{ github.workspace }}/data+ DISABLE_RATE_LIMITING: true+ SECRET_KEY: test-secret-key-for-ci+ run: |+ export PYTHONPATH="$PWD/src:$PYTHONPATH"+ echo "Starting server with LDR_DATA_DIR=$LDR_DATA_DIR"+ pdm run python -m local_deep_research.web.app &+ SERVER_PID=$!+ echo "SERVER_PID=$SERVER_PID" >> "$GITHUB_ENV"++ # Wait for server to be ready+ for i in {1..30}; do+ if curl -s http://127.0.0.1:5000 > /dev/null; then+ echo "Server is ready"+ break+ fi+ echo "Waiting for server... ($i/30)"+ sleep 2+ done++ # Verify server is running+ if ! curl -s http://127.0.0.1:5000 > /dev/null; then+ echo "Server failed to start"+ exit 1+ fi++ - name: Register CI test user+ working-directory: tests/ui_tests+ run: |+ npm ci+ node register_ci_user.js http://127.0.0.1:5000++ - name: Run Playwright WebKit Tests+ working-directory: tests/ui_tests/playwright+ env:+ CI: true+ TEST_BASE_URL: http://127.0.0.1:5000+ TEST_USERNAME: test_admin+ TEST_PASSWORD: testpass123+ run: |+ npx playwright test --project="Mobile Safari" --project="Desktop Safari"++ - name: Upload Playwright Report+ if: always()+ uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0+ with:+ name: playwright-report+ path: |+ tests/ui_tests/playwright/playwright-report/+ tests/ui_tests/playwright/test-results/++ - name: Publish Test Results+ if: always()+ uses: EnricoMi/publish-unit-test-result-action@27d65e188ec43221b20d26de30f4892fad91df2f # v2.22.0+ with:+ files: tests/ui_tests/playwright/test-results/results.xml+ check_name: Playwright WebKit Test Results+ comment_mode: off++ - name: Stop server+ if: always()+ run: |+ if [ -n "$SERVER_PID" ]; then+ kill "$SERVER_PID" || true+ fi+ pkill -f "python -m local_deep_research.web.app" || truediff --git a/tests/ui_tests/mobile/test_research_page_mobile.js b/tests/ui_tests/mobile/test_research_page_mobile.jsdeleted file mode 100644index ff806bb683..0000000000--- a/tests/ui_tests/mobile/test_research_page_mobile.js+++ /dev/null@@ -1,678 +0,0 @@-#!/usr/bin/env node-/**- * Research Page Mobile Layout Tests- *- * Specifically tests the main Research page (home) for mobile layout issues,- * with focus on elements at the bottom that can get "mashed together"- * or hidden behind the mobile navigation.- *- * Key elements tested:- * - Research Query textarea- * - Research Mode selection- * - Advanced Options toggle and panel- * - Start Research button- * - Sound notifications checkbox- * - Help panel ("How Research Works")- * - Spacing between all form elements- *- * Run: node test_research_page_mobile.js- *- * Environment variables:- * - TEST_BASE_URL: Server URL (default: http://127.0.0.1:5000)- * - CI: Set to 'true' for CI mode- * - HEADLESS: 'true' or 'false' (default: true)- */--const puppeteer = require('puppeteer');-const fs = require('fs');-const path = require('path');-const AuthHelper = require('../auth_helper');-const { getPuppeteerLaunchOptions } = require('../puppeteer_config');--// Configuration-const BASE_URL = process.env.TEST_BASE_URL || 'http://127.0.0.1:5000';-const IS_CI = process.env.CI === 'true';-const HEADLESS = process.env.HEADLESS !== 'false';--// Mobile viewports to test-const MOBILE_VIEWPORTS = {- 'iPhone_SE': { width: 375, height: 667 }, // Small phone- 'iPhone_14_Pro': { width: 393, height: 852 }, // Standard phone- 'iPhone_14_Pro_Max': { width: 430, height: 932 }, // Large phone- 'iPhone_SE_landscape': { width: 667, height: 375 }, // Landscape- 'Android_small': { width: 360, height: 640 }, // Small Android-};--// Minimum spacing between interactive elements (in pixels)-const MIN_SPACING_BETWEEN_ELEMENTS = 8;-const MIN_SPACING_ABOVE_NAV = 16;-const MIN_TOUCH_TARGET = 44;-const MOBILE_NAV_HEIGHT = 56;--// Test results-class TestResults {- constructor() {- this.tests = [];- this.startTime = Date.now();- }-- addResult(viewport, testName, passed, message, details = null) {- this.tests.push({- viewport,- testName,- passed,- message,- details,- timestamp: new Date().toISOString()- });- }-- get summary() {- const total = this.tests.length;- const passed = this.tests.filter(t => t.passed).length;- return { total, passed, failed: total - passed, duration: Date.now() - this.startTime };- }-- toJSON() {- return { summary: this.summary, tests: this.tests };- }-}--/**- * Main test class for Research page mobile layout- */-class ResearchPageMobileTests {- constructor() {- this.results = new TestResults();- this.browser = null;- this.page = null;- this.screenshotDir = path.join(__dirname, 'screenshots', 'research-page');- }-- async setup() {- // Create screenshot directory if not CI- if (!IS_CI && !fs.existsSync(this.screenshotDir)) {- fs.mkdirSync(this.screenshotDir, { recursive: true });- }-- this.browser = await puppeteer.launch(getPuppeteerLaunchOptions({- headless: HEADLESS- }));- this.page = await this.browser.newPage();-- // Set initial desktop viewport for authentication- await this.page.setViewport({ width: 1280, height: 800 });-- // Authenticate- const authHelper = new AuthHelper(this.page, BASE_URL);- await authHelper.ensureAuthenticated();- console.log('Authentication complete');- }-- async cleanup() {- if (this.browser) {- await this.browser.close();- }- }-- /**- * Take screenshot with annotations- */- async takeScreenshot(name, viewport, annotations = []) {- if (IS_CI) return null;-- try {- // Add visual annotations- if (annotations.length > 0) {- await this.page.evaluate((annotations) => {- // Remove previous annotations- document.querySelectorAll('.test-annotation').forEach(el => el.remove());-- annotations.forEach((ann, i) => {- const el = document.createElement('div');- el.className = 'test-annotation';- el.style.cssText = `- position: fixed;- left: ${ann.left}px;- top: ${ann.top}px;- width: ${ann.width}px;- height: ${ann.height}px;- border: 2px solid ${ann.color || 'red'};- background: ${ann.color || 'red'}22;- z-index: 99999;- pointer-events: none;- `;- if (ann.label) {- const label = document.createElement('span');- label.style.cssText = `- position: absolute;- top: -20px;- left: 0;- background: ${ann.color || 'red'};- color: white;- padding: 2px 6px;- font-size: 10px;- border-radius: 3px;- white-space: nowrap;- `;- label.textContent = ann.label;- el.appendChild(label);- }- document.body.appendChild(el);- });- }, annotations);- }-- const screenshotPath = path.join(this.screenshotDir, `${viewport}_${name}.png`);- await this.page.screenshot({ path: screenshotPath, fullPage: false });-- // Clean up annotations- await this.page.evaluate(() => {- document.querySelectorAll('.test-annotation').forEach(el => el.remove());- });-- return screenshotPath;- } catch (error) {- console.error(`Screenshot error: ${error.message}`);- return null;- }- }-- /**- * Get element positions for the research page bottom section- */- async getResearchPageElements() {- return await this.page.evaluate((MOBILE_NAV_HEIGHT) => {- const viewportHeight = window.innerHeight;- const mobileNav = document.querySelector('.ldr-mobile-bottom-nav');- const navRect = mobileNav ? mobileNav.getBoundingClientRect() : null;- const navVisible = mobileNav &&- window.getComputedStyle(mobileNav).display !== 'none' &&- mobileNav.classList.contains('visible');-- // Key elements on Research page- const elements = {- // Form elements- queryTextarea: document.querySelector('#query'),- modeSelection: document.querySelector('.ldr-mode-selection'),- advancedToggle: document.querySelector('.ldr-advanced-options-toggle'),- advancedPanel: document.querySelector('.ldr-advanced-options-panel'),-- // Bottom elements (the "mashed together" area)- formActions: document.querySelector('.ldr-form-actions'),- startButton: document.querySelector('#start-research-btn'),- formOptions: document.querySelector('.ldr-form-options'),- notificationToggle: document.querySelector('#notification-toggle'),- helpPanel: document.querySelector('.ldr-help-panel'),-- // Container- researchCard: document.querySelector('.ldr-research-card'),- page: document.querySelector('.ldr-page.active'),- };-- const results = {- viewport: { width: window.innerWidth, height: viewportHeight },- mobileNav: {- exists: !!mobileNav,- visible: navVisible,- rect: navRect ? {- top: navRect.top,- height: navRect.height- } : null,- effectiveTop: navVisible ? navRect.top : viewportHeight- },- elements: {},- issues: []- };-- // Analyze each element- for (const [name, el] of Object.entries(elements)) {- if (!el) {- results.elements[name] = { exists: false };- continue;- }-- const rect = el.getBoundingClientRect();- const style = window.getComputedStyle(el);-- results.elements[name] = {- exists: true,- rect: {- top: rect.top,- bottom: rect.bottom,- left: rect.left,- right: rect.right,- width: rect.width,- height: rect.height- },- computed: {- marginTop: parseFloat(style.marginTop) || 0,- marginBottom: parseFloat(style.marginBottom) || 0,- paddingTop: parseFloat(style.paddingTop) || 0,- paddingBottom: parseFloat(style.paddingBottom) || 0,- },- isVisible: style.display !== 'none' && style.visibility !== 'hidden' && rect.height > 0,- isAboveNav: !navVisible || rect.bottom <= navRect.top- };-- // Check if element is hidden behind nav- if (navVisible && rect.bottom > navRect.top && rect.top < viewportHeight) {- results.issues.push({- type: 'behind-nav',- element: name,- message: `${name} extends behind mobile nav (bottom: ${Math.round(rect.bottom)}px, navTop: ${Math.round(navRect.top)}px)`,- overlap: rect.bottom - navRect.top- });- }- }-- return results;- }, MOBILE_NAV_HEIGHT);- }-- /**- * Check vertical spacing between consecutive elements- */- async checkVerticalSpacing(viewport) {- const data = await this.getResearchPageElements();-- // Elements that should have adequate spacing between them (in order from top to bottom)- const orderedElements = [- 'queryTextarea',- 'modeSelection',- 'advancedToggle',- 'formActions', // Contains start button- 'formOptions', // Contains notification toggle- 'helpPanel'- ];-- const spacingIssues = [];- let prevElement = null;- let prevName = null;-- for (const name of orderedElements) {- const el = data.elements[name];- if (!el?.exists || !el?.isVisible) continue;-- if (prevElement) {- const spacing = el.rect.top - prevElement.rect.bottom;- if (spacing < MIN_SPACING_BETWEEN_ELEMENTS) {- spacingIssues.push({- between: `${prevName} and ${name}`,- spacing: Math.round(spacing),- required: MIN_SPACING_BETWEEN_ELEMENTS,- message: `Insufficient spacing (${Math.round(spacing)}px) between ${prevName} and ${name}`- });- }- }-- prevElement = el;- prevName = name;- }-- const passed = spacingIssues.length === 0;- const message = passed- ? 'All elements have adequate vertical spacing'- : `Found ${spacingIssues.length} spacing issues: ${spacingIssues.map(i => i.message).join('; ')}`;-- this.results.addResult(viewport, 'Vertical Spacing Between Elements', passed, message, { spacingIssues, data });-- // Take screenshot with issues highlighted- if (!passed && !IS_CI) {- const annotations = spacingIssues.map(issue => {- const parts = issue.between.split(' and ');- const el1 = data.elements[parts[0]];- const el2 = data.elements[parts[1]];- if (el1?.exists && el2?.exists) {- return {- left: 10,- top: el1.rect.bottom,- width: el1.rect.width - 20,- height: el2.rect.top - el1.rect.bottom,- color: 'orange',- label: `Gap: ${issue.spacing}px (need ${issue.required}px)`- };- }- return null;- }).filter(Boolean);- await this.takeScreenshot('spacing-issues', viewport, annotations);- }-- return passed;- }-- /**- * Check if last element is properly visible above mobile nav- */- async checkLastElementVisibility(viewport) {- const data = await this.getResearchPageElements();-- if (!data.mobileNav.visible) {- this.results.addResult(viewport, 'Last Element Above Nav', true, 'Mobile nav not visible, skip check');- return true;- }-- // Find the last visible element- const bottomElements = ['helpPanel', 'formOptions', 'formActions'];- let lastElement = null;- let lastName = null;-- for (const name of bottomElements) {- const el = data.elements[name];- if (el?.exists && el?.isVisible) {- if (!lastElement || el.rect.bottom > lastElement.rect.bottom) {- lastElement = el;- lastName = name;- }- }- }-- if (!lastElement) {- this.results.addResult(viewport, 'Last Element Above Nav', false, 'Could not find any bottom elements');- return false;- }-- const navTop = data.mobileNav.rect.top;- const spaceAboveNav = navTop - lastElement.rect.bottom;- const passed = spaceAboveNav >= MIN_SPACING_ABOVE_NAV;-- const message = passed- ? `Last element (${lastName}) has ${Math.round(spaceAboveNav)}px space above mobile nav`- : `Last element (${lastName}) too close to nav: ${Math.round(spaceAboveNav)}px (need ${MIN_SPACING_ABOVE_NAV}px)`;-- this.results.addResult(viewport, 'Last Element Above Nav', passed, message, {- lastElement: lastName,- spaceAboveNav,- navTop,- lastElementBottom: lastElement.rect.bottom- });-- // Screenshot with nav highlighted- if (!passed && !IS_CI) {- await this.takeScreenshot('last-element-nav', viewport, [- {- left: lastElement.rect.left,- top: lastElement.rect.top,- width: lastElement.rect.width,- height: lastElement.rect.height,- color: 'blue',- label: lastName- },- {- left: 0,- top: navTop,- width: data.viewport.width,- height: MOBILE_NAV_HEIGHT,- color: 'red',- label: 'Mobile Nav'- }- ]);- }-- return passed;- }-- /**- * Check if elements are overlapping (mashed together)- */- async checkForOverlappingElements(viewport) {- const data = await this.getResearchPageElements();-- const overlaps = [];- const interactiveElements = [- 'startButton',- 'notificationToggle',- 'advancedToggle'- ];-- const rects = [];- for (const name of interactiveElements) {- const el = data.elements[name];- if (el?.exists && el?.isVisible) {- rects.push({ name, rect: el.rect });- }- }-- // Check for overlaps- for (let i = 0; i < rects.length; i++) {- for (let j = i + 1; j < rects.length; j++) {- const r1 = rects[i].rect;- const r2 = rects[j].rect;-- const overlap = !(r1.right < r2.left ||- r1.left > r2.right ||- r1.bottom < r2.top ||- r1.top > r2.bottom);-- if (overlap) {- overlaps.push({- element1: rects[i].name,- element2: rects[j].name,- message: `${rects[i].name} overlaps with ${rects[j].name}`- });- }- }- }-- const passed = overlaps.length === 0;- const message = passed- ? 'No overlapping interactive elements'- : `Found ${overlaps.length} overlaps: ${overlaps.map(o => o.message).join('; ')}`;-- this.results.addResult(viewport, 'No Overlapping Elements', passed, message, { overlaps });- return passed;- }-- /**- * Check touch target sizes for key elements- */- async checkTouchTargets(viewport) {- const data = await this.getResearchPageElements();-- const smallTargets = [];- const touchElements = ['startButton', 'notificationToggle', 'advancedToggle'];-- for (const name of touchElements) {- const el = data.elements[name];- if (!el?.exists || !el?.isVisible) continue;-- if (el.rect.height < MIN_TOUCH_TARGET || el.rect.width < MIN_TOUCH_TARGET) {- smallTargets.push({- element: name,- width: Math.round(el.rect.width),- height: Math.round(el.rect.height),- required: MIN_TOUCH_TARGET,- message: `${name} too small: ${Math.round(el.rect.width)}x${Math.round(el.rect.height)}px (need ${MIN_TOUCH_TARGET}px)`- });- }- }-- const passed = smallTargets.length === 0;- const message = passed- ? 'All touch targets meet minimum size requirements'- : `Found ${smallTargets.length} small touch targets: ${smallTargets.map(t => t.message).join('; ')}`;-- this.results.addResult(viewport, 'Touch Target Sizes', passed, message, { smallTargets });- return passed;- }-- /**- * Check page has proper bottom padding for mobile nav- */- async checkBottomPadding(viewport) {- const data = await this.getResearchPageElements();-- if (!data.mobileNav.visible) {- this.results.addResult(viewport, 'Bottom Padding for Nav', true, 'Mobile nav not visible, skip check');- return true;- }-- const page = data.elements.page;- if (!page?.exists) {- this.results.addResult(viewport, 'Bottom Padding for Nav', false, 'Could not find page container');- return false;- }-- const totalPadding = page.computed.paddingBottom + page.computed.marginBottom;- const requiredPadding = MOBILE_NAV_HEIGHT + 20; // Nav height plus some breathing room- const passed = totalPadding >= requiredPadding;-- const message = passed- ? `Page has adequate bottom padding (${Math.round(totalPadding)}px)`- : `Insufficient bottom padding: ${Math.round(totalPadding)}px (need ${requiredPadding}px for mobile nav)`;-- this.results.addResult(viewport, 'Bottom Padding for Nav', passed, message, {- paddingBottom: page.computed.paddingBottom,- marginBottom: page.computed.marginBottom,- totalPadding,- requiredPadding- });-- return passed;- }-- /**- * Check content is scrollable to reveal all elements- */- async checkScrollability(viewport) {- const result = await this.page.evaluate(() => {- const page = document.querySelector('.ldr-page.active');- if (!page) return { exists: false };-- const rect = page.getBoundingClientRect();- const isScrollable = page.scrollHeight > page.clientHeight ||- document.body.scrollHeight > window.innerHeight;-- // Try scrolling to bottom- window.scrollTo(0, document.body.scrollHeight);-- return {- exists: true,- isScrollable,- scrollHeight: document.body.scrollHeight,- viewportHeight: window.innerHeight,- canScrollToBottom: true- };- });-- // Scroll back to top- await this.page.evaluate(() => window.scrollTo(0, 0));-- const passed = result.exists;- const message = result.isScrollable- ? `Page is scrollable (content: ${result.scrollHeight}px, viewport: ${result.viewportHeight}px)`- : 'Page content fits in viewport without scrolling';-- this.results.addResult(viewport, 'Content Scrollability', passed, message, result);- return passed;- }-- /**- * Run all tests for a viewport- */- async testViewport(viewportName, viewportConfig) {- console.log(`\nTesting ${viewportName} (${viewportConfig.width}x${viewportConfig.height})...`);-- await this.page.setViewport({- width: viewportConfig.width,- height: viewportConfig.height,- isMobile: true,- hasTouch: true- });-- // Navigate to research page- await this.page.goto(BASE_URL, {- waitUntil: 'domcontentloaded',- timeout: 30000- });-- // Wait for mobile nav to initialize- await new Promise(resolve => setTimeout(resolve, 1000));-- // Run all tests- await this.checkVerticalSpacing(viewportName);- await this.checkLastElementVisibility(viewportName);- await this.checkForOverlappingElements(viewportName);- await this.checkTouchTargets(viewportName);- await this.checkBottomPadding(viewportName);- await this.checkScrollability(viewportName);-- // Take a general screenshot- if (!IS_CI) {- await this.takeScreenshot('full-page', viewportName);- }- }-- /**- * Main test runner- */- async run() {- console.log('========================================');- console.log(' Research Page Mobile Layout Tests');- console.log('========================================');- console.log(`Base URL: ${BASE_URL}`);- console.log(`Viewports: ${Object.keys(MOBILE_VIEWPORTS).length}`);- console.log('');-- await this.setup();-- try {- for (const [name, config] of Object.entries(MOBILE_VIEWPORTS)) {- await this.testViewport(name, config);- }- } finally {- await this.cleanup();- }-- this.printSummary();- this.saveResults();-- process.exit(this.results.summary.failed > 0 ? 1 : 0);- }-- printSummary() {- const { summary } = this.results;-- console.log('\n========================================');- console.log(' Test Summary');- console.log('========================================');- console.log(` Total: ${summary.total}`);- console.log(` Passed: ${summary.passed}`);- console.log(` Failed: ${summary.failed}`);- console.log(` Time: ${(summary.duration / 1000).toFixed(2)}s`);- console.log('========================================\n');-- if (summary.failed > 0) {- console.log('Failed Tests:');- for (const test of this.results.tests.filter(t => !t.passed)) {- console.log(` ✗ [${test.viewport}] ${test.testName}`);- console.log(` ${test.message}`);- }- console.log('');- } else {- console.log('All tests passed!');- }- }-- saveResults() {- const outputDir = path.join(__dirname, 'test-results');- if (!fs.existsSync(outputDir)) {- fs.mkdirSync(outputDir, { recursive: true });- }-- const jsonPath = path.join(outputDir, 'research-page-mobile.json');- fs.writeFileSync(jsonPath, JSON.stringify(this.results.toJSON(), null, 2));- console.log(`Results saved to: ${jsonPath}`);- }-}--// Run tests-if (require.main === module) {- const tester = new ResearchPageMobileTests();- tester.run().catch(error => {- console.error('Test failed:', error);- process.exit(1);- });-}--module.exports = { ResearchPageMobileTests };diff --git a/tests/ui_tests/playwright/tests/research-page.spec.js b/tests/ui_tests/playwright/tests/research-page.spec.jsindex 528d7067fd..ff0c15adfa 100644--- a/tests/ui_tests/playwright/tests/research-page.spec.js+++ b/tests/ui_tests/playwright/tests/research-page.spec.js@@ -20,11 +20,15 @@ const MIN_ELEMENT_SPACING = 8;const MIN_TOUCH_TARGET = 44;const MIN_NAV_CLEARANCE = 16;+// Credentials from environment variables (set in CI or local .env)+const TEST_USERNAME = process.env.TEST_USERNAME || 'test_admin';+const TEST_PASSWORD = process.env.TEST_PASSWORD || 'testpass123';+// Helper to authenticateasync function authenticate(page) {await page.goto('/auth/login');- await page.fill('input[name="username"]', 'test_admin');- await page.fill('input[name="password"]', 'testpass123');+ await page.fill('input[name="username"]', TEST_USERNAME);+ await page.fill('input[name="password"]', TEST_PASSWORD);await page.click('button[type="submit"]');await page.waitForURL('/', { timeout: 10000 });}@@ -42,8 +46,9 @@ test.describe('Research Page - Visual Regression', () => {await page.goto('/');await page.waitForLoadState('networkidle');- // Wait for mobile nav to initialize- 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' });// Take full-page screenshot and compare to baselineawait expect(page).toHaveScreenshot('research-page-full.png', {@@ -59,7 +64,8 @@ test.describe('Research Page - Visual Regression', () => {// Scroll to bottom to capture the "mashed together" areaawait page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300);+ // Allow scroll animation to complete+ await page.waitForLoadState('domcontentloaded');await expect(page).toHaveScreenshot('research-page-bottom.png', {maxDiffPixelRatio: 0.01,@@ -238,7 +244,9 @@ test.describe('Research Page - Mobile Nav Clearance', () => {await authenticate(page);await page.goto('/');await page.waitForLoadState('networkidle');- await page.waitForTimeout(500); // Wait for mobile nav to initialize+ // 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' });});test('last element has clearance above mobile nav', async ({ page, isMobile }) => {@@ -318,7 +326,6 @@ test.describe('Research Page - Scrollability', () => {test('can scroll to reveal all content', async ({ page }) => {// Scroll to bottomawait page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));- await page.waitForTimeout(300);// Check that help panel is visibleconst helpPanel = page.locator('.ldr-help-panel');@@ -328,7 +335,6 @@ test.describe('Research Page - Scrollability', () => {// Check that Start Research button is still accessible (scroll back up)await page.evaluate(() => window.scrollTo(0, 0));- await page.waitForTimeout(300);const startButton = page.locator('#start-research-btn');await expect(startButton).toBeInViewport();@@ -361,11 +367,8 @@ test.describe('Research Page - Advanced Options', () => {// Panel should be hidden initiallyawait expect(panel).not.toBeVisible();- // Click to expand+ // Click to expand and wait for panel to become visibleawait toggle.click();- await page.waitForTimeout(300);-- // Panel should now be visibleawait expect(panel).toBeVisible();// Check no horizontal overflow after expanding@@ -382,8 +385,9 @@ test.describe('Research Page - Advanced Options', () => {}const toggle = page.locator('.ldr-advanced-options-toggle');+ const panel = page.locator('.ldr-advanced-options-panel');await toggle.click();- await page.waitForTimeout(300);+ await expect(panel).toBeVisible();// Check that form fields inside are usableconst modelSelect = page.locator('#model_provider');