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(ui-tests): make escapeKeyFunction test real app behavior (was failing with navigation error) (#4655)

LearningCircuitd6cd71924782
diff --git a/tests/ui_tests/test_keyboard_accessibility_ci.js b/tests/ui_tests/test_keyboard_accessibility_ci.js
index cb012db86f..72304c7cb0 100644
--- a/tests/ui_tests/test_keyboard_accessibility_ci.js
+++ b/tests/ui_tests/test_keyboard_accessibility_ci.js
@@ -63,53 +63,53 @@ const KeyboardNavigationTests = {
},
async escapeKeyFunction(page, baseUrl) {
+ // Assert Escape closes the open custom dropdown — the dropdown's input
+ // keydown handler hides the list on Escape. The old test used Bootstrap
+ // selectors (.dropdown-toggle / [data-toggle]) that don't exist on / in this
+ // app, so it never opened anything; depending on timing it either skipped or
+ // crashed with a navigation "Execution context was destroyed". We open the
+ // real #search_engine dropdown instead.
+ //
+ // research.js re-runs the dropdown setup after the search-engine fetch and
+ // each setup ends by hiding the dropdown, so wait for the network to settle
+ // before opening (same race guard as the mobile dropdown test). The opened
+ // list is reparented to <body>, so read it by id (#search-engine-dropdown-list).
await navigateTo(page, `${baseUrl}/`);
+ await page.waitForSelector('#search_engine', { timeout: 15000 });
+ await page.waitForNetworkIdle({ idleTime: 500, timeout: 15000 }).catch(() => {});
- // Open something that can be closed with Escape (like a dropdown or modal)
- await page.evaluate(() => {
- const dropdown = document.querySelector('.dropdown-toggle, [data-toggle="dropdown"]');
- if (dropdown) dropdown.click();
-
- const modal = document.querySelector('[data-toggle="modal"]');
- if (modal) modal.click();
- });
-
- await delay(300);
-
- const beforeEscape = await page.evaluate(() => {
- const openDropdown = document.querySelector('.dropdown.show, .dropdown-menu.show');
- const openModal = document.querySelector('.modal.show, .modal[style*="display: block"]');
- return {
- hasOpenDropdown: !!openDropdown,
- hasOpenModal: !!openModal
- };
- });
-
- // Press Escape
- await page.keyboard.press('Escape');
- await delay(300);
-
- const afterEscape = await page.evaluate(() => {
- const openDropdown = document.querySelector('.dropdown.show, .dropdown-menu.show');
- const openModal = document.querySelector('.modal.show, .modal[style*="display: block"]');
- return {
- hasOpenDropdown: !!openDropdown,
- hasOpenModal: !!openModal
- };
- });
+ const listOpen = () => {
+ const list = document.querySelector('#search-engine-dropdown-list');
+ return !!list && window.getComputedStyle(list).display === 'block'
+ && list.classList.contains('ldr-dropdown-active');
+ };
- if (!beforeEscape.hasOpenDropdown && !beforeEscape.hasOpenModal) {
- return { passed: null, skipped: true, message: 'No dropdown/modal to test Escape key' };
+ // Open the dropdown. #search_engine is the search-engine selector's <input>
+ // (a custom dropdown); its options load without an LLM, so it is CI-safe.
+ // Clicking the input both focuses it and opens the list.
+ await page.click('#search_engine');
+ await page.waitForFunction(listOpen, { timeout: 5000 }).catch(() => {});
+ const opened = await page.evaluate(listOpen);
+ if (!opened) {
+ return { passed: false, message: 'Could not open #search_engine dropdown to test Escape' };
}
- const closed = (beforeEscape.hasOpenDropdown && !afterEscape.hasOpenDropdown) ||
- (beforeEscape.hasOpenModal && !afterEscape.hasOpenModal);
+ // Press Escape and assert it closes. The click above focused the #search_engine
+ // <input>, and the Escape->hide handler is attached to that input's keydown
+ // listener, so the keypress reaches it (verified: this assertion passes locally).
+ await page.keyboard.press('Escape');
+ await page.waitForFunction(() => {
+ const list = document.querySelector('#search-engine-dropdown-list');
+ return !list || window.getComputedStyle(list).display === 'none'
+ || !list.classList.contains('ldr-dropdown-active');
+ }, { timeout: 5000 }).catch(() => {});
+ const stillOpen = await page.evaluate(listOpen);
return {
- passed: closed,
- message: closed
- ? 'Escape key closes open elements'
- : 'Escape key did not close open elements'
+ passed: !stillOpen,
+ message: !stillOpen
+ ? 'Escape closes the open custom dropdown'
+ : 'Escape did not close the open dropdown'
};
},