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 assertions for mobile dropdown-open + delete modal (dead-field audit PR 5) (#4639)

LearningCircuitbdffee4a1c5f
diff --git a/tests/ui_tests/mobile/test_ui_functionality_ci.js b/tests/ui_tests/mobile/test_ui_functionality_ci.js
index 592f26dd08..61cfc186a2 100644
--- a/tests/ui_tests/mobile/test_ui_functionality_ci.js
+++ b/tests/ui_tests/mobile/test_ui_functionality_ci.js
@@ -170,82 +170,54 @@ const DropdownTests = {
},
async dropdownOpensOnClick(page, baseUrl) {
+ // Clicking a custom-dropdown input runs custom_dropdown.js::showDropdown,
+ // which sets the list to display:block, adds .ldr-dropdown-active, AND
+ // reparents the list to document.body. We target the search-engine
+ // dropdown specifically (#search_engine): its options come from
+ // /settings/api/available-search-engines (no LLM), unlike the model
+ // dropdown which is empty without a configured provider. Because the list
+ // is moved to <body>, read it by id (#search-engine-dropdown-list), not as
+ // a descendant of .ldr-custom-dropdown. The old test had OR/skip fallbacks
+ // that passed even when the dropdown never opened.
await navigateTo(page, `${baseUrl}/`);
+ await page.waitForSelector('#search_engine', { timeout: 15000 });
+
+ // research.js sets up #search_engine TWICE: synchronously on load and again
+ // inside Promise.all([...loadSearchEngineOptions]).then() once the fetch
+ // resolves (research.js:329-344). Every setupCustomDropdown() ends with
+ // hideDropdown() (custom_dropdown.js:629), so a click before that async
+ // re-setup gets force-closed. navigateTo only waits for domcontentloaded,
+ // so wait for the network to settle (the home page has no SSE/polling) to
+ // guarantee the final setup has run before we open the dropdown.
+ await page.waitForNetworkIdle({ idleTime: 500, timeout: 15000 }).catch(() => {});
+
+ await page.click('#search_engine');
+ await page.waitForFunction(() => {
+ const list = document.querySelector('#search-engine-dropdown-list');
+ return list && window.getComputedStyle(list).display === 'block'
+ && list.classList.contains('ldr-dropdown-active');
+ }, { timeout: 5000 }).catch(() => {});
- const dropdownExists = await page.$('.ldr-custom-dropdown');
- if (!dropdownExists) {
- return { passed: null, skipped: true, message: 'No dropdown on this page' };
- }
-
- const input = await page.$('.ldr-custom-dropdown input:not([type="hidden"])');
- if (!input) {
- return { passed: false, message: 'Dropdown input element not found' };
- }
-
- // Click the input
- await input.click();
-
- // Wait a bit for any animations
- await new Promise(r => setTimeout(r, 500));
-
- // Check if dropdown is visible using multiple methods
const result = await page.evaluate(() => {
- const dropdown = document.querySelector('.ldr-custom-dropdown');
- if (!dropdown) return { exists: false };
-
- const list = dropdown.querySelector('.ldr-custom-dropdown-list, [class*="dropdown-list"]');
- if (!list) return { exists: true, hasListElement: false };
-
- const style = window.getComputedStyle(list);
- const isVisible = style.display !== 'none' &&
- style.visibility !== 'hidden' &&
- style.opacity !== '0';
-
- // Also check if dropdown has 'open' or 'active' class
- const hasOpenClass = dropdown.classList.contains('open') ||
- dropdown.classList.contains('active') ||
- dropdown.classList.contains('show') ||
- list.classList.contains('show') ||
- list.classList.contains('open');
-
- // Check if list has items
- const hasItems = list.querySelectorAll('li, .dropdown-item').length > 0;
-
+ const list = document.querySelector('#search-engine-dropdown-list');
+ if (!list) return { hasList: false };
return {
- exists: true,
- hasListElement: true,
- isVisible,
- hasOpenClass,
- hasItems
+ hasList: true,
+ display: window.getComputedStyle(list).display,
+ active: list.classList.contains('ldr-dropdown-active'),
+ itemCount: list.querySelectorAll('.ldr-custom-dropdown-item, [role="option"], li').length,
};
});
- if (!result.exists) {
- return { passed: null, skipped: true, message: 'Dropdown element not found' };
- }
-
- if (!result.hasListElement) {
- return { passed: null, skipped: true, message: 'Dropdown list element not found' };
- }
-
- // Pass if visible OR has open class OR has items (dropdown structure is valid)
- const passed = result.isVisible || result.hasOpenClass || result.hasItems;
-
- // If dropdown has the structure but visibility test fails, skip instead of fail
- // The dropdownStructure and dropdownSelection tests already verify functionality
- if (!passed && result.hasListElement) {
- return {
- passed: null,
- skipped: true,
- message: 'Dropdown visibility check inconclusive (may use different open mechanism)'
- };
+ if (!result.hasList) {
+ return { passed: false, message: '#search-engine-dropdown-list not found on /' };
}
-
+ const passed = result.display === 'block' && result.active;
return {
passed,
message: passed
- ? 'Dropdown interaction working'
- : 'Dropdown did not become visible after click'
+ ? `Search-engine dropdown opens on click (display=${result.display}, active=${result.active}, items=${result.itemCount})`
+ : `Dropdown did not open on click (display=${result.display}, active=${result.active})`
};
},
@@ -286,73 +258,77 @@ const DropdownTests = {
// ============================================================================
const ModalTests = {
async deleteModalStructure(page, baseUrl) {
- await navigateTo(page, `${baseUrl}/history/`);
+ // #deleteConfirmModal is a static include in library.html (line 1140 →
+ // components/delete_confirmation_modal.html), present-but-hidden. The old
+ // test navigated to /history/ where it doesn't exist (→ permanent skip).
+ // Assert the real modal structure on /library/.
+ await navigateTo(page, `${baseUrl}/library/`);
+ await page.waitForSelector('#deleteConfirmModal', { timeout: 15000 });
const result = await page.evaluate(() => {
- const modal = document.querySelector('#deleteConfirmModal, .delete-modal, [class*="confirm-modal"]');
+ const modal = document.querySelector('#deleteConfirmModal');
if (!modal) return { exists: false };
-
- const confirmBtn = modal.querySelector('.btn-danger, button[class*="delete"], button[class*="confirm"]');
- const cancelBtn = modal.querySelector('.btn-secondary, button[class*="cancel"]');
- const style = window.getComputedStyle(modal);
-
return {
exists: true,
- hasConfirmBtn: !!confirmBtn,
- hasCancelBtn: !!cancelBtn,
- zIndex: style.zIndex
+ hasTitle: !!modal.querySelector('#deleteConfirmModalLabel'),
+ hasConfirm: !!modal.querySelector('#deleteConfirmBtn'),
+ hasCancel: !!modal.querySelector('.btn-secondary[data-bs-dismiss="modal"]'),
};
});
if (!result.exists) {
- return { passed: null, skipped: true, message: 'No delete modal on this page' };
+ return { passed: false, message: '#deleteConfirmModal not found on /library/' };
}
-
- const hasRequiredParts = result.hasConfirmBtn && result.hasCancelBtn;
+ const passed = result.hasTitle && result.hasConfirm && result.hasCancel;
return {
- passed: hasRequiredParts,
- message: hasRequiredParts
- ? `Delete modal structure valid (z-index: ${result.zIndex})`
- : `Modal missing buttons: confirm=${result.hasConfirmBtn}, cancel=${result.hasCancelBtn}`
+ passed,
+ message: passed
+ ? 'Delete modal has title + confirm (#deleteConfirmBtn) + cancel (data-bs-dismiss) buttons'
+ : `Delete modal incomplete (title=${result.hasTitle}, confirm=${result.hasConfirm}, cancel=${result.hasCancel})`
};
},
async modalZIndex(page, baseUrl) {
- await navigateTo(page, `${baseUrl}/history/`);
+ // #deleteConfirmModal carries an inline z-index: 10000
+ // (components/delete_confirmation_modal.html), included in library.html.
+ // The old test navigated to /history/ (modal absent → skip). Assert the
+ // z-index on /library/ so the modal sits above the app chrome. We check
+ // BOTH an absolute floor and a relative comparison: the mobile bottom nav
+ // is z-index 1500 (mobile-responsive.css), already above a bare 1000 floor,
+ // so the relative check (modal > sidebar AND modal > nav) is what actually
+ // guarantees the modal overlays the chrome. getComputedStyle is only called
+ // on elements that exist (getComputedStyle(null) throws); absent chrome → 0.
+ await navigateTo(page, `${baseUrl}/library/`);
+ await page.waitForSelector('#deleteConfirmModal', { timeout: 15000 });
const result = await page.evaluate(() => {
- const modal = document.querySelector('#deleteConfirmModal, .delete-modal, [class*="modal"]');
+ const modal = document.querySelector('#deleteConfirmModal');
if (!modal) return { exists: false };
-
- const style = window.getComputedStyle(modal);
- const zIndex = parseInt(style.zIndex, 10) || 0;
-
- const sidebar = document.querySelector('.ldr-sidebar');
- const mobileNav = document.querySelector('.ldr-mobile-bottom-nav');
-
- const sidebarZ = sidebar ? parseInt(window.getComputedStyle(sidebar).zIndex, 10) || 0 : 0;
- const navZ = mobileNav ? parseInt(window.getComputedStyle(mobileNav).zIndex, 10) || 0 : 0;
-
+ const zOf = (sel) => {
+ const el = document.querySelector(sel);
+ if (!el) return 0;
+ const z = parseInt(window.getComputedStyle(el).zIndex, 10);
+ return Number.isFinite(z) ? z : 0;
+ };
+ const z = parseInt(window.getComputedStyle(modal).zIndex, 10);
return {
exists: true,
- modalZIndex: zIndex,
- sidebarZIndex: sidebarZ,
- navZIndex: navZ,
- isHighest: zIndex > sidebarZ && zIndex > navZ
+ zIndex: Number.isFinite(z) ? z : 0,
+ sidebarZ: zOf('.ldr-sidebar'),
+ navZ: zOf('.ldr-mobile-bottom-nav'),
};
});
if (!result.exists) {
- return { passed: null, skipped: true, message: 'No modal on this page' };
+ return { passed: false, message: '#deleteConfirmModal not found on /library/' };
}
-
- // Modal should have higher z-index than other UI elements
- const isAppropriate = result.modalZIndex >= 1000 || result.isHighest;
+ const aboveChrome = result.zIndex > result.sidebarZ && result.zIndex > result.navZ;
+ const passed = result.zIndex >= 1000 && aboveChrome;
return {
- passed: isAppropriate,
- message: isAppropriate
- ? `Modal z-index (${result.modalZIndex}) is appropriate`
- : `Modal z-index (${result.modalZIndex}) may be too low (sidebar: ${result.sidebarZIndex}, nav: ${result.navZIndex})`
+ passed,
+ message: passed
+ ? `Delete modal z-index ${result.zIndex} >= 1000 and above chrome (sidebar=${result.sidebarZ}, nav=${result.navZ})`
+ : `Delete modal z-index ${result.zIndex} fails (>=1000 && >sidebar(${result.sidebarZ}) && >nav(${result.navZ}))`
};
}
};