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 10 settings-interaction tests (dead-field audit PR 1) (#4589)

LearningCircuite0bd258c1ead
diff --git a/tests/ui_tests/test_settings_interactions_ci.js b/tests/ui_tests/test_settings_interactions_ci.js
index 9957da549d..bb2c387683 100644
--- a/tests/ui_tests/test_settings_interactions_ci.js
+++ b/tests/ui_tests/test_settings_interactions_ci.js
@@ -8,7 +8,7 @@
* Run: node test_settings_interactions_ci.js
*/
-const { setupTest, teardownTest, TestResults, log, delay, navigateTo, withTimeout } = require('./test_lib');
+const { setupTest, teardownTest, TestResults, log, navigateTo, withTimeout } = require('./test_lib');
// ============================================================================
// Settings Page Structure Tests
@@ -66,36 +66,49 @@ const SettingsPageTests = {
},
async settingsSearchFiltering(page, baseUrl) {
+ // #settings-search re-renders #settings-content with a filtered subset
+ // (settings.js::handleSearchInput filters allSettings by key/name/
+ // description/category) and restores the full active tab when cleared.
+ // The old test typed 'model', never asserted the count actually
+ // changed, and always returned passed:true.
await navigateTo(page, `${baseUrl}/settings`);
+ await page.waitForSelector('#settings-content .ldr-settings-item', { timeout: 15000 });
- // Wait for settings to load dynamically
- await delay(1000);
-
- const searchInput = await page.$('#settings-search, input[type="search"], input[placeholder*="search" i], input[placeholder*="filter" i]');
-
- if (!searchInput) {
- return { passed: null, skipped: true, message: 'No search input to test filtering' };
+ const count = () => page.$$eval('#settings-content .ldr-settings-item', els => els.length);
+ const initial = await count();
+ if (initial === 0) {
+ return { passed: false, message: 'No settings rendered to filter' };
}
- // Count initial settings
- const initialCount = await page.evaluate(() => {
- const settings = document.querySelectorAll('.ldr-settings-item, .setting, .setting-item, [class*="setting-row"]');
- return settings.length;
- });
-
- // Type search term
- await searchInput.type('model');
- await delay(300);
-
- const afterSearchCount = await page.evaluate(() => {
- const visibleSettings = Array.from(document.querySelectorAll('.ldr-settings-item, .setting, .setting-item, [class*="setting-row"]'))
- .filter(s => window.getComputedStyle(s).display !== 'none');
- return visibleSettings.length;
+ // A term matching nothing collapses the rendered list. The .catch
+ // tolerates the wait timing out — the count assertion below reports the
+ // actual diff, a clearer failure than a bare waitForFunction timeout.
+ await page.type('#settings-search', 'zzznomatchzzz');
+ await page.waitForFunction(
+ () => document.querySelectorAll('#settings-content .ldr-settings-item').length === 0,
+ { timeout: 5000 }
+ ).catch(() => {});
+ const filtered = await count();
+
+ // ...and clearing it restores the list. Set value + dispatch a real
+ // 'input' event (what handleSearchInput listens for) — more portable
+ // than triple-click + Backspace across headless targets.
+ await page.$eval('#settings-search', el => {
+ el.value = '';
+ el.dispatchEvent(new Event('input', { bubbles: true }));
});
+ await page.waitForFunction(
+ (n) => document.querySelectorAll('#settings-content .ldr-settings-item').length === n,
+ { timeout: 5000 }, initial
+ ).catch(() => {});
+ const restored = await count();
+ const passed = filtered < initial && restored === initial;
return {
- passed: true,
- message: `Search filters (initial: ${initialCount}, after filter: ${afterSearchCount})`
+ passed,
+ message: passed
+ ? `Search filters list (${initial} → ${filtered} on no-match → ${restored} restored)`
+ : `Filter contract failed (initial=${initial}, filtered=${filtered}, restored=${restored})`
};
}
};
@@ -135,92 +148,65 @@ const SettingsTabsTests = {
},
async tabNavigationWorks(page, baseUrl) {
+ // Tabs are .ldr-settings-tab[data-tab]; clicking one adds .active and
+ // re-renders #settings-content in place (settings.js:3930-3976) — there
+ // is no page navigation and no .tab-content/.tab-pane element, so the
+ // old probe matched nothing and the catch hardcoded passed:true.
await navigateTo(page, `${baseUrl}/settings`);
-
- // Gather tab info and before-content without clicking
- const preClick = await page.evaluate(() => {
- const tabs = document.querySelectorAll('.tab, .nav-tab, [role="tab"], .settings-tab, .nav-link');
- if (tabs.length < 2) return { hasTabs: false };
-
- const firstTabContent = document.querySelector('.tab-content, .tab-pane, [role="tabpanel"]');
- const beforeContent = firstTabContent?.textContent?.substring(0, 100);
- const tabText = tabs[1].textContent?.trim();
-
- return { hasTabs: true, beforeContent, tabText };
- });
-
- if (!preClick.hasTabs) {
- return { passed: null, skipped: true, message: 'Not enough tabs to test navigation' };
- }
-
- // Click the second tab; it may trigger a full page navigation or a JS content swap
- const tabSelector = '.tab, .nav-tab, [role="tab"], .settings-tab, .nav-link';
- let contentChanged;
- try {
- await Promise.all([
- page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: 10000 }),
- page.evaluate((sel) => {
- const tabs = document.querySelectorAll(sel);
- if (tabs[1]) tabs[1].click();
- }, tabSelector)
- ]);
-
- // Page may have navigated; wait for it to settle
- await delay(500);
-
- const afterContent = await page.evaluate(() => {
- const firstTabContent = document.querySelector('.tab-content, .tab-pane, [role="tabpanel"]');
- return firstTabContent?.textContent?.substring(0, 100) || '';
- });
-
- contentChanged = preClick.beforeContent !== afterContent;
- } catch (err) {
- if (err.message && (err.message.includes('context was destroyed') || err.message.includes('Navigation timeout'))) {
- // Context destroyed means navigation happened mid-flight.
- // Navigation timeout means the tab switched content via JS without a full navigation.
- // Both are acceptable — the tab click worked either way.
- try {
- await page.waitForSelector('body', { timeout: 5000 });
- } catch (e) {
- console.warn('waitForSelector("body") failed after tab click, page may still be usable:', e.message);
- }
- await delay(500);
- contentChanged = true;
- } else {
- throw err;
- }
+ await page.waitForSelector('#settings-content .ldr-settings-item', { timeout: 15000 });
+ await page.waitForSelector('.ldr-settings-tab[data-tab="llm"]', { timeout: 5000 });
+
+ // Precondition: the dashboard opens on the 'all' tab. Make it explicit
+ // so a changed default fails here with a clear message.
+ const start = await page.evaluate(() => ({
+ allActive: document.querySelector('.ldr-settings-tab[data-tab="all"]')?.classList.contains('active'),
+ itemCount: document.querySelectorAll('#settings-content .ldr-settings-item').length,
+ }));
+ if (start.allActive !== true) {
+ return { passed: false, message: `Expected 'all' tab active on load (allActive=${start.allActive})` };
}
+ // Switch to 'llm' — a strict subset of 'all', so the rendered item set
+ // must shrink (proves the content actually re-rendered, not just the
+ // tab class flipping).
+ await page.click('.ldr-settings-tab[data-tab="llm"]');
+ await page.waitForFunction(
+ () => document.querySelector('.ldr-settings-tab[data-tab="llm"]')?.classList.contains('active') === true,
+ { timeout: 5000 }
+ );
+
+ const state = await page.evaluate(() => ({
+ llmActive: document.querySelector('.ldr-settings-tab[data-tab="llm"]')?.classList.contains('active'),
+ allActive: document.querySelector('.ldr-settings-tab[data-tab="all"]')?.classList.contains('active'),
+ itemCount: document.querySelectorAll('#settings-content .ldr-settings-item').length,
+ }));
+
+ const reRendered = state.itemCount < start.itemCount;
+ const passed = state.llmActive === true && state.allActive === false && reRendered;
return {
- passed: true,
- message: `Tab navigation: clicked "${preClick.tabText}", content changed=${contentChanged}`
+ passed,
+ message: passed
+ ? `Tab switch works (llm active, all deactivated, items ${start.itemCount}→${state.itemCount})`
+ : `Tab switch failed (llmActive=${state.llmActive}, allActive=${state.allActive}, items ${start.itemCount}→${state.itemCount})`
};
},
async specificTabsPresent(page, baseUrl) {
+ // The dashboard renders a fixed set of category tabs as
+ // .ldr-settings-tab[data-tab] (settings_dashboard.html). Assert the
+ // real data-tab set rather than fuzzy-matching body text.
await navigateTo(page, `${baseUrl}/settings`);
+ await page.waitForSelector('.ldr-settings-tab[data-tab]', { timeout: 10000 });
- const result = await page.evaluate(() => {
- const pageText = document.body.textContent.toLowerCase();
- const tabs = Array.from(document.querySelectorAll('.tab, .nav-tab, [role="tab"], .settings-tab, .nav-link'))
- .map(t => t.textContent?.toLowerCase());
-
- const allText = pageText + tabs.join(' ');
-
- return {
- hasLanguageModels: allText.includes('language model') || allText.includes('llm') || allText.includes('model'),
- hasSearchEngines: allText.includes('search engine') || allText.includes('search'),
- hasReports: allText.includes('report'),
- hasApplication: allText.includes('application') || allText.includes('app'),
- hasNotifications: allText.includes('notification')
- };
- });
-
- const foundTabs = Object.entries(result).filter(([_k, v]) => v).map(([k]) => k.replace('has', ''));
+ const tabs = await page.$$eval('.ldr-settings-tab[data-tab]', els => els.map(e => e.getAttribute('data-tab')));
+ const expected = ['llm', 'search', 'report', 'app', 'notifications'];
+ const missing = expected.filter(t => !tabs.includes(t));
return {
- passed: foundTabs.length > 0,
- message: `Settings categories: ${foundTabs.join(', ')}`
+ passed: missing.length === 0,
+ message: missing.length === 0
+ ? `All expected category tabs present: ${tabs.join(', ')}`
+ : `Missing category tabs: ${missing.join(', ')} (present: ${tabs.join(', ')})`
};
}
};
@@ -230,202 +216,122 @@ const SettingsTabsTests = {
// ============================================================================
const SettingsControlsTests = {
async textInputSettings(page, baseUrl) {
+ // Real rendered text settings are input.ldr-settings-input[type=text]
+ // inside #settings-content (settings_form.html). The old selector list
+ // (.settings input etc.) matched nothing → permanent skip.
await navigateTo(page, `${baseUrl}/settings`);
- await delay(500);
+ await page.waitForSelector('#settings-content .ldr-settings-item', { timeout: 15000 });
const result = await page.evaluate(() => {
- // Broader search for text inputs on settings page
- const textInputs = document.querySelectorAll(
- '.settings input[type="text"], ' +
- '.setting input[type="text"], ' +
- 'input.setting-input, ' +
- 'form input[type="text"], ' +
- '.card input[type="text"], ' +
- '.form-group input[type="text"], ' +
- '[class*="setting"] input[type="text"]'
- );
-
- // Also check for any inputs that look like settings
- const allTextInputs = textInputs.length === 0
- ? document.querySelectorAll('input[type="text"]:not([type="search"]):not([hidden])')
- : textInputs;
-
- const firstInput = allTextInputs[0];
-
- // Check if we're on a settings page
- const isSettingsPage = window.location.href.includes('settings') ||
- !!document.querySelector('[class*="settings"], #settings');
-
- return {
- count: allTextInputs.length,
- hasInputs: allTextInputs.length > 0,
- firstInputName: firstInput?.name,
- firstInputValue: firstInput?.value?.substring(0, 30),
- isSettingsPage
- };
+ const inputs = document.querySelectorAll('#settings-content input.ldr-settings-input[type="text"][name]');
+ const first = inputs[0];
+ return { count: inputs.length, firstName: first?.name };
});
- if (!result.hasInputs) {
- if (result.isSettingsPage) {
- return { passed: null, skipped: true, message: 'Settings page found but no text inputs (may use other control types)' };
- }
- return { passed: null, skipped: true, message: 'No text inputs found on settings page' };
- }
-
return {
- passed: true,
- message: `Text inputs: ${result.count} found (first: "${result.firstInputName}")`
+ passed: result.count > 0,
+ message: result.count > 0
+ ? `Text settings inputs: ${result.count} (first: "${result.firstName}")`
+ : 'No .ldr-settings-input[type=text] rendered in #settings-content'
};
},
async numberInputSettings(page, baseUrl) {
await navigateTo(page, `${baseUrl}/settings`);
+ await page.waitForSelector('#settings-content .ldr-settings-item', { timeout: 15000 });
const result = await page.evaluate(() => {
- const numberInputs = document.querySelectorAll(
- '.ldr-settings-item input[type="number"], ' +
- '.settings input[type="number"], ' +
- '.setting input[type="number"], ' +
- 'input[type="number"][name]'
- );
-
- const firstInput = numberInputs[0];
-
+ const inputs = document.querySelectorAll('#settings-content input[type="number"][name]');
+ const first = inputs[0];
return {
- count: numberInputs.length,
- hasInputs: numberInputs.length > 0,
- firstInputName: firstInput?.name,
- min: firstInput?.min,
- max: firstInput?.max,
- value: firstInput?.value
+ count: inputs.length,
+ firstName: first?.name,
+ min: first?.min,
+ max: first?.max,
+ step: first?.step
};
});
- if (!result.hasInputs) {
- return { passed: null, skipped: true, message: 'No number inputs found' };
- }
-
return {
- passed: true,
- message: `Number inputs: ${result.count} found (first: "${result.firstInputName}", min=${result.min}, max=${result.max})`
+ passed: result.count > 0,
+ message: result.count > 0
+ ? `Number settings inputs: ${result.count} (first: "${result.firstName}", min=${result.min}, max=${result.max}, step=${result.step})`
+ : 'No number inputs rendered in #settings-content'
};
},
async toggleSwitchSettings(page, baseUrl) {
+ // Real setting checkboxes are input.ldr-settings-checkbox
+ // (settings_form.html), each paired with a .ldr-checkbox-hidden-fallback.
+ // The old broad selectors matched nothing → permanent skip.
await navigateTo(page, `${baseUrl}/settings`);
- await delay(500);
+ await page.waitForSelector('#settings-content .ldr-settings-item', { timeout: 15000 });
const result = await page.evaluate(() => {
- // Broader search for toggle/checkbox inputs
- const toggles = document.querySelectorAll(
- '.settings input[type="checkbox"], ' +
- '.setting input[type="checkbox"], ' +
- '.toggle-switch, ' +
- '.switch input, ' +
- 'form input[type="checkbox"], ' +
- '.card input[type="checkbox"], ' +
- '[class*="toggle"], ' +
- '[class*="switch"] input'
- );
-
- // Fallback to any checkboxes
- const allToggles = toggles.length === 0
- ? document.querySelectorAll('input[type="checkbox"]:not([hidden])')
- : toggles;
-
- const firstToggle = allToggles[0];
-
- // Check if we're on a settings page
- const isSettingsPage = window.location.href.includes('settings') ||
- !!document.querySelector('[class*="settings"], #settings');
-
- return {
- count: allToggles.length,
- hasToggles: allToggles.length > 0,
- firstToggleName: firstToggle?.name,
- firstToggleChecked: firstToggle?.checked,
- isSettingsPage
- };
+ const boxes = document.querySelectorAll('#settings-content input.ldr-settings-checkbox[name]');
+ const first = boxes[0];
+ return { count: boxes.length, firstName: first?.name, checked: first?.checked };
});
- if (!result.hasToggles) {
- if (result.isSettingsPage) {
- return { passed: null, skipped: true, message: 'Settings page found but no toggles (may use other control types)' };
- }
- return { passed: null, skipped: true, message: 'No toggle switches found on settings page' };
- }
-
return {
- passed: true,
- message: `Toggles: ${result.count} found (first: "${result.firstToggleName}", checked=${result.firstToggleChecked})`
+ passed: result.count > 0,
+ message: result.count > 0
+ ? `Setting checkboxes: ${result.count} (first: "${result.firstName}", checked=${result.checked})`
+ : 'No .ldr-settings-checkbox rendered in #settings-content'
};
},
async dropdownSelectSettings(page, baseUrl) {
+ // Dropdown settings render either as a plain <select.ldr-settings-select>
+ // or — for llm.provider / llm.model / search.tool — as a custom
+ // .ldr-custom-dropdown widget (components/custom_dropdown.html). The
+ // default config only has the custom kind (no plain <select>), so the
+ // contract is "at least one dropdown control exists".
await navigateTo(page, `${baseUrl}/settings`);
+ await page.waitForSelector('#settings-content .ldr-settings-item', { timeout: 15000 });
const result = await page.evaluate(() => {
- const selects = document.querySelectorAll(
- '.ldr-settings-item select, ' +
- '.settings select, ' +
- '.setting select, ' +
- 'select[name]'
- );
-
- const firstSelect = selects[0];
- const options = firstSelect ? Array.from(firstSelect.options).slice(0, 5).map(o => o.text) : [];
-
+ const selects = document.querySelectorAll('#settings-content select.ldr-settings-select[name]');
+ const customs = document.querySelectorAll('#settings-content .ldr-custom-dropdown');
+ const first = selects[0];
return {
- count: selects.length,
- hasSelects: selects.length > 0,
- firstName: firstSelect?.name,
- options
+ selectCount: selects.length,
+ customCount: customs.length,
+ firstName: first?.name,
+ optionCount: first ? first.options.length : 0,
};
});
- if (!result.hasSelects) {
- return { passed: null, skipped: true, message: 'No dropdown selects found' };
- }
-
+ const total = result.selectCount + result.customCount;
+ // A plain <select>, if present, must have options; custom dropdowns
+ // populate their list lazily, so only their presence is asserted.
+ const selectsOk = result.selectCount === 0 || result.optionCount > 0;
return {
- passed: true,
- message: `Dropdowns: ${result.count} found (first: "${result.firstName}", options: ${result.options.join(', ')})`
+ passed: total > 0 && selectsOk,
+ message: total > 0
+ ? `Dropdown settings: ${result.selectCount} <select>${result.firstName ? ` ("${result.firstName}", ${result.optionCount} opts)` : ''} + ${result.customCount} custom-dropdown`
+ : 'No dropdown controls (.ldr-settings-select / .ldr-custom-dropdown) rendered in #settings-content'
};
},
async toggleSwitchToggleable(page, baseUrl) {
+ // Click a real, enabled setting checkbox and assert its checked state
+ // flips. Uses page.click (a real user gesture) on the confirmed
+ // .ldr-settings-checkbox selector.
await navigateTo(page, `${baseUrl}/settings`);
+ const sel = '#settings-content input.ldr-settings-checkbox[name]:not([disabled])';
+ await page.waitForSelector(sel, { timeout: 15000 });
- const result = await page.evaluate(() => {
- const toggle = document.querySelector(
- '.ldr-settings-item input[type="checkbox"], ' +
- '.settings input[type="checkbox"], ' +
- '.toggle-switch input, ' +
- '.switch input, ' +
- 'input[type="checkbox"][name]'
- );
-
- if (!toggle) return { hasToggle: false };
-
- const beforeState = toggle.checked;
- toggle.click();
- const afterState = toggle.checked;
-
- return {
- hasToggle: true,
- beforeState,
- afterState,
- toggled: beforeState !== afterState
- };
- });
-
- if (!result.hasToggle) {
- return { passed: null, skipped: true, message: 'No toggle to test' };
- }
+ const before = await page.$eval(sel, el => el.checked);
+ await page.click(sel);
+ const after = await page.$eval(sel, el => el.checked);
+ const toggled = before !== after;
return {
- passed: result.toggled,
- message: `Toggle works: before=${result.beforeState}, after=${result.afterState}`
+ passed: toggled,
+ message: toggled
+ ? `Checkbox toggles (before=${before}, after=${after})`
+ : `Checkbox did not flip (before=${before}, after=${after})`
};
}
};
@@ -497,42 +403,31 @@ const SettingsSaveTests = {
},
async autoSaveFunctionality(page, baseUrl) {
+ // Settings auto-save on change: handleInputChange schedules a save and,
+ // on success, showSaveSuccess() adds .ldr-save-success to the changed
+ // input (settings.js:2651). The old selector '.settings input' matched
+ // nothing (permanent skip) and it looked for a .toast that isn't used.
await navigateTo(page, `${baseUrl}/settings`);
+ const sel = '#settings-content input.ldr-settings-checkbox[name]:not([disabled])';
+ await page.waitForSelector(sel, { timeout: 15000 });
- // Find a toggle and change it
- const result = await page.evaluate(() => {
- const toggle = document.querySelector('.settings input[type="checkbox"]');
- if (!toggle) return { hasToggle: false };
-
- toggle.click();
-
- // Wait a bit and check for toast/notification
- return new Promise(resolve => {
- setTimeout(() => {
- const toast = document.querySelector('.toast, .notification, .alert-success, [class*="toast"]');
- const savedIndicator = document.querySelector('.saved, .success, [class*="saved"]');
-
- resolve({
- hasToggle: true,
- hasToast: !!toast,
- hasSavedIndicator: !!savedIndicator,
- toastText: toast?.textContent?.trim()?.substring(0, 50)
- });
- }, 500);
- });
- });
-
- if (!result.hasToggle) {
- return { passed: null, skipped: true, message: 'No toggle to test auto-save' };
- }
+ await page.click(sel);
- const hasAutoSave = result.hasToast || result.hasSavedIndicator;
+ // Wait for the save round-trip to flag success on the input.
+ let sawSuccess = false;
+ try {
+ await page.waitForFunction(
+ () => !!document.querySelector('.ldr-save-success'),
+ { timeout: 8000 }
+ );
+ sawSuccess = true;
+ } catch { /* timeout — no save feedback appeared */ }
return {
- passed: hasAutoSave,
- message: hasAutoSave
- ? `Auto-save: toast="${result.toastText}", indicator=${result.hasSavedIndicator}`
- : 'No auto-save feedback detected'
+ passed: sawSuccess,
+ message: sawSuccess
+ ? 'Auto-save fired (.ldr-save-success applied after changing a setting)'
+ : 'No .ldr-save-success feedback within 8s of changing a setting'
};
}
};
@@ -542,49 +437,23 @@ const SettingsSaveTests = {
// ============================================================================
const SettingsHelpTests = {
async settingDescriptions(page, baseUrl) {
+ // Real per-setting help text is .ldr-input-help (settings_form.html).
+ // The old probe [class*=description] only matched static page-header
+ // divs (tautological).
await navigateTo(page, `${baseUrl}/settings`);
- await delay(500);
+ await page.waitForSelector('#settings-content .ldr-settings-item', { timeout: 15000 });
const result = await page.evaluate(() => {
- // Broader search for descriptions and help text
- const descriptions = document.querySelectorAll(
- '.setting-description, ' +
- '.help-text, ' +
- '.setting-help, ' +
- 'small.text-muted, ' +
- '.form-text, ' +
- '.description, ' +
- '[class*="description"], ' +
- '[class*="help-text"], ' +
- 'label + small, ' +
- '.card-text, ' +
- 'p.text-muted'
- );
-
- const firstDesc = descriptions[0];
-
- // Check if we're on a settings page
- const isSettingsPage = window.location.href.includes('settings') ||
- !!document.querySelector('[class*="settings"], #settings');
-
- return {
- count: descriptions.length,
- hasDescriptions: descriptions.length > 0,
- firstText: firstDesc?.textContent?.trim()?.substring(0, 100),
- isSettingsPage
- };
+ const helps = Array.from(document.querySelectorAll('#settings-content .ldr-input-help'))
+ .filter(el => el.textContent.trim().length > 0);
+ return { count: helps.length, firstText: helps[0]?.textContent.trim().slice(0, 80) };
});
- if (!result.hasDescriptions) {
- if (result.isSettingsPage) {
- return { passed: null, skipped: true, message: 'Settings page found but no descriptions (may use inline labels)' };
- }
- return { passed: null, skipped: true, message: 'No setting descriptions found' };
- }
-
return {
- passed: true,
- message: `Setting descriptions: ${result.count} found (first: "${result.firstText}...")`
+ passed: result.count > 0,
+ message: result.count > 0
+ ? `Setting help text: ${result.count} non-empty .ldr-input-help (first: "${result.firstText}")`
+ : 'No non-empty .ldr-input-help rendered in #settings-content'
};
},