Skip to content

~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.

fix: use waitForNavigation instead of polling for CI registration

LearningCircuitc2488acd3e21
diff --git a/tests/ui_tests/auth_helper.js b/tests/ui_tests/auth_helper.js
index 557c4f2d65..8e2df2cef7 100644
--- a/tests/ui_tests/auth_helper.js
+++ b/tests/ui_tests/auth_helper.js
@@ -463,71 +463,60 @@ class AuthHelper {
timer.lap('checkbox clicked');
}
- // Submit form - use CI-specific polling approach to avoid timeout issues
+ // Submit form - use CI-specific approach with waitForNavigation + retries
if (this.isCI) {
- console.log(' Using CI-specific registration approach (polling for redirect)');
+ console.log(' Using CI-specific registration approach');
- // Click the submit button
- await this.page.click('button[type="submit"]');
+ // In CI, registration can take 2+ minutes due to encrypted DB creation.
+ // The page.evaluate() approach doesn't work because the page is unresponsive
+ // during server processing. Instead, we use waitForNavigation with retries.
- // Wait for either navigation or timeout - polling approach is more reliable
- // than waitForNavigation which can hang on slow CI runners
- let redirected = false;
- let currentUrl = '';
+ let registrationSucceeded = false;
- // Poll for up to 4 minutes (registration can take 2+ minutes in CI)
- const maxPolls = 120; // 120 * 2s = 4 minutes
- for (let i = 0; i < maxPolls; i++) {
- await this._delay(2000); // Check every 2 seconds
+ // First attempt: click and wait for navigation with a long timeout
+ console.log(' Submitting form and waiting for server response...');
+ try {
+ await Promise.all([
+ this.page.waitForNavigation({
+ waitUntil: 'domcontentloaded',
+ timeout: AUTH_CONFIG.timeouts.submitNavigation // 5 minutes
+ }),
+ this.page.click('button[type="submit"]')
+ ]);
- // Try to get URL with a timeout
- try {
- currentUrl = await Promise.race([
- this.page.evaluate(() => window.location.href),
- new Promise((_, reject) => setTimeout(() => reject(new Error('URL check timeout')), AUTH_CONFIG.timeouts.urlCheck))
- ]);
+ const currentUrl = this.page.url();
+ console.log(` Navigation completed. URL: ${currentUrl}`);
- // Log progress every 10 seconds
- if (i % 5 === 0) {
- console.log(` Checking URL (${i+1}/${maxPolls}): ${currentUrl}`);
- }
- } catch (urlError) {
- console.log(` Warning: Could not get URL (${i+1}/${maxPolls}): ${urlError.message}`);
- continue; // Skip this check and try again
+ if (!currentUrl.includes(AUTH_CONFIG.paths.register)) {
+ registrationSucceeded = true;
}
+ } catch (navError) {
+ console.log(` Navigation error: ${navError.message}`);
- // Check if we've been redirected away from registration page
- if (currentUrl && !currentUrl.includes(AUTH_CONFIG.paths.register)) {
- console.log(' ✅ Redirected away from registration page');
- redirected = true;
- break;
- }
+ // Handle frame detachment (page was replaced)
+ if (navError.message.includes('detached') || navError.message.includes('destroyed')) {
+ console.log(' Frame was replaced - registration likely succeeded');
+ await this._delay(AUTH_CONFIG.delays.afterRegistration);
- // Check for error messages on the page (with timeout protection)
- try {
- const errorElement = await Promise.race([
- this.page.$('.alert-danger:not(.alert-warning), .error-message'),
- new Promise(resolve => setTimeout(() => resolve(null), AUTH_CONFIG.timeouts.errorCheck))
- ]);
- if (errorElement) {
- const errorText = await this.page.evaluate(el => el.textContent, errorElement);
- if (errorText.includes('already exists')) {
- console.log('⚠️ User already exists, attempting login instead');
- return await this.login(username, password);
- }
- throw new Error(`Registration failed with error: ${errorText.trim()}`);
- }
- } catch (errorCheckError) {
- if (errorCheckError.message && errorCheckError.message.includes('Registration failed')) {
- throw errorCheckError;
+ // Navigate to home to verify
+ try {
+ await this.page.goto(this.baseUrl, {
+ waitUntil: AUTH_CONFIG.ci.waitUntil,
+ timeout: AUTH_CONFIG.timeouts.formSelector
+ });
+ registrationSucceeded = true;
+ } catch (gotoError) {
+ console.log(` Could not navigate to home: ${gotoError.message}`);
}
- // Otherwise ignore the error check failure
}
+ // For timeout errors, fall through to session verification below
}
- if (!redirected) {
- // Last resort: check if we can access the home page (session may be valid)
- console.log(' Polling timed out, checking session validity...');
+ // If navigation didn't clearly succeed, verify via session
+ if (!registrationSucceeded) {
+ console.log(' Verifying registration via session...');
+ await this._delay(5000); // Give server time to complete
+
try {
await this.page.goto(this.baseUrl, {
waitUntil: AUTH_CONFIG.ci.waitUntil,
@@ -535,23 +524,46 @@ class AuthHelper {
});
const homeUrl = this.page.url();
+ console.log(` After navigation to home: ${homeUrl}`);
+
if (!homeUrl.includes('/auth/login') && !homeUrl.includes('/auth/register')) {
// Check for logout button as proof of login
const logoutBtn = await this.page.$('#logout-form, a[href*="logout"], .logout');
if (logoutBtn) {
- console.log(' ✅ Registration succeeded (verified via session)');
- return true;
+ console.log(' ✅ Found logout button - registration succeeded');
+ registrationSucceeded = true;
}
}
} catch (sessionError) {
console.log(` Session check failed: ${sessionError.message}`);
}
+ }
- throw new Error('Registration timed out - no redirect detected after 4 minutes');
+ if (registrationSucceeded) {
+ console.log('✅ Registration successful');
+ return true;
}
- console.log('✅ Registration successful');
- return true;
+ // Check if still on registration page with an error
+ const currentUrl = this.page.url();
+ if (currentUrl.includes(AUTH_CONFIG.paths.register)) {
+ try {
+ const error = await this.page.$('.alert-danger:not(.alert-warning), .error-message');
+ if (error) {
+ const errorText = await this.page.evaluate(el => el.textContent, error);
+ if (errorText.includes('already exists')) {
+ console.log('⚠️ User already exists, attempting login instead');
+ return await this.login(username, password);
+ }
+ throw new Error(`Registration failed: ${errorText.trim()}`);
+ }
+ } catch (e) {
+ if (e.message.includes('Registration failed')) throw e;
+ // Ignore error checking errors
+ }
+ }
+
+ throw new Error('Registration failed - could not verify success');
}
// Non-CI logic - use waitForNavigation