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 results exports (dead-field audit) (#4670)

LearningCircuit10e2aba8f661
diff --git a/tests/ui_tests/test_results_exports_ci.js b/tests/ui_tests/test_results_exports_ci.js
index ec2104c894..b17aa0fc8d 100644
--- a/tests/ui_tests/test_results_exports_ci.js
+++ b/tests/ui_tests/test_results_exports_ci.js
@@ -183,99 +183,103 @@ const StarRatingTests = {
},
async starRatingClickable(page, baseUrl) {
- const researchId = await findCompletedResearch(page, baseUrl);
-
- if (!researchId) {
- return { passed: null, skipped: true, message: 'No completed research for star click test' };
- }
+ // The star-rating widget (#research-rating > .ldr-star) is rendered
+ // server-side on every /results/<id> page and its click handler wires
+ // up purely from the URL id, so it works with no LLM and even when the
+ // DB has no completed research. Use a completed research if one exists,
+ // otherwise a synthetic id — the widget renders either way.
+ const researchId = (await findCompletedResearch(page, baseUrl)) || '0';
await navigateTo(page, `${baseUrl}/results/${researchId}`);
const result = await page.evaluate(() => {
- const stars = document.querySelectorAll(
- '.star, ' +
- '[class*="star"]:not([class*="start"]), ' +
- 'input[type="radio"][name*="rating"], ' +
- '.rating-star, ' +
- '.star-rating button, ' +
- '.star-rating span[data-value]'
- );
+ const widget = document.getElementById('research-rating');
+ const stars = Array.from(document.querySelectorAll('#research-rating .ldr-star'));
- if (stars.length === 0) return { hasStars: false };
-
- // Try to click the third star (rating of 3)
- const targetStar = stars[Math.min(2, stars.length - 1)];
- const beforeClick = document.querySelector('.star-rating, .rating')?.className || '';
+ if (!widget || stars.length === 0) {
+ return { onResultsPage: !!widget, starCount: stars.length };
+ }
+ // Click the third star (rating of 3).
+ const targetStar = stars[2];
targetStar.click();
- const afterClick = document.querySelector('.star-rating, .rating')?.className || '';
+ // Real signal: clicking the Nth star adds the "active" class to that
+ // star and every lower-indexed star (setRating in results.js), and
+ // leaves higher-indexed stars unmarked.
+ const activeFlags = stars.map(s => s.classList.contains('active'));
return {
- hasStars: true,
+ onResultsPage: true,
starCount: stars.length,
- clicked: true,
- classChanged: beforeClick !== afterClick
+ activeFlags,
+ lowerActive: activeFlags.slice(0, 3).every(Boolean),
+ higherInactive: activeFlags.slice(3).every(v => !v)
};
});
- if (!result.hasStars) {
- return { passed: null, skipped: true, message: 'No clickable stars found' };
+ // The widget must actually be present on the results page; if it's not,
+ // the wrong page (login/error) loaded — that's a real failure, not a skip.
+ if (!result.onResultsPage || result.starCount === 0) {
+ return {
+ passed: false,
+ message: `Star rating widget not found on results page (onResultsPage=${result.onResultsPage}, stars=${result.starCount})`
+ };
}
+ const passed = result.starCount === 5 && result.lowerActive && result.higherInactive;
+
return {
- passed: result.clicked,
- message: `Stars are clickable (${result.starCount} stars, class changed: ${result.classChanged})`
+ passed,
+ message: `Click on 3rd star sets active state [${result.activeFlags.map(v => (v ? '1' : '0')).join('')}] (expected 11100)`
};
},
async starRatingHoverFeedback(page, baseUrl) {
- const researchId = await findCompletedResearch(page, baseUrl);
-
- if (!researchId) {
- return { passed: null, skipped: true, message: 'No completed research for hover test' };
- }
+ // Same widget as starRatingClickable — rendered server-side on every
+ // /results/<id> page, so this works with no LLM and an empty DB.
+ const researchId = (await findCompletedResearch(page, baseUrl)) || '0';
await navigateTo(page, `${baseUrl}/results/${researchId}`);
- const starSelector = '.ldr-star';
- const star = await page.$(starSelector);
+ const stars = await page.$$('#research-rating .ldr-star');
- if (!star) {
- return { passed: null, skipped: true, message: 'No star elements found for hover test' };
- }
-
- // Get initial state
- const beforeHover = await page.evaluate((sel) => {
- const el = document.querySelector(sel);
+ // Star widget must be present on the results page; if it's missing the
+ // wrong page loaded — a real failure, not a skip.
+ if (stars.length !== 5) {
return {
- className: el?.className,
- style: el ? window.getComputedStyle(el).color : null
+ passed: false,
+ message: `Expected 5 star elements on results page, found ${stars.length}`
};
- }, starSelector);
+ }
- // Hover over star
- await star.hover();
+ // No star should carry the hover class before we hover.
+ const beforeHover = await page.evaluate(() =>
+ Array.from(document.querySelectorAll('#research-rating .ldr-star'))
+ .some(s => s.classList.contains('ldr-hover'))
+ );
+
+ // Hover the 4th star (mouseenter triggers highlightStars in results.js).
+ await stars[3].hover();
await delay(200);
- // Get hover state
- const afterHover = await page.evaluate((sel) => {
- const el = document.querySelector(sel);
+ // Specific expected affordance: hovering the Nth star adds the
+ // "ldr-hover" class to that star and every lower-indexed star.
+ const afterHover = await page.evaluate(() => {
+ const flags = Array.from(document.querySelectorAll('#research-rating .ldr-star'))
+ .map(s => s.classList.contains('ldr-hover'));
return {
- className: el?.className,
- style: el ? window.getComputedStyle(el).color : null
+ flags,
+ lowerHovered: flags.slice(0, 4).every(Boolean),
+ higherNotHovered: flags.slice(4).every(v => !v)
};
- }, starSelector);
+ });
- const hasHoverEffect = afterHover.className?.includes('ldr-hover') ||
- beforeHover.className !== afterHover.className ||
- beforeHover.style !== afterHover.style;
+ const passed = !beforeHover && afterHover.lowerHovered && afterHover.higherNotHovered;
return {
- passed: hasHoverEffect,
- message: hasHoverEffect
- ? 'Star rating has hover feedback'
- : 'No visible hover feedback detected'
+ passed,
+ message: `Hover on 4th star adds ldr-hover [${afterHover.flags.map(v => (v ? '1' : '0')).join('')}] (expected 11110, beforeAnyHover=${beforeHover})`
};
}
};