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: Properly wait for navigation after research submit

LearningCircuit1edb12b6990a
diff --git a/tests/ui_tests/test_export_functionality.js b/tests/ui_tests/test_export_functionality.js
index 1e5ee12c15..0995b5d6dd 100644
--- a/tests/ui_tests/test_export_functionality.js
+++ b/tests/ui_tests/test_export_functionality.js
@@ -135,16 +135,31 @@ async function createResearchAndWait(page) {
const testQuery = 'What is 2+2?';
await page.type('#query', testQuery);
- // Submit research
+ // Submit research and wait for navigation to complete
+ // Use Promise.race to handle both navigation and staying on same page
const submitButton = await page.$('button[type="submit"]');
- if (submitButton) {
- await submitButton.click();
- } else {
- await page.keyboard.press('Enter');
+
+ try {
+ // Wait for either navigation or a timeout (page stays on home)
+ await Promise.race([
+ Promise.all([
+ page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: 10000 }),
+ submitButton ? submitButton.click() : page.keyboard.press('Enter')
+ ]),
+ // If no navigation happens within 5s, research was queued/async
+ delay(5000)
+ ]);
+ } catch (navErr) {
+ // Navigation timeout is fine - page might stay on home page
+ log(`ℹ️ No navigation after submit (research may be queued)`, 'info');
}
- // Wait for navigation
- await delay(3000);
+ // Give page time to settle after any navigation
+ await delay(1000);
+
+ // Now check the final URL - page should be stable at this point
+ const url = page.url();
+ log(`📍 Current URL after submit: ${url}`, 'info');
// Check if research was submitted
// NOTE: The page can navigate to different URLs depending on the app state:
@@ -152,39 +167,29 @@ async function createResearchAndWait(page) {
// - /progress/{id} - progress page (legacy)
// - /results/{id} - results page
// - / - home page (if queued or error shown inline)
- const url = page.url();
const navigatedToResearchPage = url.includes('/research/') ||
url.includes('/progress/') ||
url.includes('/results/');
// Also check if we stayed on home page but research was accepted
- // The browser console shows "Research started successfully" if API returned success
- // Handle various URL formats: with/without trailing slash, with query params
const urlWithoutParams = url.split('?')[0];
const stayedOnHomePage = urlWithoutParams === BASE_URL ||
urlWithoutParams === `${BASE_URL}/`;
- // If we stayed on home page, verify no error message is shown
- // NOTE: Wrap in try-catch because page might navigate during evaluate()
- // which causes "Execution context was destroyed" error
+ // If we stayed on home page, check for error messages
if (stayedOnHomePage) {
- try {
- const hasError = await page.evaluate(() => {
- const errorElements = document.querySelectorAll('.alert-danger, .error-message, .toast-error');
- for (const el of errorElements) {
- if (el.textContent.trim()) {
- return el.textContent.trim();
- }
+ const hasError = await page.evaluate(() => {
+ const errorElements = document.querySelectorAll('.alert-danger, .error-message, .toast-error');
+ for (const el of errorElements) {
+ if (el.textContent.trim()) {
+ return el.textContent.trim();
}
- return null;
- });
- if (hasError) {
- log(`⚠️ Error found on home page: ${hasError}`, 'warning');
- // Don't fail - the export test can still check history page
}
- } catch (evalErr) {
- // Page navigated during evaluate - this is fine, research started
- log(`ℹ️ Page navigated during check (research started)`, 'info');
+ return null;
+ });
+ if (hasError) {
+ log(`⚠️ Error found on home page: ${hasError}`, 'warning');
+ // Don't fail - the export test can still check history page
}
}