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.

test(puppeteer): retry flaky navigations in Download Manager tests (#3794)

LearningCircuit9bc2e45984dc
diff --git a/tests/puppeteer/helpers/index.js b/tests/puppeteer/helpers/index.js
index a9931c4b9b..9d3618647e 100644
--- a/tests/puppeteer/helpers/index.js
+++ b/tests/puppeteer/helpers/index.js
@@ -61,6 +61,50 @@ function resetScreenshotCounter() {
screenshotCounter = 0;
}
+/**
+ * Navigate to a URL with retry on timeout/network errors.
+ *
+ * The CI environment is occasionally slow enough that a single page.goto
+ * exceeds the navigation timeout (e.g. /library/ on a cold app worker).
+ * Retrying the navigation a couple of times turns flaky timeouts into
+ * passing runs without masking real failures — if every attempt fails,
+ * the last error is rethrown.
+ *
+ * @param {object} page - Puppeteer page object
+ * @param {string} url - URL to navigate to
+ * @param {object} options - Options forwarded to page.goto, plus:
+ * - retries: number of retries after the first attempt (default 2)
+ * - retryDelayMs: pause between attempts (default 5000)
+ * - waitUntil: forwarded to page.goto (default 'domcontentloaded')
+ * - timeout: per-attempt timeout in ms (default 45000)
+ * @returns {Promise<object|null>} Puppeteer HTTPResponse from the successful goto
+ */
+async function gotoWithRetry(page, url, options = {}) {
+ const {
+ retries = 2,
+ retryDelayMs = 5000,
+ ...gotoOptions
+ } = options;
+ const navOptions = {
+ waitUntil: 'domcontentloaded',
+ timeout: 45000,
+ ...gotoOptions
+ };
+
+ let lastError;
+ for (let attempt = 1; attempt <= retries + 1; attempt++) {
+ try {
+ return await page.goto(url, navOptions);
+ } catch (err) {
+ lastError = err;
+ if (attempt > retries) break;
+ console.log(` gotoWithRetry: attempt ${attempt} for ${url} failed (${err.message}), retrying...`);
+ await delay(retryDelayMs);
+ }
+ }
+ throw lastError;
+}
+
/**
* Wait for an element and click it
* @param {object} page - Puppeteer page object
@@ -327,6 +371,7 @@ module.exports = {
delay,
takeScreenshot,
resetScreenshotCounter,
+ gotoWithRetry,
waitAndClick,
waitAndType,
getInputValue,
diff --git a/tests/puppeteer/test_deep_functionality.js b/tests/puppeteer/test_deep_functionality.js
index b96d914c27..5076cc26d2 100644
--- a/tests/puppeteer/test_deep_functionality.js
+++ b/tests/puppeteer/test_deep_functionality.js
@@ -23,7 +23,8 @@ const {
ensureLoggedIn,
getLaunchOptions,
generateTestRunId,
- getCSRFToken
+ getCSRFToken,
+ gotoWithRetry
} = require('./helpers');
// Generate unique username for this test run - ensures fresh state each time
@@ -1165,7 +1166,7 @@ describe('Deep Functionality Tests', function() {
describe('Download Manager', () => {
it('should load download manager page', async () => {
- await page.goto(`${BASE_URL}/library/downloads`, { waitUntil: 'domcontentloaded' });
+ await gotoWithRetry(page, `${BASE_URL}/library/downloads`);
await takeScreenshot(page, 'download-manager');
const url = page.url();
@@ -1177,7 +1178,7 @@ describe('Deep Functionality Tests', function() {
it('should show download queue or status', async () => {
// Navigate to library first (more reliable)
- await page.goto(`${BASE_URL}/library/`, { waitUntil: 'domcontentloaded' });
+ await gotoWithRetry(page, `${BASE_URL}/library/`);
// Look for download-related elements
const queueElements = await page.$$('.download-queue, .queue-item, [class*="download"], table, .ldr-library-container');