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.

chore(lint): enable no-else-return + no-lonely-if (#3643)

LearningCircuit5564585a73a8
diff --git a/eslint.config.js b/eslint.config.js
index 47c5ae9bb3..c7e46abd95 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -223,6 +223,10 @@ export default [
// Always pass radix to parseInt — explicit base avoids surprise
"radix": "error",
+
+ // Readability: drop pointless `else` after `return`, fold `else { if }` into `else if`
+ "no-else-return": "error",
+ "no-lonely-if": "error",
},
languageOptions: {
diff --git a/src/local_deep_research/web/static/js/components/custom_dropdown.js b/src/local_deep_research/web/static/js/components/custom_dropdown.js
index c061281dd3..efde7590b2 100644
--- a/src/local_deep_research/web/static/js/components/custom_dropdown.js
+++ b/src/local_deep_research/web/static/js/components/custom_dropdown.js
@@ -660,11 +660,9 @@
} else {
onSelect(value, { value, label: value });
}
- } else {
+ } else if (hiddenInput) {
// Even if we don't trigger events, we should update the hidden field
- if (hiddenInput) {
- hiddenInput.value = value;
- }
+ hiddenInput.value = value;
}
}
};
diff --git a/src/local_deep_research/web/static/js/components/details.js b/src/local_deep_research/web/static/js/components/details.js
index efe76b3aa3..4571b9663f 100644
--- a/src/local_deep_research/web/static/js/components/details.js
+++ b/src/local_deep_research/web/static/js/components/details.js
@@ -133,12 +133,10 @@
} else {
domainList.textContent = 'Domain data unavailable (security module not loaded)';
}
+ } else if (window.safeSetInnerHTML) {
+ window.safeSetInnerHTML(domainList, '<div style="text-align: center; color: var(--text-secondary); padding: 1rem;">No domain data available</div>', true);
} else {
- if (window.safeSetInnerHTML) {
- window.safeSetInnerHTML(domainList, '<div style="text-align: center; color: var(--text-secondary); padding: 1rem;">No domain data available</div>', true);
- } else {
- domainList.textContent = 'No domain data available';
- }
+ domainList.textContent = 'No domain data available';
}
// Display resource samples
@@ -167,12 +165,10 @@
// eslint-disable-next-line no-unsanitized/property -- audited 2026-03-28: all interpolations use escapeHtml/esc, numeric coercion, or hardcoded strings
resourceSample.innerHTML = resourceHtml; // Fields already escaped above
}
+ } else if (window.safeSetInnerHTML) {
+ window.safeSetInnerHTML(resourceSample, '<div style="text-align: center; color: var(--text-secondary); padding: 1rem;">No resource samples available</div>', true);
} else {
- if (window.safeSetInnerHTML) {
- window.safeSetInnerHTML(resourceSample, '<div style="text-align: center; color: var(--text-secondary); padding: 1rem;">No resource samples available</div>', true);
- } else {
- resourceSample.textContent = 'No resource samples available';
- }
+ resourceSample.textContent = 'No resource samples available';
}
// Create generic source type pie chart
diff --git a/src/local_deep_research/web/static/js/components/fallback/formatting.js b/src/local_deep_research/web/static/js/components/fallback/formatting.js
index 8ca9a0dd9d..dc59eccaff 100644
--- a/src/local_deep_research/web/static/js/components/fallback/formatting.js
+++ b/src/local_deep_research/web/static/js/components/fallback/formatting.js
@@ -75,9 +75,8 @@
if (minutes === 0) {
return `${remainingSeconds}s`;
- } else {
- return `${minutes}m ${remainingSeconds}s`;
}
+ return `${minutes}m ${remainingSeconds}s`;
}
/**
diff --git a/src/local_deep_research/web/static/js/components/history.js b/src/local_deep_research/web/static/js/components/history.js
index 11ab38acbc..97a28de1e2 100644
--- a/src/local_deep_research/web/static/js/components/history.js
+++ b/src/local_deep_research/web/static/js/components/history.js
@@ -250,13 +250,11 @@
handleSubscribe(itemData);
} else if (e.target.closest('.ldr-rerun-btn')) {
handleRerun(itemData);
- } else {
+ } else if (ResearchStates.isCompleted(itemData.status)) {
// Item-level click (navigate to results/progress)
- if (ResearchStates.isCompleted(itemData.status)) {
- URLValidator.safeAssign(window.location, 'href', URLBuilder.resultsPage(itemId));
- } else {
- URLValidator.safeAssign(window.location, 'href', URLBuilder.progressPage(itemId));
- }
+ URLValidator.safeAssign(window.location, 'href', URLBuilder.resultsPage(itemId));
+ } else {
+ URLValidator.safeAssign(window.location, 'href', URLBuilder.progressPage(itemId));
}
});
}
diff --git a/src/local_deep_research/web/static/js/components/logpanel.js b/src/local_deep_research/web/static/js/components/logpanel.js
index b7b676d50f..62442eeb97 100644
--- a/src/local_deep_research/web/static/js/components/logpanel.js
+++ b/src/local_deep_research/web/static/js/components/logpanel.js
@@ -126,13 +126,12 @@
logPanelContent.style.display = 'none';
}
return;
- } else {
- // Ensure log panel is visible on research pages
- SafeLogger.log('On a research page, ensuring log panel is shown');
- const panel = logPanelContent.closest('.ldr-collapsible-log-panel');
- if (panel) {
- panel.style.display = 'flex';
- }
+ }
+ // Ensure log panel is visible on research pages
+ SafeLogger.log('On a research page, ensuring log panel is shown');
+ const panel = logPanelContent.closest('.ldr-collapsible-log-panel');
+ if (panel) {
+ panel.style.display = 'flex';
}
SafeLogger.log('Log panel elements found, setting up handlers');
diff --git a/src/local_deep_research/web/static/js/components/progress.js b/src/local_deep_research/web/static/js/components/progress.js
index 939e2ecc7a..5ce900c0d0 100644
--- a/src/local_deep_research/web/static/js/components/progress.js
+++ b/src/local_deep_research/web/static/js/components/progress.js
@@ -638,13 +638,11 @@
URLValidator.safeAssign(viewResultsButton, 'href', URLBuilder.resultsPage(currentResearchId));
viewResultsButton.style.display = 'inline-block';
}
- } else {
+ } else if (viewResultsButton) {
// For cancelled research, go back to home
- if (viewResultsButton) {
- viewResultsButton.textContent = 'Start New Research';
- URLValidator.safeAssign(viewResultsButton, 'href', '/');
- viewResultsButton.style.display = 'inline-block';
- }
+ viewResultsButton.textContent = 'Start New Research';
+ URLValidator.safeAssign(viewResultsButton, 'href', '/');
+ viewResultsButton.style.display = 'inline-block';
}
// Hide cancel button
diff --git a/src/local_deep_research/web/static/js/components/research.js b/src/local_deep_research/web/static/js/components/research.js
index d241db2ef5..1d2bf2fe63 100644
--- a/src/local_deep_research/web/static/js/components/research.js
+++ b/src/local_deep_research/web/static/js/components/research.js
@@ -1302,13 +1302,13 @@
return {
success: true
};
- } else {
- return {
+ }
+ return {
success: false,
error: data.message || "The selected model is not available in Ollama.",
solution: "Please pull the model first using 'ollama pull " + model + "' or select a different model."
};
- }
+
} catch (error) {
SafeLogger.error("Error checking Ollama model:", error);
return {
diff --git a/src/local_deep_research/web/static/js/components/settings.js b/src/local_deep_research/web/static/js/components/settings.js
index b28855b1c6..d81d8a2145 100644
--- a/src/local_deep_research/web/static/js/components/settings.js
+++ b/src/local_deep_research/web/static/js/components/settings.js
@@ -481,12 +481,10 @@
input.blur();
}
}
- } else {
+ } else if (eventType === 'blur') {
// If blur event and no changes, remove modified indicator maybe?
- if (eventType === 'blur') {
- const item = input.closest('.ldr-settings-item');
- if (item) item.classList.remove('ldr-settings-modified');
- }
+ const item = input.closest('.ldr-settings-item');
+ if (item) item.classList.remove('ldr-settings-modified');
}
// --- MODIFICATION END ---
}
@@ -2389,18 +2387,15 @@
jsonData[propName] = control.checked;
} else if (control.tagName === 'SELECT') {
jsonData[propName] = control.value;
- } else {
- // Attempt to convert to number if appropriate
- if (!isNaN(control.value) && control.value !== '') {
- // Check if it should be a float or int
- if (control.value.includes('.')) {
- jsonData[propName] = parseFloat(control.value);
- } else {
- jsonData[propName] = parseInt(control.value, 10);
- }
+ } else if (!isNaN(control.value) && control.value !== '') {
+ // Attempt to convert to number — float if it has a dot, else int
+ if (control.value.includes('.')) {
+ jsonData[propName] = parseFloat(control.value);
} else {
- jsonData[propName] = control.value;
+ jsonData[propName] = parseInt(control.value, 10);
}
+ } else {
+ jsonData[propName] = control.value;
}
}
});
@@ -2600,22 +2595,20 @@
allSettings = processSettings(data.settings);
}
}
- } else {
+ } else if (savingKeys.length === 1) {
// Update just the changed setting in our allSettings array
- if (savingKeys.length === 1) {
- const key = savingKeys[0];
- const settingIndex = allSettings.findIndex(s => s.key === key);
+ const key = savingKeys[0];
+ const settingIndex = allSettings.findIndex(s => s.key === key);
- if (settingIndex !== -1 && data.settings) {
- // Find the updated setting in the response
- const updatedSetting = data.settings[key];
+ if (settingIndex !== -1 && data.settings) {
+ // Find the updated setting in the response
+ const updatedSetting = data.settings[key];
- if (updatedSetting) {
- // Update the setting in our array
- const settingMap = {};
- settingMap[key] = updatedSetting;
- allSettings[settingIndex] = processSettings(settingMap)[0];
- }
+ if (updatedSetting) {
+ // Update the setting in our array
+ const settingMap = {};
+ settingMap[key] = updatedSetting;
+ allSettings[settingIndex] = processSettings(settingMap)[0];
}
}
}
@@ -4078,9 +4071,7 @@
showAlert('Failed to refresh models: ' + error.message, 'error');
}
});
- } else {
- if (icon) icon.className = 'fas fa-sync-alt';
- }
+ } else if (icon) icon.className = 'fas fa-sync-alt';
});
}
} else if (settingKey === 'llm.provider') {
@@ -4328,18 +4319,15 @@
if (isValid) {
SafeLogger.log(`Setting model value to currently selected: ${currentModel}`);
modelDropdownControl.setValue(currentModel, false);
- } else {
+ } else if (filteredModels.length > 0) {
// Select first available model
- // *** FIX: Check if filteredModels has elements ***
- if (filteredModels.length > 0) {
- const firstModel = filteredModels[0].value;
- SafeLogger.log(`Current model ${currentModel} invalid for provider ${providerUpper}. Setting to first available: ${firstModel}`);
- modelDropdownControl.setValue(firstModel, false); // DON'T fire event, avoid loop
- } else {
- // No models available, clear the input
- SafeLogger.log(`No models found for provider ${providerUpper}. Clearing model selection.`);
- modelDropdownControl.setValue("", false);
- }
+ const firstModel = filteredModels[0].value;
+ SafeLogger.log(`Current model ${currentModel} invalid for provider ${providerUpper}. Setting to first available: ${firstModel}`);
+ modelDropdownControl.setValue(firstModel, false); // DON'T fire event, avoid loop
+ } else {
+ // No models available, clear the input
+ SafeLogger.log(`No models found for provider ${providerUpper}. Clearing model selection.`);
+ modelDropdownControl.setValue("", false);
}
}
diff --git a/src/local_deep_research/web/static/js/embedding_settings.js b/src/local_deep_research/web/static/js/embedding_settings.js
index a2b3794d91..168ad40264 100644
--- a/src/local_deep_research/web/static/js/embedding_settings.js
+++ b/src/local_deep_research/web/static/js/embedding_settings.js
@@ -233,9 +233,8 @@ function formatValueForDisplay(value) {
return JSON.stringify(value);
} else if (typeof value === 'string' && value.length > 30) {
return value.substring(0, 28) + '...';
- } else {
- return String(value);
}
+ return String(value);
}
/**
diff --git a/src/local_deep_research/web/static/js/mobile-navigation.js b/src/local_deep_research/web/static/js/mobile-navigation.js
index 794ef6e24a..245027e94b 100644
--- a/src/local_deep_research/web/static/js/mobile-navigation.js
+++ b/src/local_deep_research/web/static/js/mobile-navigation.js
@@ -485,12 +485,10 @@
e.preventDefault();
lastFocusable.focus();
}
- } else {
+ } else if (document.activeElement === lastFocusable) {
// Tab: if on last element, wrap to first
- if (document.activeElement === lastFocusable) {
- e.preventDefault();
- firstFocusable.focus();
- }
+ e.preventDefault();
+ firstFocusable.focus();
}
};
diff --git a/src/local_deep_research/web/static/js/security/xss-protection.js b/src/local_deep_research/web/static/js/security/xss-protection.js
index 0f0e105578..f4a3dfa57d 100644
--- a/src/local_deep_research/web/static/js/security/xss-protection.js
+++ b/src/local_deep_research/web/static/js/security/xss-protection.js
@@ -278,11 +278,10 @@ function sanitizeHtml(dirty, config = {}) {
if (hasDOMPurify()) {
const finalConfig = { ...SANITIZE_CONFIG, ...config };
return DOMPurify.sanitize(String(dirty), finalConfig);
- } else {
- // Fallback: escape all HTML if DOMPurify is not available
- SafeLogger.warn('DOMPurify not available, falling back to HTML escaping');
- return escapeHtml(String(dirty));
}
+ // Fallback: escape all HTML if DOMPurify is not available
+ SafeLogger.warn('DOMPurify not available, falling back to HTML escaping');
+ return escapeHtml(String(dirty));
}
/**
@@ -323,9 +322,8 @@ function sanitizeUserInput(input, options = {}) {
// Either escape HTML or sanitize it
if (allowHtml) {
return sanitizeHtml(sanitized);
- } else {
- return escapeHtml(sanitized);
}
+ return escapeHtml(sanitized);
}
// Export to global scope
diff --git a/src/local_deep_research/web/static/js/services/formatting.js b/src/local_deep_research/web/static/js/services/formatting.js
index dde80cf33e..6bfa2a328e 100644
--- a/src/local_deep_research/web/static/js/services/formatting.js
+++ b/src/local_deep_research/web/static/js/services/formatting.js
@@ -77,9 +77,8 @@ function formatDuration(seconds) {
if (minutes === 0) {
return `${remainingSeconds}s`;
- } else {
- return `${minutes}m ${remainingSeconds}s`;
}
+ return `${minutes}m ${remainingSeconds}s`;
}
/**
@@ -112,9 +111,8 @@ function formatCurrency(amount) {
return `$${amount.toFixed(6)}`;
} else if (amount < 1) {
return `$${amount.toFixed(4)}`;
- } else {
- return `$${amount.toFixed(2)}`;
}
+ return `$${amount.toFixed(2)}`;
}
/**
diff --git a/src/local_deep_research/web/static/js/services/ui.js b/src/local_deep_research/web/static/js/services/ui.js
index a1062db3b2..0ae6b67245 100644
--- a/src/local_deep_research/web/static/js/services/ui.js
+++ b/src/local_deep_research/web/static/js/services/ui.js
@@ -267,23 +267,22 @@ function renderMarkdown(markdown) {
: processedHtml;
return `<div class="ldr-markdown-content">${sanitized}</div>`;
- } else {
- // Fallback if marked is not available - display as plaintext for security
- // Using regex-based partial markdown is fragile and a security risk,
- // so we escape all HTML and display as preformatted text with a warning
- SafeLogger.warn('Marked library not available. Displaying as plaintext for security.');
- const escaped = typeof window.escapeHtml === 'function'
- ? window.escapeHtml(markdown)
- // bearer:disable javascript_lang_manual_html_sanitization
- : markdown.replace(/[&<>"']/g, (m) => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'})[m]);
-
- return `<div class="markdown-content">
- <div class="alert alert-warning" style="margin-bottom: 1rem;">
- <i class="fas fa-exclamation-triangle"></i> Markdown rendering unavailable. Displaying as plaintext.
- </div>
- <pre style="white-space: pre-wrap; word-wrap: break-word; font-family: inherit;">${escaped}</pre>
- </div>`;
}
+ // Fallback if marked is not available - display as plaintext for security
+ // Using regex-based partial markdown is fragile and a security risk,
+ // so we escape all HTML and display as preformatted text with a warning
+ SafeLogger.warn('Marked library not available. Displaying as plaintext for security.');
+ const escaped = typeof window.escapeHtml === 'function'
+ ? window.escapeHtml(markdown)
+ // bearer:disable javascript_lang_manual_html_sanitization
+ : markdown.replace(/[&<>"']/g, (m) => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'})[m]);
+
+ return `<div class="markdown-content">
+ <div class="alert alert-warning" style="margin-bottom: 1rem;">
+ <i class="fas fa-exclamation-triangle"></i> Markdown rendering unavailable. Displaying as plaintext.
+ </div>
+ <pre style="white-space: pre-wrap; word-wrap: break-word; font-family: inherit;">${escaped}</pre>
+ </div>`;
} catch (error) {
SafeLogger.error('Error rendering markdown:', error);
const escapedMessage = typeof window.escapeHtml === 'function'
diff --git a/src/local_deep_research/web/static/js/utils/form-validation.js b/src/local_deep_research/web/static/js/utils/form-validation.js
index ea81f5c6c6..28f3b47f06 100644
--- a/src/local_deep_research/web/static/js/utils/form-validation.js
+++ b/src/local_deep_research/web/static/js/utils/form-validation.js
@@ -84,15 +84,14 @@
errorElement.style.display = 'block';
}
return false;
- } else {
- element.classList.remove('ldr-field-invalid');
- element.removeAttribute('aria-invalid');
- if (errorElement) {
- errorElement.textContent = '';
- errorElement.style.display = 'none';
- }
- return true;
}
+ element.classList.remove('ldr-field-invalid');
+ element.removeAttribute('aria-invalid');
+ if (errorElement) {
+ errorElement.textContent = '';
+ errorElement.style.display = 'none';
+ }
+ return true;
}
/**
diff --git a/src/local_deep_research/web/static/js/utils/value-helpers.js b/src/local_deep_research/web/static/js/utils/value-helpers.js
index 35fe4bfa5b..71bc931002 100644
--- a/src/local_deep_research/web/static/js/utils/value-helpers.js
+++ b/src/local_deep_research/web/static/js/utils/value-helpers.js
@@ -113,9 +113,8 @@
return `"${value.substring(0, 18)}..."`;
} else if (typeof value === 'string') {
return `"${value}"`;
- } else {
- return String(value);
}
+ return String(value);
}
window.LdrValueHelpers = {
diff --git a/tests/accessibility_tests/auth-setup.js b/tests/accessibility_tests/auth-setup.js
index e4b102b182..ee683476f2 100644
--- a/tests/accessibility_tests/auth-setup.js
+++ b/tests/accessibility_tests/auth-setup.js
@@ -21,17 +21,24 @@ const authFile = path.join(authDir, 'user.json');
// Ensure .auth directory exists before storageState() call
mkdirSync(authDir, { recursive: true });
+// Login on a cold Docker boot can take >30s — registration creates an
+// encrypted SQLCipher DB, derives a key from the password, and imports
+// 500+ default settings. Give the setup task plenty of headroom; the
+// inner waitForURL still bounds the actual wait.
+setup.setTimeout(180_000);
+
setup('authenticate', async ({ page }) => {
await page.goto('/auth/login', { waitUntil: 'domcontentloaded' });
await page.fill('input[name="username"]', TEST_USERNAME);
await page.fill('input[name="password"]', TEST_PASSWORD);
- await page.click('button[type="submit"]');
-
- await page.waitForURL('/', { timeout: 60000 });
+ await Promise.all([
+ page.waitForURL('/', { timeout: 120_000 }),
+ page.click('button[type="submit"]'),
+ ]);
- await expect(page.locator('.ldr-user-info')).toBeVisible();
+ await expect(page.locator('.ldr-user-info')).toBeVisible({ timeout: 30_000 });
await page.context().storageState({ path: authFile });
});
diff --git a/tests/ui_tests/mobile/test_layout_bugs_ci.js b/tests/ui_tests/mobile/test_layout_bugs_ci.js
index 0b38b589a6..7759bdbeec 100644
--- a/tests/ui_tests/mobile/test_layout_bugs_ci.js
+++ b/tests/ui_tests/mobile/test_layout_bugs_ci.js
@@ -351,82 +351,82 @@ const Assertions = {
? `Settings accessible in mobile sheet menu (${result.settingsItemsCount} items found)`
: `Settings items NOT found in mobile sheet menu (${result.totalItems} total items, height=${result.sheetHeight}px)`
};
- } else {
- // For desktop/tablet, check sidebar can show all items
- const result = await page.evaluate(() => {
- const sidebar = document.querySelector('.ldr-sidebar');
- if (!sidebar) {
- return { exists: false };
- }
-
- const nav = sidebar.querySelector('.ldr-sidebar-nav');
- if (!nav) {
- return { exists: true, navExists: false };
- }
+ }
+ // For desktop/tablet, check sidebar can show all items
+ const result = await page.evaluate(() => {
+ const sidebar = document.querySelector('.ldr-sidebar');
+ if (!sidebar) {
+ return { exists: false };
+ }
- // Get all nav items
- const items = Array.from(nav.querySelectorAll('li a'));
+ const nav = sidebar.querySelector('.ldr-sidebar-nav');
+ if (!nav) {
+ return { exists: true, navExists: false };
+ }
- // Check if Settings section exists
- const settingsSection = Array.from(sidebar.querySelectorAll('.ldr-sidebar-section-label'))
- .find(el => el.textContent.toLowerCase().includes('settings'));
+ // Get all nav items
+ const items = Array.from(nav.querySelectorAll('li a'));
- // Check if any Settings items exist
- const settingsItems = items.filter(a =>
- a.href.includes('settings') ||
- a.href.includes('embeddings') ||
- a.href.includes('configuration')
- );
+ // Check if Settings section exists
+ const settingsSection = Array.from(sidebar.querySelectorAll('.ldr-sidebar-section-label'))
+ .find(el => el.textContent.toLowerCase().includes('settings'));
- // Check if last item is visible (within viewport)
- const sidebarRect = sidebar.getBoundingClientRect();
- const viewportHeight = window.innerHeight;
-
- // Find the bottom-most item
- let lastItemBottom = 0;
- items.forEach(item => {
- const rect = item.getBoundingClientRect();
- if (rect.bottom > lastItemBottom) {
- lastItemBottom = rect.bottom;
- }
- });
+ // Check if any Settings items exist
+ const settingsItems = items.filter(a =>
+ a.href.includes('settings') ||
+ a.href.includes('embeddings') ||
+ a.href.includes('configuration')
+ );
- const isScrollable = nav.scrollHeight > nav.clientHeight;
- const allItemsInView = lastItemBottom <= viewportHeight;
+ // Check if last item is visible (within viewport)
+ const sidebarRect = sidebar.getBoundingClientRect();
+ const viewportHeight = window.innerHeight;
- return {
- exists: true,
- navExists: true,
- totalItems: items.length,
- settingsSectionFound: !!settingsSection,
- settingsItemsCount: settingsItems.length,
- sidebarBottom: sidebarRect.bottom,
- lastItemBottom,
- viewportHeight,
- isScrollable,
- allItemsInView: allItemsInView || isScrollable // Either all visible or can scroll to them
- };
+ // Find the bottom-most item
+ let lastItemBottom = 0;
+ items.forEach(item => {
+ const rect = item.getBoundingClientRect();
+ if (rect.bottom > lastItemBottom) {
+ lastItemBottom = rect.bottom;
+ }
});
- if (!result.exists) {
- return { passed: true, message: 'Sidebar not on page' };
- }
-
- if (!result.navExists) {
- return { passed: false, message: 'Sidebar exists but nav not found' };
- }
-
- // We need either Settings items visible OR the section to be scrollable
- const hasSettingsAccess = result.settingsItemsCount > 0 || result.settingsSectionFound;
- const canAccessAll = result.allItemsInView;
+ const isScrollable = nav.scrollHeight > nav.clientHeight;
+ const allItemsInView = lastItemBottom <= viewportHeight;
return {
- passed: hasSettingsAccess && canAccessAll,
- message: hasSettingsAccess && canAccessAll
- ? `All ${result.totalItems} nav items accessible (Settings section found)`
- : `Nav items may be cut off: lastItemBottom=${result.lastItemBottom}px, viewportHeight=${result.viewportHeight}px, settingsFound=${hasSettingsAccess}`
+ exists: true,
+ navExists: true,
+ totalItems: items.length,
+ settingsSectionFound: !!settingsSection,
+ settingsItemsCount: settingsItems.length,
+ sidebarBottom: sidebarRect.bottom,
+ lastItemBottom,
+ viewportHeight,
+ isScrollable,
+ allItemsInView: allItemsInView || isScrollable // Either all visible or can scroll to them
};
+ });
+
+ if (!result.exists) {
+ return { passed: true, message: 'Sidebar not on page' };
+ }
+
+ if (!result.navExists) {
+ return { passed: false, message: 'Sidebar exists but nav not found' };
}
+
+ // We need either Settings items visible OR the section to be scrollable
+ const hasSettingsAccess = result.settingsItemsCount > 0 || result.settingsSectionFound;
+ const canAccessAll = result.allItemsInView;
+
+ return {
+ passed: hasSettingsAccess && canAccessAll,
+ message: hasSettingsAccess && canAccessAll
+ ? `All ${result.totalItems} nav items accessible (Settings section found)`
+ : `Nav items may be cut off: lastItemBottom=${result.lastItemBottom}px, viewportHeight=${result.viewportHeight}px, settingsFound=${hasSettingsAccess}`
+ };
+
},
/**
@@ -485,31 +485,31 @@ const Assertions = {
totalSpacing: paddingBottom + marginBottom,
passed: hasSufficientSpacing
};
- } else {
- const sidebar = document.querySelector('.ldr-sidebar');
- if (!sidebar) {
- return { mainExists: true, navExists: false };
- }
- const sidebarRect = sidebar.getBoundingClientRect();
- const sidebarStyle = window.getComputedStyle(sidebar);
- const mainRect = mainContent.getBoundingClientRect();
+ }
+ const sidebar = document.querySelector('.ldr-sidebar');
+ if (!sidebar) {
+ return { mainExists: true, navExists: false };
+ }
+ const sidebarRect = sidebar.getBoundingClientRect();
+ const sidebarStyle = window.getComputedStyle(sidebar);
+ const mainRect = mainContent.getBoundingClientRect();
- if (sidebarStyle.display === 'none' || sidebarRect.width === 0) {
- return { mainExists: true, navExists: false };
- }
+ if (sidebarStyle.display === 'none' || sidebarRect.width === 0) {
+ return { mainExists: true, navExists: false };
+ }
- // Check horizontal overlap
- const overlap = mainRect.left < sidebarRect.right ? sidebarRect.right - mainRect.left : 0;
+ // Check horizontal overlap
+ const overlap = mainRect.left < sidebarRect.right ? sidebarRect.right - mainRect.left : 0;
+
+ return {
+ mainExists: true,
+ navExists: true,
+ mainLeft: mainRect.left,
+ sidebarRight: sidebarRect.right,
+ overlap,
+ passed: overlap <= 10
+ };
- return {
- mainExists: true,
- navExists: true,
- mainLeft: mainRect.left,
- sidebarRight: sidebarRect.right,
- overlap,
- passed: overlap <= 10
- };
- }
}, isMobileWidth);
if (!result.mainExists) {
diff --git a/tests/ui_tests/test_benchmark_settings.js b/tests/ui_tests/test_benchmark_settings.js
index 32f12248e9..44627d8703 100644
--- a/tests/ui_tests/test_benchmark_settings.js
+++ b/tests/ui_tests/test_benchmark_settings.js
@@ -213,10 +213,9 @@ async function keepSessionAlive(page) {
providerSelect.dispatchEvent(new Event('change', { bubbles: true }));
console.log(`Set provider to Ollama (value: ${ollamaOption.value})`);
return true;
- } else {
- console.log('Could not find Ollama option in provider select');
- console.log('Available options:', Array.from(providerSelect.options).map(opt => opt.value));
}
+ console.log('Could not find Ollama option in provider select');
+ console.log('Available options:', Array.from(providerSelect.options).map(opt => opt.value));
}
console.log('Could not find provider field');
@@ -273,22 +272,21 @@ async function keepSessionAlive(page) {
modelSelect.dispatchEvent(new Event('change', { bubbles: true }));
console.log(`Set model to gemma3:12b (value: ${gemmaOption.value})`);
return true;
- } else {
- console.log('Could not find gemma3:12b option');
- console.log('Available model options:', options.map(opt => opt.value).slice(0, 10));
-
- // Try to find any Ollama model as fallback
- const ollamaOption = options.find(opt =>
- opt.value.toLowerCase().includes('gemma') ||
- opt.text.toLowerCase().includes('gemma')
- );
-
- if (ollamaOption) {
- modelSelect.value = ollamaOption.value;
- modelSelect.dispatchEvent(new Event('change', { bubbles: true }));
- console.log(`Set model to fallback Ollama model: ${ollamaOption.value}`);
- return true;
- }
+ }
+ console.log('Could not find gemma3:12b option');
+ console.log('Available model options:', options.map(opt => opt.value).slice(0, 10));
+
+ // Try to find any Ollama model as fallback
+ const ollamaOption = options.find(opt =>
+ opt.value.toLowerCase().includes('gemma') ||
+ opt.text.toLowerCase().includes('gemma')
+ );
+
+ if (ollamaOption) {
+ modelSelect.value = ollamaOption.value;
+ modelSelect.dispatchEvent(new Event('change', { bubbles: true }));
+ console.log(`Set model to fallback Ollama model: ${ollamaOption.value}`);
+ return true;
}
}
diff --git a/tests/ui_tests/test_news_breaking_table.js b/tests/ui_tests/test_news_breaking_table.js
index 693c475139..f687d2b0b5 100644
--- a/tests/ui_tests/test_news_breaking_table.js
+++ b/tests/ui_tests/test_news_breaking_table.js
@@ -271,10 +271,9 @@ async function testNewsBreakingTable() {
});
return;
- } else {
- console.log(` Still on: ${finalUrl}`);
- console.log(` API requests made: ${requests.length}`);
}
+ console.log(` Still on: ${finalUrl}`);
+ console.log(` API requests made: ${requests.length}`);
} else {
console.log('❌ Test run button not found');
}
diff --git a/tests/ui_tests/test_research_details.js b/tests/ui_tests/test_research_details.js
index dd572c1eae..f97d6679be 100644
--- a/tests/ui_tests/test_research_details.js
+++ b/tests/ui_tests/test_research_details.js
@@ -132,11 +132,9 @@ async function testResearchDetails() {
if (detailsLink) {
await detailsLink.click();
await page.waitForNavigation();
- } else {
+ } else if (research.id) {
// Try direct navigation if we have the ID
- if (research.id) {
- await page.goto(`${BASE_URL}/results/${research.id}`);
- }
+ await page.goto(`${BASE_URL}/results/${research.id}`);
}
// Wait for details page to load
diff --git a/tests/ui_tests/test_simple_cost.js b/tests/ui_tests/test_simple_cost.js
index f410693bc8..f8da04f560 100644
--- a/tests/ui_tests/test_simple_cost.js
+++ b/tests/ui_tests/test_simple_cost.js
@@ -124,10 +124,9 @@ const { getPuppeteerLaunchOptions } = require('./puppeteer_config');
if (testData.overview.total_calls > 0) {
console.log('Should show content!');
return 'should_show_content';
- } else {
- console.log('Should show no data');
- return 'should_show_no_data';
}
+ console.log('Should show no data');
+ return 'should_show_no_data';
}
return 'unknown';
});