~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: make SSRF test mocks compatible with Python 3.14 (#2955)
LearningCircuit1d046fadf1e2
diff --git a/src/local_deep_research/security/safe_requests.py b/src/local_deep_research/security/safe_requests.pyindex 326cc303ed..806e7fabfc 100644--- a/src/local_deep_research/security/safe_requests.py+++ b/src/local_deep_research/security/safe_requests.py@@ -10,7 +10,7 @@ from urllib.parse import urljoinfrom loguru import logger-from .ssrf_validator import validate_url+from . import ssrf_validator# Default timeout for all HTTP requests (prevents hanging)@@ -157,7 +157,7 @@ def safe_get(requests.RequestException: If request fails"""# Validate URL to prevent SSRF- if not validate_url(+ if not ssrf_validator.validate_url(url,allow_localhost=allow_localhost,allow_private_ips=allow_private_ips,@@ -201,7 +201,7 @@ def safe_get()# Validate redirect target against SSRF rules- if not validate_url(+ if not ssrf_validator.validate_url(redirect_url,allow_localhost=allow_localhost,allow_private_ips=allow_private_ips,@@ -284,7 +284,7 @@ def safe_post(requests.RequestException: If request fails"""# Validate URL to prevent SSRF- if not validate_url(+ if not ssrf_validator.validate_url(url,allow_localhost=allow_localhost,allow_private_ips=allow_private_ips,@@ -327,7 +327,7 @@ def safe_post()# Validate redirect target against SSRF rules- if not validate_url(+ if not ssrf_validator.validate_url(redirect_url,allow_localhost=allow_localhost,allow_private_ips=allow_private_ips,@@ -440,7 +440,7 @@ class SafeSession(requests.Session):def request(self, method: str, url: str, **kwargs) -> requests.Response:"""Override request method to add SSRF validation."""# Validate URL- if not validate_url(+ if not ssrf_validator.validate_url(url,allow_localhost=self.allow_localhost,allow_private_ips=self.allow_private_ips,@@ -466,7 +466,7 @@ class SafeSession(requests.Session):therefore validated twice (once in ``request()``, once here);this is intentional defense-in-depth."""- if request.url and not validate_url(+ if request.url and not ssrf_validator.validate_url(request.url,allow_localhost=self.allow_localhost,allow_private_ips=self.allow_private_ips,diff --git a/tests/security/test_check_response_size.py b/tests/security/test_check_response_size.pyindex 06bb6a3435..bdfea60a67 100644--- a/tests/security/test_check_response_size.py+++ b/tests/security/test_check_response_size.py@@ -10,6 +10,7 @@ from unittest.mock import patch, MagicMockimport requests+from local_deep_research.security import ssrf_validatorfrom local_deep_research.security.safe_requests import (_check_response_size,SafeSession,@@ -97,8 +98,9 @@ def _prep_request(url="https://example.com"):@pytest.fixturedef _bypass_ssrf():"""Patch validate_url to always return True (bypass SSRF check)."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):yielddiff --git a/tests/security/test_safe_requests.py b/tests/security/test_safe_requests.pyindex 132205d661..5a8b7f6135 100644--- a/tests/security/test_safe_requests.py+++ b/tests/security/test_safe_requests.py@@ -4,6 +4,7 @@ import pytestfrom unittest.mock import patch, MagicMockimport requests+from local_deep_research.security import ssrf_validatorfrom local_deep_research.security.safe_requests import (safe_get,safe_post,@@ -18,8 +19,9 @@ class TestSafeGetFunction:def test_valid_url_makes_request(self):"""Should make request to valid external URL."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -36,8 +38,9 @@ class TestSafeGetFunction:def test_rejects_invalid_url(self):"""Should raise ValueError for URLs failing SSRF validation."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=False,):with pytest.raises(ValueError, match="SSRF"):@@ -45,8 +48,9 @@ class TestSafeGetFunction:def test_uses_default_timeout(self):"""Should use default timeout when not specified."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -63,8 +67,9 @@ class TestSafeGetFunction:def test_custom_timeout(self):"""Should use custom timeout when provided."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -82,8 +87,9 @@ class TestSafeGetFunction:def test_underlying_requests_always_gets_redirects_disabled(self):"""The underlying requests.get() always receives allow_redirects=False;safe_get handles redirects manually with SSRF validation."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -101,8 +107,9 @@ class TestSafeGetFunction:def test_can_enable_redirects(self):"""With allow_redirects=True, redirects are still disabled atrequests level (handled manually for SSRF validation)."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -121,8 +128,9 @@ class TestSafeGetFunction:def test_passes_params(self):"""Should pass URL parameters."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -142,8 +150,9 @@ class TestSafeGetFunction:def test_oversized_response_raises_error(self):"""Oversized responses are rejected with ValueError."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -160,8 +169,9 @@ class TestSafeGetFunction:def test_accepts_response_within_limit(self):"""Should accept response within size limit."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -176,8 +186,9 @@ class TestSafeGetFunction:def test_handles_invalid_content_length(self):"""Should ignore invalid Content-Length values."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -193,8 +204,9 @@ class TestSafeGetFunction:def test_reraises_timeout(self):"""Should re-raise timeout exceptions."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -206,8 +218,9 @@ class TestSafeGetFunction:def test_reraises_request_exception(self):"""Should re-raise request exceptions."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -219,8 +232,9 @@ class TestSafeGetFunction:def test_allow_localhost_parameter(self):"""Should pass allow_localhost to validate_url."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,) as mock_validate:with patch(@@ -240,8 +254,9 @@ class TestSafeGetFunction:def test_allow_private_ips_parameter(self):"""Should pass allow_private_ips to validate_url."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,) as mock_validate:with patch(@@ -265,8 +280,9 @@ class TestSafePostFunction:def test_valid_url_makes_request(self):"""Should make POST request to valid external URL."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -285,8 +301,9 @@ class TestSafePostFunction:def test_rejects_invalid_url(self):"""Should raise ValueError for URLs failing SSRF validation."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=False,):with pytest.raises(ValueError, match="SSRF"):@@ -294,8 +311,9 @@ class TestSafePostFunction:def test_passes_data_parameter(self):"""Should pass data parameter for form data."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -312,8 +330,9 @@ class TestSafePostFunction:def test_passes_json_parameter(self):"""Should pass json parameter for JSON data."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -331,8 +350,9 @@ class TestSafePostFunction:def test_uses_default_timeout(self):"""Should use default timeout when not specified."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -350,8 +370,9 @@ class TestSafePostFunction:def test_underlying_requests_always_gets_redirects_disabled(self):"""The underlying requests.post() always receives allow_redirects=False;safe_post handles redirects manually with SSRF validation."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -369,8 +390,9 @@ class TestSafePostFunction:def test_can_enable_redirects(self):"""With allow_redirects=True, redirects are still disabled atrequests level (handled manually for SSRF validation)."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -389,8 +411,9 @@ class TestSafePostFunction:def test_oversized_response_raises_error(self):"""Oversized responses are rejected with ValueError."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -407,8 +430,9 @@ class TestSafePostFunction:def test_reraises_timeout(self):"""Should re-raise timeout exceptions."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch(@@ -442,8 +466,9 @@ class TestSafeSession:def test_request_validates_url(self):"""Should validate URL before making request."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=False,):session = SafeSession()@@ -452,8 +477,9 @@ class TestSafeSession:def test_request_makes_call_on_valid_url(self):"""Should make request when URL is valid."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch.object(requests.Session, "request") as mock_request:@@ -468,8 +494,9 @@ class TestSafeSession:def test_request_uses_default_timeout(self):"""Should set default timeout if not provided."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch.object(requests.Session, "request") as mock_request:@@ -484,8 +511,9 @@ class TestSafeSession:def test_request_respects_custom_timeout(self):"""Should respect custom timeout when provided."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with patch.object(requests.Session, "request") as mock_request:@@ -500,8 +528,9 @@ class TestSafeSession:def test_context_manager(self):"""Should work as context manager."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,):with SafeSession() as session:@@ -509,8 +538,9 @@ class TestSafeSession:def test_passes_allow_localhost_to_validate(self):"""Should pass allow_localhost to validate_url."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,) as mock_validate:with patch.object(requests.Session, "request"):@@ -525,8 +555,9 @@ class TestSafeSession:def test_passes_allow_private_ips_to_validate(self):"""Should pass allow_private_ips to validate_url."""- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,) as mock_validate:with patch.object(requests.Session, "request"):diff --git a/tests/security/test_ssrf_redirect_bypass.py b/tests/security/test_ssrf_redirect_bypass.pyindex 514cbf1dfb..dff6447674 100644--- a/tests/security/test_ssrf_redirect_bypass.py+++ b/tests/security/test_ssrf_redirect_bypass.py@@ -13,7 +13,8 @@ from unittest.mock import patch, MagicMockimport requests-from local_deep_research.security import safe_requests as _sr_mod+from local_deep_research.security import ssrf_validator+from local_deep_research.security.safe_requests import (safe_get,safe_post,@@ -28,7 +29,7 @@ from local_deep_research.security.safe_requests import (@pytest.fixturedef mock_validate_url():with patch.object(- _sr_mod,+ ssrf_validator,"validate_url",return_value=True,) as m:@@ -428,7 +429,11 @@ class TestSafeSessionRedirectFollowing:prep.prepare_url("http://169.254.169.254/metadata", {})prep.prepare_method("GET")- with patch.object(_sr_mod, "validate_url", return_value=False):+ with patch.object(+ ssrf_validator,+ "validate_url",+ return_value=False,+ ):with pytest.raises(ValueError, match="Redirect target failed"):session.send(prep)@@ -440,7 +445,11 @@ class TestSafeSessionRedirectFollowing:prep.prepare_url("https://example.com", {})prep.prepare_method("GET")- with patch.object(_sr_mod, "validate_url", return_value=True):+ with patch.object(+ ssrf_validator,+ "validate_url",+ return_value=True,+ ):with patch.object(requests.Session, "send", return_value=_make_response(200)):@@ -455,7 +464,11 @@ class TestSafeSessionRedirectFollowing:prep.prepare_url("http://127.0.0.1/admin", {})prep.prepare_method("GET")- with patch.object(_sr_mod, "validate_url", return_value=False):+ with patch.object(+ ssrf_validator,+ "validate_url",+ return_value=False,+ ):with pytest.raises(ValueError, match="SSRF"):session.send(prep)@@ -468,7 +481,9 @@ class TestSafeSessionRedirectFollowing:prep.prepare_method("GET")with patch.object(- _sr_mod, "validate_url", return_value=True+ ssrf_validator,+ "validate_url",+ return_value=True,) as mock_validate:with patch.object(requests.Session, "send", return_value=_make_response(200)@@ -489,7 +504,9 @@ class TestSafeSessionRedirectFollowing:prep.prepare_method("GET")with patch.object(- _sr_mod, "validate_url", return_value=True+ ssrf_validator,+ "validate_url",+ return_value=True,) as mock_validate:with patch.object(requests.Session, "send", return_value=_make_response(200)@@ -503,7 +520,11 @@ class TestSafeSessionRedirectFollowing:def test_request_validates_initial_url(self):"""SafeSession.request() validates the initial URL."""- with patch.object(_sr_mod, "validate_url", return_value=False):+ with patch.object(+ ssrf_validator,+ "validate_url",+ return_value=False,+ ):session = SafeSession()with pytest.raises(ValueError, match="SSRF"):session.request("GET", "http://169.254.169.254/metadata")@@ -820,7 +841,11 @@ class TestSafeSessionContentLength:oversized_resp = _make_response(200)oversized_resp.headers = {"Content-Length": str(MAX_RESPONSE_SIZE + 1)}- with patch.object(_sr_mod, "validate_url", return_value=True):+ with patch.object(+ ssrf_validator,+ "validate_url",+ return_value=True,+ ):with patch.object(requests.Session, "send", return_value=oversized_resp):@@ -840,7 +865,11 @@ class TestSafeSessionContentLength:normal_resp = _make_response(200)normal_resp.headers = {"Content-Length": "1024"}- with patch.object(_sr_mod, "validate_url", return_value=True):+ with patch.object(+ ssrf_validator,+ "validate_url",+ return_value=True,+ ):with patch.object(requests.Session, "send", return_value=normal_resp):diff --git a/tests/security/test_ssrf_response_size.py b/tests/security/test_ssrf_response_size.pyindex 111cb54a15..ad9d101ec9 100644--- a/tests/security/test_ssrf_response_size.py+++ b/tests/security/test_ssrf_response_size.py@@ -10,6 +10,7 @@ from unittest.mock import patch, MagicMockfrom io import BytesIO+from local_deep_research.security import ssrf_validatorfrom local_deep_research.security.safe_requests import (safe_get,safe_post,@@ -22,8 +23,9 @@ from local_deep_research.security.safe_requests import (@pytest.fixturedef mock_validate_url():- with patch(- "local_deep_research.security.safe_requests.validate_url",+ with patch.object(+ ssrf_validator,+ "validate_url",return_value=True,) as m:yield mdiff --git a/tests/security/test_ssrf_validator_high_value.py b/tests/security/test_ssrf_validator_high_value.pyindex 4bddf5b024..8a9478871a 100644--- a/tests/security/test_ssrf_validator_high_value.py+++ b/tests/security/test_ssrf_validator_high_value.py@@ -4,8 +4,8 @@ import osimport socketfrom unittest.mock import patch+from local_deep_research.security import ssrf_validator-from local_deep_research.security import ssrf_validator as _ssrf_modfrom local_deep_research.security.ssrf_validator import (is_ip_blocked,validate_url,@@ -288,11 +288,19 @@ class TestGetSafeUrl:assert get_safe_url("", "fallback") == "fallback"def test_safe_url_passes_through(self):- with patch.object(_ssrf_mod, "validate_url", return_value=True):+ with patch.object(+ ssrf_validator,+ "validate_url",+ return_value=True,+ ):assert get_safe_url("http://example.com") == "http://example.com"def test_unsafe_url_returns_default(self):- with patch.object(_ssrf_mod, "validate_url", return_value=False):+ with patch.object(+ ssrf_validator,+ "validate_url",+ return_value=False,+ ):assert get_safe_url("http://evil.internal", "safe") == "safe"def test_none_url_none_default(self):diff --git a/tests/ui_tests/test_api_endpoints_ci.js b/tests/ui_tests/test_api_endpoints_ci.jsindex eca69db4f2..d70dc5c2eb 100644--- a/tests/ui_tests/test_api_endpoints_ci.js+++ b/tests/ui_tests/test_api_endpoints_ci.js@@ -725,11 +725,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_benchmark_ci.js b/tests/ui_tests/test_benchmark_ci.jsindex 71b014d935..7f60749e93 100644--- a/tests/ui_tests/test_benchmark_ci.js+++ b/tests/ui_tests/test_benchmark_ci.js@@ -478,11 +478,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_context_overflow_ci.js b/tests/ui_tests/test_context_overflow_ci.jsindex 640ec31a64..051fd792fc 100644--- a/tests/ui_tests/test_context_overflow_ci.js+++ b/tests/ui_tests/test_context_overflow_ci.js@@ -272,11 +272,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_crud_operations_ci.js b/tests/ui_tests/test_crud_operations_ci.jsindex 2a16bda70d..59cff591fc 100644--- a/tests/ui_tests/test_crud_operations_ci.js+++ b/tests/ui_tests/test_crud_operations_ci.js@@ -658,11 +658,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_error_handling_ci.js b/tests/ui_tests/test_error_handling_ci.jsindex 07f28efbde..ba35a9af05 100644--- a/tests/ui_tests/test_error_handling_ci.js+++ b/tests/ui_tests/test_error_handling_ci.js@@ -495,26 +495,52 @@ async function main() {log.section('401 Authentication');await results.run('401', 'Unauthenticated Redirects To Login', () => Error401Tests.unauthenticatedRedirectsToLogin(page, baseUrl), { page });- // After 401 test cleared cookies, reload login page to get a fresh CSRF token- // (the old page has a stale token from the cleared session)+ // After 401 test cleared cookies, re-authenticate on a fresh login page.+ // We avoid waitForNavigation here — if login fails (CSRF, wrong password),+ // it stays on /auth/login and waitForNavigation hangs for the full timeout.+ // Instead: click submit, then poll for URL change or session cookie.+ let reAuthOk = false;try {await page.goto(`${baseUrl}/auth/login`, { waitUntil: 'domcontentloaded', timeout: 15000 });- await page.waitForSelector('form[action*="login"], input[type="password"], .login-form', { timeout: 10000 });- } catch (reloadError) {- log.warning(`Could not reload login page: ${reloadError.message}`);+ await page.waitForSelector('input[name="username"]', { timeout: 10000 });+ await page.$eval('input[name="username"]', el => el.value = '');+ await page.$eval('input[name="password"]', el => el.value = '');+ await page.type('input[name="username"]', 'test_admin');+ await page.type('input[name="password"]', 'testpass123');+ await page.click('button[type="submit"]');++ // Poll for up to 15s: either we leave /auth/login or get a session cookie+ for (let i = 0; i < 30; i++) {+ await delay(500);+ const url = page.url();+ if (!url.includes('/auth/login')) {+ reAuthOk = true;+ break;+ }+ const cookies = await page.cookies();+ if (cookies.some(c => c.name === 'session')) {+ // Have session cookie but still on login page — navigate away+ await page.goto(baseUrl, { waitUntil: 'domcontentloaded', timeout: 15000 });+ reAuthOk = true;+ break;+ }+ }+ } catch (reAuthError) {+ log.warning(`Direct re-auth failed: ${reAuthError.message}`);}- // Re-authenticate after 401 tests- let reAuthOk = false;- try {- await withTimeout(- ctx.authHelper.ensureAuthenticated(),- 30000,- 'Re-authentication after 401 tests'- );- reAuthOk = true;- } catch (error) {- log.warning(`Re-authentication timed out: ${error.message}`);+ // Fallback: try ensureAuthenticated if direct login failed+ if (!reAuthOk) {+ try {+ await withTimeout(+ ctx.authHelper.ensureAuthenticated(),+ 60000,+ 'Re-authentication after 401 tests'+ );+ reAuthOk = true;+ } catch (error) {+ log.warning(`Re-authentication timed out: ${error.message}`);+ }}if (reAuthOk) {@@ -533,7 +559,7 @@ async function main() {try {await withTimeout(ctx.authHelper.ensureAuthenticated(),- 30000,+ 60000,'Re-authentication for API tests');reAuthOk = true;diff --git a/tests/ui_tests/test_followup_research_ci.js b/tests/ui_tests/test_followup_research_ci.jsindex adfaa110f9..c9022e11d0 100644--- a/tests/ui_tests/test_followup_research_ci.js+++ b/tests/ui_tests/test_followup_research_ci.js@@ -432,11 +432,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_form_validation_aria_ci.js b/tests/ui_tests/test_form_validation_aria_ci.jsindex 8efbbc8c91..42c0d16fb2 100644--- a/tests/ui_tests/test_form_validation_aria_ci.js+++ b/tests/ui_tests/test_form_validation_aria_ci.js@@ -433,11 +433,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_history_page_ci.js b/tests/ui_tests/test_history_page_ci.jsindex bd183f2193..75fd02cd99 100644--- a/tests/ui_tests/test_history_page_ci.js+++ b/tests/ui_tests/test_history_page_ci.js@@ -310,11 +310,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_keyboard_accessibility_ci.js b/tests/ui_tests/test_keyboard_accessibility_ci.jsindex d886337e21..b598c51fa7 100644--- a/tests/ui_tests/test_keyboard_accessibility_ci.js+++ b/tests/ui_tests/test_keyboard_accessibility_ci.js@@ -568,11 +568,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_library_collections_ci.js b/tests/ui_tests/test_library_collections_ci.jsindex 937fc9ed2d..417e07651c 100644--- a/tests/ui_tests/test_library_collections_ci.js+++ b/tests/ui_tests/test_library_collections_ci.js@@ -393,11 +393,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_library_documents_ci.js b/tests/ui_tests/test_library_documents_ci.jsindex 41f7645486..95378485f4 100644--- a/tests/ui_tests/test_library_documents_ci.js+++ b/tests/ui_tests/test_library_documents_ci.js@@ -733,11 +733,12 @@ async function main() {// Helper: run a sub-test with a 30s timeout so a single hang// doesn't block the entire 300s process-level timeout.+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_loading_feedback_ci.js b/tests/ui_tests/test_loading_feedback_ci.jsindex 51f264046c..753d6ed6d6 100644--- a/tests/ui_tests/test_loading_feedback_ci.js+++ b/tests/ui_tests/test_loading_feedback_ci.js@@ -692,11 +692,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_metrics_dashboard_ci.js b/tests/ui_tests/test_metrics_dashboard_ci.jsindex c51936e662..12862f5773 100644--- a/tests/ui_tests/test_metrics_dashboard_ci.js+++ b/tests/ui_tests/test_metrics_dashboard_ci.js@@ -688,11 +688,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_mobile_interactions_ci.js b/tests/ui_tests/test_mobile_interactions_ci.jsindex 755bde2e9d..967edb7f8e 100644--- a/tests/ui_tests/test_mobile_interactions_ci.js+++ b/tests/ui_tests/test_mobile_interactions_ci.js@@ -481,11 +481,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_news_feed_ci.js b/tests/ui_tests/test_news_feed_ci.jsindex 26a94d3b8a..aae6205741 100644--- a/tests/ui_tests/test_news_feed_ci.js+++ b/tests/ui_tests/test_news_feed_ci.js@@ -697,13 +697,16 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;- // Helper: run a sub-test with a 30s timeout so a single hang+ // Helper: run a sub-test with a timeout so a single hang// doesn't block the entire 300s process-level timeout.+ // Use 60s to match navigateTo's CI timeout — 30s was too tight+ // when the server is under load from prior test files.+ const testTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ testTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_news_subscriptions_ci.js b/tests/ui_tests/test_news_subscriptions_ci.jsindex 60671569d5..d8356f66c6 100644--- a/tests/ui_tests/test_news_subscriptions_ci.js+++ b/tests/ui_tests/test_news_subscriptions_ci.js@@ -470,11 +470,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_realtime_progress_ci.js b/tests/ui_tests/test_realtime_progress_ci.jsindex 31eb9e4c17..4ae8f65ad5 100644--- a/tests/ui_tests/test_realtime_progress_ci.js+++ b/tests/ui_tests/test_realtime_progress_ci.js@@ -437,11 +437,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_research_form_ci.js b/tests/ui_tests/test_research_form_ci.jsindex 441d2e2012..0b47dbbf9a 100644--- a/tests/ui_tests/test_research_form_ci.js+++ b/tests/ui_tests/test_research_form_ci.js@@ -783,11 +783,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_research_workflow_ci.js b/tests/ui_tests/test_research_workflow_ci.jsindex d8ee5b6269..c2a69bdf2c 100644--- a/tests/ui_tests/test_research_workflow_ci.js+++ b/tests/ui_tests/test_research_workflow_ci.js@@ -427,11 +427,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_results_exports_ci.js b/tests/ui_tests/test_results_exports_ci.jsindex 70a69bf932..8c4334a695 100644--- a/tests/ui_tests/test_results_exports_ci.js+++ b/tests/ui_tests/test_results_exports_ci.js@@ -671,11 +671,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_settings_interactions_ci.js b/tests/ui_tests/test_settings_interactions_ci.jsindex 40dd682e5f..3c61247005 100644--- a/tests/ui_tests/test_settings_interactions_ci.js+++ b/tests/ui_tests/test_settings_interactions_ci.js@@ -669,11 +669,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {diff --git a/tests/ui_tests/test_settings_pages_ci.js b/tests/ui_tests/test_settings_pages_ci.jsindex 53329860bc..4ed2042d5b 100644--- a/tests/ui_tests/test_settings_pages_ci.js+++ b/tests/ui_tests/test_settings_pages_ci.js@@ -124,22 +124,38 @@ const SettingsInputTests = {async modelProviderSetting(page, baseUrl) {await navigateTo(page, `${baseUrl}/settings/`);+ // Wait for settings form to render (inputs are loaded async via JS)+ try {+ await page.waitForSelector('[name="llm.provider"], select[name*="provider"]', { timeout: 15000 });+ } catch (e) {+ return { passed: null, skipped: true, message: 'No model provider setting found (form did not render)' };+ }+const result = await page.evaluate(() => {- const providerSelect = document.querySelector(+ const providerEl = document.querySelector('select[name*="provider"], ' +'select[data-setting*="provider"], ' +'#llm_provider, ' +'[name="llm.provider"]');- if (!providerSelect || providerSelect.tagName !== 'SELECT') return { exists: false };+ if (!providerEl) return { exists: false };++ // Accept both <select> and <input> (custom dropdown)+ if (providerEl.tagName === 'SELECT') {+ const options = Array.from(providerEl.options);+ return {+ exists: true,+ optionCount: options.length,+ options: options.map(o => ({ value: o.value, text: o.text })).slice(0, 8),+ currentValue: providerEl.value+ };+ }- const options = Array.from(providerSelect.options);return {exists: true,- optionCount: options.length,- options: options.map(o => ({ value: o.value, text: o.text })).slice(0, 8),- currentValue: providerSelect.value+ isCustom: true,+ currentValue: providerEl.value};});@@ -147,6 +163,13 @@ const SettingsInputTests = {return { passed: null, skipped: true, message: 'No model provider setting found' };}+ if (result.isCustom) {+ return {+ passed: true,+ message: `Model provider setting found (custom input, current: ${result.currentValue || 'default'})`+ };+ }+return {passed: result.optionCount > 0,message: `Model provider dropdown has ${result.optionCount} options (current: ${result.currentValue})`@@ -156,6 +179,19 @@ const SettingsInputTests = {async searchEngineSetting(page, baseUrl) {await navigateTo(page, `${baseUrl}/settings/`);+ // Ensure "All Settings" tab is active (previous test may have switched tabs)+ await page.evaluate(() => {+ const allTab = document.querySelector('[data-tab="all"], .ldr-settings-tab');+ if (allTab) allTab.click();+ });++ // Wait for settings form to render (search.tool is a hidden input in a custom dropdown)+ try {+ await page.waitForSelector('[name="search.tool"], select[name*="search"]', { timeout: 15000 });+ } catch (e) {+ return { passed: null, skipped: true, message: 'No search engine setting found (form did not render)' };+ }+const result = await page.evaluate(() => {// Check for standard <select>const engineSelect = document.querySelector(@@ -212,6 +248,13 @@ const SettingsInputTests = {async temperatureSetting(page, baseUrl) {await navigateTo(page, `${baseUrl}/settings/`);+ // Wait for settings form to render+ try {+ await page.waitForSelector('[name="llm.temperature"], input[name*="temperature"]', { timeout: 15000 });+ } catch (e) {+ return { passed: null, skipped: true, message: 'No temperature setting found (form did not render)' };+ }+const result = await page.evaluate(() => {const tempInput = document.querySelector('input[name*="temperature"], ' +@@ -244,6 +287,13 @@ const SettingsInputTests = {async apiKeyFieldMasked(page, baseUrl) {await navigateTo(page, `${baseUrl}/settings/`);+ // Wait for settings form to render+ try {+ await page.waitForSelector('input[name*="api_key"], input[type="password"][name*="key"]', { timeout: 15000 });+ } catch (e) {+ return { passed: null, skipped: true, message: 'No API key fields found (form did not render)' };+ }+const result = await page.evaluate(() => {const apiKeyInputs = document.querySelectorAll('input[name*="api_key"], ' +@@ -411,6 +461,13 @@ const SettingsStatusTests = {async ollamaStatusIndicator(page, baseUrl) {await navigateTo(page, `${baseUrl}/settings/`);+ // Wait for settings form to render before checking for ollama elements+ try {+ await page.waitForSelector('[name="llm.provider"], input[name*="api_key"]', { timeout: 15000 });+ } catch (e) {+ // Form didn't render — skip+ }+const result = await page.evaluate(() => {const ollamaStatus = document.querySelector('.ollama-status, ' +@@ -507,11 +564,12 @@ async function main() {const { page } = ctx;const { baseUrl } = ctx.config;+ const subTestTimeout = ctx.config.isCI ? 60000 : 30000;async function run(category, name, testFn) {try {const result = await withTimeout(testFn(page, baseUrl),- 30000,+ subTestTimeout,`${category}/${name}`);if (result.skipped) {