~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(test): await save PUT before reload in egress-policy UI test (#5491)
LearningCircuit9212cbaf5d40
diff --git a/tests/ui_tests/test_egress_policy_ui.js b/tests/ui_tests/test_egress_policy_ui.jsindex c6862c153b..5b6cd329ce 100644--- a/tests/ui_tests/test_egress_policy_ui.js+++ b/tests/ui_tests/test_egress_policy_ui.js@@ -74,6 +74,38 @@ async function sleep(ms) {return new Promise(r => setTimeout(r, ms));}+/**+ * Resolve when the PUT that saves a single setting round-trips.+ * MUST be registered before the action that triggers the save — Puppeteer+ * only sees responses that arrive after the listener is attached.+ *+ * Used in place of a fixed sleep so the test never reloads (or navigates)+ * while a save fetch is still in-flight, which would abort it and leave+ * the setting unpersisted (the race that flaked emb-persists-reload).+ */+function waitForSettingPut(page, settingKey) {+ const expectedPath = `/settings/api/${settingKey}`;+ return page.waitForResponse(+ (r) =>+ r.request().method() === 'PUT' &&+ new URL(r.url()).pathname === expectedPath,+ { timeout: 10000 },+ )+ .then(async (response) => {+ // Resolve only on a successful save — a 4xx/5xx (e.g. a+ // validation rejection) means the setting did NOT persist, and+ // the reload below would then fail with a confusing+ // "reloaded=false" instead of this explicit error.+ if (!response.ok()) {+ const body = await response.text().catch(() => '');+ throw new Error(+ `PUT ${settingKey} failed with HTTP ${response.status()}: ${body.slice(0, 300)}`,+ );+ }+ return response;+ });+}+/*** Set the scope dropdown to `value` and wait for the live JS hook to* update body[data-scope]. Returns the body's data-scope after the@@ -306,8 +338,14 @@ async function main() {// -----------------------------------------------------------await run('7. Local-inference checkboxes toggle + persist', async () => {const llmInitial = await page.$eval('#llm_require_local_endpoint', (el) => el.checked);+ // Await the save PUT's response before reading state or reloading.+ // The change handler fires an async fetch; a fixed sleep races+ // page.reload() which aborts in-flight requests — the embedding+ // toggle (clicked second, closest to reload) lost that race under+ // CI DB-write latency and never persisted (emb-persists-reload).+ const llmSaveP = waitForSettingPut(page, 'llm.require_local_endpoint');await page.click('#llm_require_local_endpoint');- await sleep(IS_CI ? 500 : 300);+ await llmSaveP;const llmAfter = await page.$eval('#llm_require_local_endpoint', (el) => el.checked);record('llm-toggle-flips',@@ -316,8 +354,9 @@ async function main() {);const embInitial = await page.$eval('#embeddings_require_local', (el) => el.checked);+ const embSaveP = waitForSettingPut(page, 'embeddings.require_local');await page.click('#embeddings_require_local');- await sleep(IS_CI ? 500 : 300);+ await embSaveP;const embAfter = await page.$eval('#embeddings_require_local', (el) => el.checked);record('emb-toggle-flips',@@ -346,9 +385,22 @@ async function main() {await screenshot(page, '07-toggles-after-reload');// Restore to original to leave the env clean for repeat runs.- if (llmAfter !== llmInitial) await page.click('#llm_require_local_endpoint');- if (embAfter !== embInitial) await page.click('#embeddings_require_local');- await sleep(IS_CI ? 500 : 300);+ // Await each restore PUT so the next test's navigation can't+ // abort it (same race that flaked the persist assertions above).+ // Restore based on what actually persisted (the reloaded+ // values), not the pre-reload DOM state — if a save was rejected+ // the reloaded value already equals the initial and clicking+ // again would flip it AWAY from the intended baseline.+ if (llmReloaded !== llmInitial) {+ const restoreLlm = waitForSettingPut(page, 'llm.require_local_endpoint');+ await page.click('#llm_require_local_endpoint');+ await restoreLlm;+ }+ if (embReloaded !== embInitial) {+ const restoreEmb = waitForSettingPut(page, 'embeddings.require_local');+ await page.click('#embeddings_require_local');+ await restoreEmb;+ }});// -----------------------------------------------------------@@ -498,8 +550,11 @@ async function main() {// control, then reload and verify the form reflects them.await selectScope(page, 'public_only');const llmStart = await page.$eval('#llm_require_local_endpoint', (el) => el.checked);- if (!llmStart) await page.click('#llm_require_local_endpoint');- await sleep(IS_CI ? 500 : 300);+ if (!llmStart) {+ const llmSaveP = waitForSettingPut(page, 'llm.require_local_endpoint');+ await page.click('#llm_require_local_endpoint');+ await llmSaveP;+ }await page.reload({ waitUntil: 'domcontentloaded' });await page.waitForSelector('#policy_egress_scope', { timeout: 10000 });