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(test): await egress scope save before navigation (#5592)

LearningCircuit73f2680bebc2
diff --git a/tests/ui_tests/test_egress_policy_ui.js b/tests/ui_tests/test_egress_policy_ui.js
index 5b6cd329ce..029a1b6c36 100644
--- a/tests/ui_tests/test_egress_policy_ui.js
+++ b/tests/ui_tests/test_egress_policy_ui.js
@@ -107,16 +107,34 @@ function waitForSettingPut(page, settingKey) {
}
/**
- * 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
- * change so callers can assert on it.
+ * Set the scope dropdown to `value`, wait for both the scope save PUT
+ * (policy.egress_scope) and the research-card colour transition to settle,
+ * and return the body's data-scope so callers can assert on it.
*/
async function selectScope(page, value) {
- await page.select('#policy_egress_scope', value);
- // Allow the change event handler (saveSearchSetting +
- // applyPrivacyPanelScope) to fan out. Save is async (POST to
- // /settings/api/save) so we wait a touch longer.
- await sleep(IS_CI ? 600 : 400);
+ // Register waiters before the select — waitForResponse only sees
+ // responses that arrive after attachment.
+ const scopeSaved = waitForSettingPut(page, 'policy.egress_scope');
+ const expectedBorder = SCOPE_PALETTE[value].border;
+ const visualReady = page.waitForFunction(
+ (scope, expected) => {
+ if (document.body.dataset.scope !== scope) return false;
+ const card = document.querySelector('.ldr-card.ldr-research-card');
+ if (!card) return false;
+ const color = getComputedStyle(card).borderLeftColor;
+ return expected === null
+ ? color === 'transparent' || color === 'rgba(0, 0, 0, 0)'
+ : color === expected;
+ },
+ { timeout: 10000 },
+ value,
+ expectedBorder,
+ );
+ await Promise.all([
+ page.select('#policy_egress_scope', value),
+ scopeSaved,
+ visualReady,
+ ]);
return page.evaluate(() => document.body.dataset.scope);
}