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 semanticColors (dead-field audit) (#4658)

LearningCircuitd4c5217c12c7
diff --git a/tests/ui_tests/test_keyboard_accessibility_ci.js b/tests/ui_tests/test_keyboard_accessibility_ci.js
index 72304c7cb0..d541bd122d 100644
--- a/tests/ui_tests/test_keyboard_accessibility_ci.js
+++ b/tests/ui_tests/test_keyboard_accessibility_ci.js
@@ -553,23 +553,56 @@ const AriaLabelsTests = {
// ============================================================================
const ColorContrastTests = {
async semanticColors(page, baseUrl) {
+ // Semantic states (error / success / warning) must be visually distinguished
+ // by colour. The old test queried .error/.success/.warning elements then
+ // returned passed:true unconditionally — it never compared anything. Render an
+ // alert of each type via the app's own alert function (window.showSafeAlert ->
+ // #research-alert) and assert all three are PAIRWISE DISTINCT in text /
+ // background / border colour. Deterministic and LLM-independent.
await navigateTo(page, `${baseUrl}/`);
+ await page.waitForSelector('#research-alert', { timeout: 15000 });
- const result = await page.evaluate(() => {
- const errorElements = document.querySelectorAll('.error, .danger, .alert-danger, [class*="error"]');
- const successElements = document.querySelectorAll('.success, .alert-success, [class*="success"]');
- const warningElements = document.querySelectorAll('.warning, .alert-warning, [class*="warning"]');
+ const hasMechanism = await page.evaluate(() => typeof window.showSafeAlert === 'function');
+ if (!hasMechanism) {
+ return { passed: false, message: 'Alert mechanism (window.showSafeAlert) not loaded on /' };
+ }
- return {
- errorCount: errorElements.length,
- successCount: successElements.length,
- warningCount: warningElements.length
- };
+ const colorFor = (type) => page.evaluate((t) => {
+ const a = document.querySelector('#research-alert');
+ if (!a) return null;
+ a.innerHTML = '';
+ a.style.display = 'none';
+ window.showSafeAlert('research-alert', `semantic-${t}`, t);
+ const el = a.firstElementChild || a;
+ const cs = window.getComputedStyle(el);
+ return { color: cs.color, background: cs.backgroundColor, border: cs.borderColor };
+ }, type);
+
+ const err = await colorFor('error');
+ const ok = await colorFor('success');
+ const warn = await colorFor('warning');
+ // Restore the container to its hidden/empty default so we don't leak a visible
+ // alert 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 (!err || !ok || !warn) {
+ return { passed: false, message: 'Could not render semantic alerts to compare colours' };
+ }
+
+ // Distinct if any of text / background / border colour differs.
+ const differ = (x, y) => x.color !== y.color || x.background !== y.background || x.border !== y.border;
+ const errVsOk = differ(err, ok);
+ const errVsWarn = differ(err, warn);
+ const okVsWarn = differ(ok, warn);
+ const passed = errVsOk && errVsWarn && okVsWarn;
return {
- passed: true,
- message: `Semantic colors: error=${result.errorCount}, success=${result.successCount}, warning=${result.warningCount}`
+ passed,
+ message: passed
+ ? `error/success/warning alerts all use distinct colours (bg error=${err.background}, success=${ok.background}, warning=${warn.background})`
+ : `Semantic colours not all distinct (error≠success=${errVsOk}, error≠warning=${errVsWarn}, success≠warning=${okVsWarn})`
};
}
};