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(ui-tests): real assertion for flashMessagesDisplayed (dead-field audit) (#4657)

LearningCircuitc031f0de64a0
diff --git a/tests/ui_tests/test_loading_feedback_ci.js b/tests/ui_tests/test_loading_feedback_ci.js
index 177d350234..d697060c74 100644
--- a/tests/ui_tests/test_loading_feedback_ci.js
+++ b/tests/ui_tests/test_loading_feedback_ci.js
@@ -222,26 +222,63 @@ const ToastNotificationsTests = {
},
async flashMessagesDisplayed(page, baseUrl) {
+ // The app shows flash/alert messages by routing showAlert(...) through
+ // window.showSafeAlert, which renders into the #research-alert live region.
+ // The old test queried alert selectors on a fresh / and returned passed:true
+ // unconditionally — it never verified a message is displayed. Drive the real
+ // display function with a marker and assert it renders a visible alert.
+ //
+ // showSafeAlert clears the container and appends the alert SYNCHRONOUSLY, so we
+ // trigger and read in a single page.evaluate: that both isolates the marker from
+ // the on-load /api/warnings check (which also renders into this same container)
+ // and removes any async race. We drive showSafeAlert directly rather than a real
+ // user trigger, so this is a rendering-mechanism check.
await navigateTo(page, `${baseUrl}/`);
-
- const result = await page.evaluate(() => {
- const flashMessages = document.querySelectorAll(
- '.flash, ' +
- '.alert, ' +
- '.message, ' +
- '[role="alert"], ' +
- '.notification'
- );
-
+ await page.waitForSelector('#research-alert', { timeout: 15000 });
+
+ const MARKER = 'LDR_UI_TEST_FLASH_MARKER';
+ const result = await page.evaluate((marker) => {
+ if (typeof window.showSafeAlert !== 'function') return { hasMechanism: false };
+ const a = document.querySelector('#research-alert');
+ if (!a) return { hasMechanism: true, hasContainer: false };
+ a.innerHTML = '';
+ a.style.display = 'none';
+ window.showSafeAlert('research-alert', marker, 'error');
+ // Read in the same synchronous tick — no async warning re-render can race it.
+ const child = a.firstElementChild;
return {
- count: flashMessages.length,
- types: Array.from(flashMessages).map(m => m.className.substring(0, 30))
+ hasMechanism: true,
+ hasContainer: true,
+ visible: window.getComputedStyle(a).display !== 'none',
+ childCount: a.children.length,
+ rendered: a.textContent.includes(marker),
+ // role of the APPENDED alert element (createSafeAlertElement sets
+ // role="alert"), not the container's static template role — so this
+ // conjunct actually verifies the rendered alert, not a constant.
+ childRole: child ? child.getAttribute('role') : null,
};
+ }, MARKER);
+
+ // Restore #research-alert to its hidden/empty default so the marker alert
+ // doesn't leak into sibling tests that share this page.
+ await page.evaluate(() => {
+ const a = document.querySelector('#research-alert');
+ if (a) { a.innerHTML = ''; a.style.display = 'none'; }
});
+ if (!result.hasMechanism) {
+ return { passed: false, message: 'Alert mechanism (window.showSafeAlert) not loaded on /' };
+ }
+ if (!result.hasContainer) {
+ return { passed: false, message: '#research-alert container not found on /' };
+ }
+ const passed = result.rendered && result.visible && result.childCount > 0
+ && result.childRole === 'alert';
return {
- passed: true,
- message: `Flash messages: ${result.count} found (${result.types.slice(0, 3).join(', ')})`
+ passed,
+ message: passed
+ ? `Flash message rendered into #research-alert (alert role="alert", visible, ${result.childCount} child)`
+ : `Flash message not displayed (rendered=${result.rendered}, visible=${result.visible}, children=${result.childCount}, childRole=${result.childRole})`
};
}
};