~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: Speed up CI tests by using pre-created test user
LearningCircuit16c3df62cb42
diff --git a/tests/ui_tests/auth_helper.js b/tests/ui_tests/auth_helper.jsindex cea3f4c637..b5d00208c0 100644--- a/tests/ui_tests/auth_helper.js+++ b/tests/ui_tests/auth_helper.js@@ -5,11 +5,50 @@const crypto = require('crypto');+/**+ * Timing utility for detailed performance logging+ */+class Timer {+ constructor(label) {+ this.label = label;+ this.startTime = Date.now();+ this.laps = [];+ }++ lap(description) {+ const now = Date.now();+ const elapsed = now - this.startTime;+ const lapTime = this.laps.length > 0+ ? now - this.laps[this.laps.length - 1].timestamp+ : elapsed;+ this.laps.push({ description, elapsed, lapTime, timestamp: now });+ console.log(` ⏱️ [${this.label}] ${description}: +${lapTime}ms (total: ${elapsed}ms)`);+ return elapsed;+ }++ elapsed() {+ return Date.now() - this.startTime;+ }++ summary() {+ const total = this.elapsed();+ console.log(` ⏱️ [${this.label}] TOTAL: ${total}ms (${(total/1000).toFixed(1)}s)`);+ return total;+ }+}+const DEFAULT_TEST_USER = {username: 'testuser',password: 'T3st!Secure#2024$LDR'};+// CI pre-created test user (created in GitHub workflow's "Initialize database" step)+// This user is created BEFORE tests run, so no slow registration needed+const CI_TEST_USER = {+ username: 'test_admin',+ password: 'testpass123'+};+// Configuration constants - single source of truth for auth helper settingsconst AUTH_CONFIG = {// Route paths@@ -18,34 +57,33 @@ const AUTH_CONFIG = {register: '/auth/register',logout: '/auth/logout'},- // Timeouts (ms) - CI needs VERY LONG timeouts due to:+ // Timeouts (ms) - CI has longer timeouts due to:// 1. Slower CI runners with shared resources// 2. Registration creates encrypted SQLCipher database// 3. Key derivation from password is CPU intensive// 4. Creating 58 database tables takes time// 5. Importing 500+ settings from JSON files- // 6. Library system initialization- // Total registration time can be 2+ minutes on slow runners+ // Note: If registration takes >2min, something is likely wrongtimeouts: {- navigation: process.env.CI ? 180000 : 30000, // 3 min in CI- formSelector: process.env.CI ? 60000 : 5000, // 1 min in CI- submitNavigation: process.env.CI ? 300000 : 60000, // 5 min in CI for registration- urlCheck: process.env.CI ? 30000 : 5000, // 30s in CI- errorCheck: process.env.CI ? 15000 : 2000, // 15s in CI- logout: process.env.CI ? 60000 : 10000 // 1 min in CI+ navigation: process.env.CI ? 60000 : 30000, // 1 min in CI (reduced from 3 min)+ formSelector: process.env.CI ? 30000 : 5000, // 30s in CI (reduced from 1 min)+ submitNavigation: process.env.CI ? 120000 : 60000, // 2 min in CI (reduced from 5 min)+ urlCheck: process.env.CI ? 10000 : 5000, // 10s in CI (reduced from 30s)+ errorCheck: process.env.CI ? 5000 : 2000, // 5s in CI (reduced from 15s)+ logout: process.env.CI ? 30000 : 10000 // 30s in CI (reduced from 1 min)},// Delays (ms)delays: {- retryNavigation: process.env.CI ? 3000 : 1000, // 3s between retries in CI- afterRegistration: process.env.CI ? 10000 : 3000, // 10s after registration in CI- beforeRetry: process.env.CI ? 10000 : 5000, // 10s before retry in CI- afterLogout: process.env.CI ? 3000 : 1000 // 3s after logout in CI+ retryNavigation: process.env.CI ? 2000 : 1000, // 2s between retries in CI+ afterRegistration: process.env.CI ? 5000 : 3000, // 5s after registration in CI+ beforeRetry: process.env.CI ? 5000 : 5000, // 5s before retry in CI+ afterLogout: process.env.CI ? 2000 : 1000 // 2s after logout in CI},// CI-specific settingsci: {waitUntil: 'domcontentloaded',- maxLoginAttempts: 15, // More attempts for slow CI- maxNavigationRetries: 5 // More retries for flaky CI+ maxLoginAttempts: 10, // Reduced from 15 - fail faster+ maxNavigationRetries: 3 // Reduced from 5 - fail faster}};@@ -86,21 +124,26 @@ class AuthHelper {* @returns {string} The URL we arrived at*/async _navigateToAuthPage(path, expectedPathSegment) {+ const timer = new Timer(`nav:${path}`);const targetUrl = `${this.baseUrl}${path}`;const waitUntil = this.isCI ? AUTH_CONFIG.ci.waitUntil : 'networkidle2';const maxRetries = this.isCI ? AUTH_CONFIG.ci.maxNavigationRetries : 1;+ const timeout = AUTH_CONFIG.timeouts.navigation;console.log(` Navigating to ${path}...`);+ console.log(` Config: waitUntil=${waitUntil}, timeout=${timeout}ms, maxRetries=${maxRetries}`);let arrivedUrl = '';let lastError = null;for (let attempt = 1; attempt <= maxRetries; attempt++) {try {+ timer.lap(`attempt ${attempt} start`);await this.page.goto(targetUrl, {waitUntil,- timeout: AUTH_CONFIG.timeouts.navigation+ timeout});+ timer.lap(`attempt ${attempt} navigation complete`);arrivedUrl = this.page.url();console.log(` Attempt ${attempt}/${maxRetries}: Arrived at: ${arrivedUrl}`);@@ -200,23 +243,28 @@ class AuthHelper {* Login with existing user credentials*/async login(username = DEFAULT_TEST_USER.username, password = DEFAULT_TEST_USER.password) {+ const timer = new Timer('login');console.log(`🔐 Attempting login as ${username}...`);// Check if already logged inif (await this.isLoggedIn()) {console.log('✅ Already logged in');+ timer.summary();return true;}+ timer.lap('checked login status');// Always navigate to login page to ensure fresh CSRF token// (After logout, the page may have a stale token from the previous session)const currentUrl = this.page.url();console.log(` Current URL: ${currentUrl}`);await this._navigateToAuthPage(AUTH_CONFIG.paths.login, AUTH_CONFIG.paths.login);+ timer.lap('navigated to login page');// Wait for login formconsole.log(' Waiting for login form...');await this.page.waitForSelector('input[name="username"]', { timeout: AUTH_CONFIG.timeouts.formSelector });+ timer.lap('login form ready');// Check what's on the pageconst formAction = await this.page.$eval('form', form => form.action).catch(() => 'no form found');@@ -235,6 +283,7 @@ class AuthHelper {// Type credentialsawait this.page.type('input[name="username"]', username);await this.page.type('input[name="password"]', password);+ timer.lap('credentials filled');// Check form values before submitconst usernameValue = await this.page.$eval('input[name="username"]', el => el.value);@@ -263,9 +312,11 @@ class AuthHelper {// In CI, try a different approach - click and wait for URL changeif (this.isCI) {console.log(' Using CI-specific login approach (wait for redirect)');+ timer.lap('starting CI login');// Click the submit buttonawait this.page.click('button[type="submit"]');+ timer.lap('submit clicked');// Wait for either navigation or timeoutlet redirected = false;@@ -325,10 +376,12 @@ class AuthHelper {console.log(' Session cookie exists, manually navigating to home');await this.page.goto(this.baseUrl, { waitUntil: AUTH_CONFIG.ci.waitUntil });} else {+ timer.summary();throw new Error('Login failed - no redirect and no session cookie');}}+ timer.lap('CI login redirect complete');console.log(' Navigation completed');} else {// Non-CI logic - use domcontentloaded instead of networkidle2 to avoid WebSocket/polling timeouts@@ -342,6 +395,7 @@ class AuthHelper {console.log(' Navigation completed');}} catch (navError) {+ timer.lap(`navigation error: ${navError.message.substring(0, 40)}`);console.log(` Navigation error: ${navError.message}`);console.log(` Current URL after error: ${this.page.url()}`);@@ -354,6 +408,7 @@ class AuthHelper {console.log(` Alerts on page: ${JSON.stringify(alerts)}`);}+ timer.summary();throw navError;}@@ -367,6 +422,7 @@ class AuthHelper {if (error) {const errorText = await this.page.evaluate(el => el.textContent, error);console.log(` Error message on page: ${errorText.trim()}`);+ timer.summary();throw new Error(`Login failed: ${errorText.trim()}`);}@@ -378,9 +434,11 @@ class AuthHelper {console.log(` Validation errors: ${JSON.stringify(validationErrors)}`);}+ timer.summary();throw new Error('Login failed - still on login page');}+ timer.summary();console.log('✅ Login successful');return true;}@@ -389,10 +447,13 @@ class AuthHelper {* Register a new user*/async register(username = DEFAULT_TEST_USER.username, password = DEFAULT_TEST_USER.password) {+ const timer = new Timer('register');console.log(`📝 Attempting registration for ${username}...`);+ console.log(` Submit timeout: ${AUTH_CONFIG.timeouts.submitNavigation}ms (${(AUTH_CONFIG.timeouts.submitNavigation/1000/60).toFixed(1)} min)`);// Navigate to registration page using the helperconst arrivedUrl = await this._navigateToAuthPage(AUTH_CONFIG.paths.register, AUTH_CONFIG.paths.register);+ timer.lap('navigation complete');// If redirected to login, registration might be disabledif (arrivedUrl.includes(AUTH_CONFIG.paths.login)) {@@ -400,34 +461,55 @@ class AuthHelper {}// Wait for registration form+ console.log(' Waiting for registration form...');await this.page.waitForSelector('input[name="username"]', { timeout: AUTH_CONFIG.timeouts.formSelector });+ timer.lap('form ready');// Fill in registration form+ console.log(' Filling registration form...');await this.page.type('input[name="username"]', username);await this.page.type('input[name="password"]', password);await this.page.type('input[name="confirm_password"]', password);+ timer.lap('form filled');// Check acknowledgment checkbox if presentconst acknowledgeCheckbox = await this.page.$('input[name="acknowledge"]');if (acknowledgeCheckbox) {await this.page.click('input[name="acknowledge"]');+ timer.lap('checkbox clicked');}// Submit form+ console.log(' Submitting registration form...');+ console.log(' ⚠️ This may take 1-3 minutes in CI (database creation + settings import)');try {- await Promise.all([- this.page.waitForNavigation({- waitUntil: 'domcontentloaded',- timeout: AUTH_CONFIG.timeouts.submitNavigation- }),- this.page.click('button[type="submit"]')- ]);+ // Set up progress logging for long operations+ const progressInterval = setInterval(() => {+ const elapsed = timer.elapsed();+ console.log(` ⏳ Still waiting for registration... (${(elapsed/1000).toFixed(0)}s elapsed)`);+ }, 15000); // Log every 15 seconds++ try {+ await Promise.all([+ this.page.waitForNavigation({+ waitUntil: 'domcontentloaded',+ timeout: AUTH_CONFIG.timeouts.submitNavigation+ }),+ this.page.click('button[type="submit"]')+ ]);+ } finally {+ clearInterval(progressInterval);+ }+ timer.lap('form submitted + navigation complete');} catch (navError) {+ timer.lap(`submit error: ${navError.message.substring(0, 50)}`);+// In CI, navigation errors are expected due to frame detachmentif (this.isCI && navError.message.includes('detached')) {console.log(' CI: Navigation error (expected):', navError.message);// Wait for registration to complete server-sideawait this._delay(AUTH_CONFIG.delays.afterRegistration);+ timer.lap('post-registration delay complete');// Navigate back to home page after registrationtry {@@ -435,18 +517,22 @@ class AuthHelper {waitUntil: AUTH_CONFIG.ci.waitUntil,timeout: AUTH_CONFIG.timeouts.formSelector});+ timer.lap('navigated to home');} catch (gotoError) {console.log(' CI: Could not navigate after registration:', gotoError.message);}+ timer.summary();console.log('✅ Registration completed (CI mode)');return true;}+ timer.summary();throw navError;}// Check if registration was successfulconst currentUrl = this.page.url();+ timer.lap('checking result URL');if (currentUrl.includes(AUTH_CONFIG.paths.register)) {// Still on registration page - check for actual errors (not warnings)const error = await this.page.$('.alert-danger:not(.alert-warning), .error-message');@@ -454,8 +540,10 @@ class AuthHelper {const errorText = await this.page.evaluate(el => el.textContent, error);if (errorText.includes('already exists')) {console.log('⚠️ User already exists, attempting login instead');+ timer.summary();return await this.login(username, password);}+ timer.summary();throw new Error(`Registration failed: ${errorText}`);}@@ -466,38 +554,60 @@ class AuthHelper {console.log('⚠️ Security warning:', warningText.trim().replace(/\s+/g, ' '));}+ timer.summary();throw new Error('Registration failed - still on registration page');}+ timer.summary();console.log('✅ Registration successful');return true;}/*** Ensure user is authenticated - register if needed, then login+ * In CI mode, first tries the pre-created CI test user for speed*/async ensureAuthenticated(username = null, password = DEFAULT_TEST_USER.password, retries = null) {+ const timer = new Timer('ensureAuthenticated');+// Use more retries in CI environmentif (retries === null) {- retries = this.isCI ? 4 : 2;- }-- // Generate random username if not provided- if (!username) {- username = generateRandomUsername();- console.log(`🎲 Using random username: ${username}`);+ retries = this.isCI ? 3 : 2;}// Check if already logged intry {if (await this.isLoggedIn()) {console.log('✅ Already logged in');+ timer.summary();return true;}} catch (checkError) {console.log(`⚠️ Could not check login status: ${checkError.message}`);// Continue with authentication attempt}+ timer.lap('login status checked');++ // In CI, first try the pre-created CI test user (much faster than registration!)+ if (this.isCI) {+ console.log('\n🚀 CI mode: Trying pre-created test user first (fast path)...');+ try {+ await this.login(CI_TEST_USER.username, CI_TEST_USER.password);+ console.log('✅ Logged in with CI test user');+ timer.summary();+ return true;+ } catch (ciLoginError) {+ console.log(`⚠️ CI test user login failed: ${ciLoginError.message}`);+ console.log(' Falling back to registration...');+ timer.lap('CI user login failed');+ }+ }++ // Generate random username if not provided+ if (!username) {+ username = generateRandomUsername();+ console.log(`🎲 Using random username: ${username}`);+ }let lastError;for (let attempt = 1; attempt <= retries; attempt++) {@@ -536,11 +646,13 @@ class AuthHelper {if (attempt === retries) {console.log(`❌ All ${retries} authentication attempts failed`);+ timer.summary();throw lastError;}}}+ timer.summary();throw lastError || new Error('Failed to authenticate after retries');}@@ -711,6 +823,29 @@ async function safeClick(page, selectorOrElement, options = {}) {}}+/**+ * Log the current auth configuration for debugging+ */+function logAuthConfig() {+ const isCI = !!process.env.CI;+ console.log('\n📋 Auth Configuration:');+ console.log(` Environment: ${isCI ? 'CI' : 'Local'}`);+ console.log(' Timeouts:');+ console.log(` - navigation: ${AUTH_CONFIG.timeouts.navigation}ms (${(AUTH_CONFIG.timeouts.navigation/1000).toFixed(0)}s)`);+ console.log(` - formSelector: ${AUTH_CONFIG.timeouts.formSelector}ms (${(AUTH_CONFIG.timeouts.formSelector/1000).toFixed(0)}s)`);+ console.log(` - submitNavigation: ${AUTH_CONFIG.timeouts.submitNavigation}ms (${(AUTH_CONFIG.timeouts.submitNavigation/1000/60).toFixed(1)}min)`);+ console.log(` - urlCheck: ${AUTH_CONFIG.timeouts.urlCheck}ms`);+ console.log(' CI settings:');+ console.log(` - waitUntil: ${AUTH_CONFIG.ci.waitUntil}`);+ console.log(` - maxLoginAttempts: ${AUTH_CONFIG.ci.maxLoginAttempts}`);+ console.log(` - maxNavigationRetries: ${AUTH_CONFIG.ci.maxNavigationRetries}`);+ console.log('');+}+module.exports = AuthHelper;module.exports.safeClick = safeClick;module.exports.AUTH_CONFIG = AUTH_CONFIG;+module.exports.Timer = Timer;+module.exports.logAuthConfig = logAuthConfig;+module.exports.CI_TEST_USER = CI_TEST_USER;+module.exports.DEFAULT_TEST_USER = DEFAULT_TEST_USER;diff --git a/tests/ui_tests/test_change_password_validation.js b/tests/ui_tests/test_change_password_validation.jsindex 321b5ce76b..02299862cb 100644--- a/tests/ui_tests/test_change_password_validation.js+++ b/tests/ui_tests/test_change_password_validation.js@@ -11,13 +11,16 @@const puppeteer = require('puppeteer');const AuthHelper = require('./auth_helper');+const { logAuthConfig, Timer, CI_TEST_USER } = require('./auth_helper');const { getPuppeteerLaunchOptions } = require('./puppeteer_config');const fs = require('fs');const path = require('path');async function testChangePasswordValidation() {const isCI = !!process.env.CI;+ const testTimer = new Timer('test_change_password_validation');console.log(`🧪 Running change password validation test (CI mode: ${isCI})`);+ logAuthConfig();// Create screenshots directory if it doesn't existconst screenshotsDir = path.join(__dirname, 'screenshots');@@ -38,8 +41,11 @@ async function testChangePasswordValidation() {let testsPassed = 0;let testsFailed = 0;- // Create a test user for change password tests- const testUser = {+ // In CI, use the pre-created test user; locally, create a new one+ const testUser = isCI ? {+ username: CI_TEST_USER.username,+ password: CI_TEST_USER.password+ } : {username: `chgpwd_${Date.now()}`,password: 'OldPass123!'};@@ -47,17 +53,26 @@ async function testChangePasswordValidation() {console.log('🧪 Starting change password validation tests...\n');try {- // First, register a test user so we can test change password- console.log('📋 Setup: Registering test user...');+ // First, authenticate (CI uses pre-created user, local creates new one)+ console.log('📋 Setup: Authenticating...');const authHelper = new AuthHelper(page, baseUrl);try {- await authHelper.register(testUser.username, testUser.password);- console.log('✅ Test user registered successfully\n');- } catch (regError) {- console.log(`⚠️ Could not register test user: ${regError.message}`);+ if (isCI) {+ // In CI, just login with pre-created user (fast!)+ console.log(` Using CI test user: ${testUser.username}`);+ await authHelper.login(testUser.username, testUser.password);+ console.log('✅ Logged in with CI test user\n');+ } else {+ // Locally, register a new user+ await authHelper.register(testUser.username, testUser.password);+ console.log('✅ Test user registered successfully\n');+ }+ } catch (authError) {+ console.log(`⚠️ Could not authenticate: ${authError.message}`);console.log(' Skipping change password tests - requires authenticated user\n');await browser.close();+ testTimer.summary();console.log('⚠️ Test skipped - no test user available');process.exit(0); // Exit successfully since we can't test without a user}@@ -345,10 +360,12 @@ async function testChangePasswordValidation() {}await browser.close();+ testTimer.summary();process.exit(1);}await browser.close();+ testTimer.summary();console.log('\n✅ Test completed successfully');}diff --git a/tests/ui_tests/test_concurrent_limit.js b/tests/ui_tests/test_concurrent_limit.jsindex badc4e5998..705d852d35 100644--- a/tests/ui_tests/test_concurrent_limit.js+++ b/tests/ui_tests/test_concurrent_limit.js@@ -1,8 +1,11 @@const puppeteer = require('puppeteer');const { browserConfig } = require('./browser_config');const AuthHelper = require('./auth_helper');+const { CI_TEST_USER } = require('./auth_helper');const { getPuppeteerLaunchOptions } = require('./puppeteer_config');+const isCI = !!process.env.CI;+async function submitResearchBatch(page, queries) {// Submit all researches as quickly as possibleconst results = [];@@ -100,17 +103,22 @@ async function submitResearchBatch(page, queries) {const page = await browser.newPage();try {- // Create a fresh user+ // Authenticate (CI uses pre-created user for speed)const auth = new AuthHelper(page);- const username = 'conctest_' + Date.now();- const password = 'T3st!Secure#2024$LDR';-- console.log('1. Creating user:', username);- await auth.register(username, password);- const isLoggedIn = await auth.isLoggedIn();- if (!isLoggedIn) {- await auth.login(username, password);+ if (isCI) {+ console.log(`1. Using CI test user: ${CI_TEST_USER.username}`);+ await auth.login(CI_TEST_USER.username, CI_TEST_USER.password);+ } else {+ const username = 'conctest_' + Date.now();+ const password = 'T3st!Secure#2024$LDR';+ console.log('1. Creating user:', username);+ await auth.register(username, password);++ const isLoggedIn = await auth.isLoggedIn();+ if (!isLoggedIn) {+ await auth.login(username, password);+ }}console.log('\n2. Testing concurrent research limit...\n');diff --git a/tests/ui_tests/test_export_functionality.js b/tests/ui_tests/test_export_functionality.jsindex c12b303278..5fd327d1ac 100644--- a/tests/ui_tests/test_export_functionality.js+++ b/tests/ui_tests/test_export_functionality.js@@ -2,12 +2,14 @@ const puppeteer = require('puppeteer');const path = require('path');const fs = require('fs');const AuthHelper = require('./auth_helper');+const { CI_TEST_USER, logAuthConfig } = require('./auth_helper');const { getPuppeteerLaunchOptions } = require('./puppeteer_config');// Test configurationconst BASE_URL = 'http://127.0.0.1:5000';-const TEST_USER = `export_test_${Date.now()}`;-const TEST_PASSWORD = 'TestPass123!';+const isCI = !!process.env.CI;+const TEST_USER = isCI ? CI_TEST_USER.username : `export_test_${Date.now()}`;+const TEST_PASSWORD = isCI ? CI_TEST_USER.password : 'TestPass123!';// Colors for console outputconst colors = {@@ -205,11 +207,17 @@ async function testExportFunctionality() {});try {- // Setup+ // Setup - authenticate (CI uses pre-created user for speed)const auth = new AuthHelper(page);- log('📝 Registering new user...', 'info');- await auth.register(TEST_USER, TEST_PASSWORD);- log('✅ Registration successful', 'success');+ if (isCI) {+ log(`🔐 Logging in with CI test user: ${TEST_USER}`, 'info');+ await auth.login(TEST_USER, TEST_PASSWORD);+ log('✅ Login successful', 'success');+ } else {+ log('📝 Registering new user...', 'info');+ await auth.register(TEST_USER, TEST_PASSWORD);+ log('✅ Registration successful', 'success');+ }await configureExportSettings(page);await createResearchAndWait(page);diff --git a/tests/ui_tests/test_research_form_validation.js b/tests/ui_tests/test_research_form_validation.jsindex 0e3ab05566..453a376bab 100644--- a/tests/ui_tests/test_research_form_validation.js+++ b/tests/ui_tests/test_research_form_validation.js@@ -6,6 +6,7 @@const puppeteer = require('puppeteer');const AuthHelper = require('./auth_helper');+const { CI_TEST_USER, logAuthConfig } = require('./auth_helper');const { getPuppeteerLaunchOptions } = require('./puppeteer_config');const fs = require('fs');const path = require('path');@@ -13,6 +14,7 @@ const path = require('path');async function testResearchFormValidation() {const isCI = !!process.env.CI;console.log(`🧪 Running research form validation test (CI mode: ${isCI})`);+ logAuthConfig();// Create screenshots directory if it doesn't existconst screenshotsDir = path.join(__dirname, 'screenshots');@@ -36,27 +38,24 @@ async function testResearchFormValidation() {console.log('🧪 Starting research form validation tests...\n');try {- // Register and login+ // Authenticate (CI uses pre-created user for speed)console.log('📋 Setup: Authenticating...');const authHelper = new AuthHelper(page, baseUrl);- const testUser = {- username: `research_${Date.now()}`,- password: 'TestPass123!'- };try {- await authHelper.register(testUser.username, testUser.password);- console.log('✅ Test user registered and logged in\n');- } catch (regError) {- console.log(`⚠️ Could not register: ${regError.message}`);- try {+ if (isCI) {+ console.log(` Using CI test user: ${CI_TEST_USER.username}`);+ await authHelper.login(CI_TEST_USER.username, CI_TEST_USER.password);+ console.log('✅ Logged in with CI test user\n');+ } else {await authHelper.ensureAuthenticated();- console.log('✅ Authenticated via existing mechanism\n');- } catch (authError) {- console.log('❌ Cannot authenticate - skipping research form tests');- await browser.close();- process.exit(0);+ console.log('✅ Authenticated\n');}+ } catch (authError) {+ console.log(`⚠️ Could not authenticate: ${authError.message}`);+ console.log('❌ Cannot authenticate - skipping research form tests');+ await browser.close();+ process.exit(0);}// Navigate to home page (research form)diff --git a/tests/ui_tests/test_research_submit.js b/tests/ui_tests/test_research_submit.jsindex f6eb86a89b..dd9794cba1 100644--- a/tests/ui_tests/test_research_submit.js+++ b/tests/ui_tests/test_research_submit.js@@ -6,6 +6,7 @@const puppeteer = require('puppeteer');const AuthHelper = require('./auth_helper');+const { CI_TEST_USER, logAuthConfig } = require('./auth_helper');const { getPuppeteerLaunchOptions } = require('./puppeteer_config');const { setupDefaultModel } = require('./model_helper');const fs = require('fs');@@ -15,6 +16,7 @@ const path = require('path');let browser;const isCI = !!process.env.CI;console.log(`🧪 Running research submit test (CI mode: ${isCI})`);+ logAuthConfig();// Create screenshots directoryconst screenshotsDir = path.join(__dirname, 'screenshots');@@ -39,13 +41,17 @@ const path = require('path');});}- // Register and login+ // Authenticate (CI uses pre-created user for speed)const auth = new AuthHelper(page);- const username = 'simple_' + Date.now();- const password = 'TestPass123!';-- console.log('🔐 Creating user:', username);- await auth.register(username, password);+ if (isCI) {+ console.log(`🔐 Using CI test user: ${CI_TEST_USER.username}`);+ await auth.login(CI_TEST_USER.username, CI_TEST_USER.password);+ } else {+ const username = 'simple_' + Date.now();+ const password = 'TestPass123!';+ console.log('🔐 Creating user:', username);+ await auth.register(username, password);+ }console.log('\n🏠 Navigating to home page...');await page.goto('http://127.0.0.1:5000/', { waitUntil: 'networkidle2' });diff --git a/tests/ui_tests/test_settings_validation.js b/tests/ui_tests/test_settings_validation.jsindex 5361d126d9..efa74821ee 100644--- a/tests/ui_tests/test_settings_validation.js+++ b/tests/ui_tests/test_settings_validation.js@@ -6,13 +6,16 @@const puppeteer = require('puppeteer');const AuthHelper = require('./auth_helper');+const { logAuthConfig, Timer, CI_TEST_USER } = require('./auth_helper');const { getPuppeteerLaunchOptions } = require('./puppeteer_config');const fs = require('fs');const path = require('path');async function testSettingsValidation() {const isCI = !!process.env.CI;+ const testTimer = new Timer('test_settings_validation');console.log(`🧪 Running settings validation test (CI mode: ${isCI})`);+ logAuthConfig();// Create screenshots directory if it doesn't existconst screenshotsDir = path.join(__dirname, 'screenshots');@@ -36,28 +39,27 @@ async function testSettingsValidation() {console.log('🧪 Starting settings validation tests...\n');try {- // Register and login+ // Authenticate (CI uses pre-created user for speed)console.log('📋 Setup: Authenticating...');const authHelper = new AuthHelper(page, baseUrl);- const testUser = {- username: `settings_${Date.now()}`,- password: 'TestPass123!'- };try {- await authHelper.register(testUser.username, testUser.password);- console.log('✅ Test user registered and logged in\n');- } catch (regError) {- console.log(`⚠️ Could not register: ${regError.message}`);- // Try to ensure we're authenticated somehow- try {+ if (isCI) {+ // In CI, just login with pre-created user (fast!)+ console.log(` Using CI test user: ${CI_TEST_USER.username}`);+ await authHelper.login(CI_TEST_USER.username, CI_TEST_USER.password);+ console.log('✅ Logged in with CI test user\n');+ } else {+ // Locally, use ensureAuthenticated which will register if neededawait authHelper.ensureAuthenticated();- console.log('✅ Authenticated via existing mechanism\n');- } catch (authError) {- console.log('❌ Cannot authenticate - skipping settings tests');- await browser.close();- process.exit(0);+ console.log('✅ Authenticated\n');}+ } catch (authError) {+ console.log(`⚠️ Could not authenticate: ${authError.message}`);+ console.log('❌ Cannot authenticate - skipping settings tests');+ await browser.close();+ testTimer.summary();+ process.exit(0);}// Navigate to settings page@@ -222,10 +224,12 @@ async function testSettingsValidation() {}await browser.close();+ testTimer.summary();process.exit(1);}await browser.close();+ testTimer.summary();console.log('\n✅ Test completed successfully');}