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 research workflow (dead-field audit) (#4676)

LearningCircuit248168eca992
diff --git a/tests/ui_tests/test_research_workflow_ci.js b/tests/ui_tests/test_research_workflow_ci.js
index 48a9f9631a..77f5ddf9d4 100644
--- a/tests/ui_tests/test_research_workflow_ci.js
+++ b/tests/ui_tests/test_research_workflow_ci.js
@@ -194,50 +194,38 @@ const ResearchFormTests = {
// ============================================================================
const ProgressTests = {
async progressPageStructure(page, baseUrl) {
- // We need to check if there's any research in progress or check the page structure
- // First, check history for any research
- await navigateTo(page, `${baseUrl}/history`);
-
- const historyResult = await page.evaluate(() => {
- const items = document.querySelectorAll('.history-item, .research-item, [data-research-id], tr[data-id]');
- if (items.length === 0) return { hasResearch: false };
-
- // Get first research ID
- const firstItem = items[0];
- const researchId = firstItem.dataset?.researchId || firstItem.dataset?.id ||
- firstItem.querySelector('[data-research-id]')?.dataset?.researchId ||
- firstItem.querySelector('a[href*="/results/"], a[href*="/progress/"]')?.href?.match(/\/(results|progress)\/(\d+)/)?.[2];
-
- return { hasResearch: true, researchId };
- });
-
- if (!historyResult.hasResearch) {
- return { passed: null, skipped: true, message: 'No research history to test progress page' };
- }
-
- // Try to access results page (completed research)
- await navigateTo(page, `${baseUrl}/results/${historyResult.researchId}`);
+ // The progress page (pages/progress.html) renders server-side for any
+ // research id — the route does not look the id up in the DB, so this is
+ // CI-safe with a fresh DB / no LLM. Assert the progress-page-specific
+ // container plus its concrete progress bar and status indicator, so the
+ // test fails if the wrong page (login/error/results) loaded instead.
+ await navigateTo(page, `${baseUrl}/progress/1`);
const result = await page.evaluate(() => {
- // Check for common progress/results page elements
- const progressBar = document.querySelector('.progress-bar, .progress, [role="progressbar"]');
- const statusBadge = document.querySelector('.status-badge, .badge, [class*="status"]');
- const reportContent = document.querySelector('.report-content, .research-report, .markdown-content, #report');
+ const progressPage = document.querySelector('#research-progress');
+ const progressFill = document.querySelector('#progress-bar.ldr-progress-fill');
+ const progressBar = document.querySelector('.ldr-progress-bar[role="progressbar"]');
+ const statusText = document.querySelector('#status-text.ldr-status-indicator');
return {
+ onProgressPage: !!progressPage,
+ hasProgressFill: !!progressFill,
hasProgressBar: !!progressBar,
- hasStatusBadge: !!statusBadge,
- hasReportContent: !!reportContent,
+ hasStatusText: !!statusText,
+ statusValue: statusText?.textContent?.trim() || null,
pageTitle: document.title
};
});
- const hasAnyElement = result.hasProgressBar || result.hasStatusBadge || result.hasReportContent;
+ const passed = result.onProgressPage && result.hasProgressBar &&
+ result.hasProgressFill && result.hasStatusText;
return {
- passed: hasAnyElement,
- message: hasAnyElement
- ? `Results page loaded (progress=${result.hasProgressBar}, status=${result.hasStatusBadge}, report=${result.hasReportContent})`
- : 'Results page missing expected elements'
+ passed,
+ message: passed
+ ? `Progress page structure OK (#research-progress, progress bar, status="${result.statusValue}")`
+ : `Progress page missing expected elements ` +
+ `(page=${result.onProgressPage}, bar=${result.hasProgressBar}, ` +
+ `fill=${result.hasProgressFill}, status=${result.hasStatusText}, title="${result.pageTitle}")`
};
}
};
@@ -247,79 +235,68 @@ const ProgressTests = {
// ============================================================================
const ResultsTests = {
async resultsPageStructure(page, baseUrl) {
- // Get a research ID from history
- await navigateTo(page, `${baseUrl}/history`);
-
- const researchId = await page.evaluate(() => {
- const link = document.querySelector('a[href*="/results/"]');
- if (link) {
- const match = link.href.match(/\/results\/(\d+)/);
- return match ? match[1] : null;
- }
- return null;
- });
-
- if (!researchId) {
- return { passed: null, skipped: true, message: 'No completed research to test results page' };
- }
-
- await navigateTo(page, `${baseUrl}/results/${researchId}`);
+ // The results page (pages/results.html) renders server-side for any
+ // research id — the route renders the template without a DB lookup, so
+ // this is CI-safe with a fresh DB / no LLM. Assert the results-page
+ // container, the exact title text, the report container and the
+ // metadata block, so the test fails if a login/error page loaded.
+ await navigateTo(page, `${baseUrl}/results/1`);
const result = await page.evaluate(() => {
+ const resultsPage = document.querySelector('#research-results');
+ const title = document.querySelector('#research-results h1.ldr-page-title');
+ // #results-content is the report container that results.js populates
+ const reportContainer = document.querySelector('#results-content.ldr-results-content');
+ const metadata = document.querySelector('#research-metadata.ldr-results-metadata');
+
return {
- hasTitle: !!document.querySelector('h1, .research-title, .query-title'),
- hasReport: !!document.querySelector('.report-content, .research-report, .markdown-content, #report, .ldr-report'),
- hasMetadata: !!document.querySelector('.research-metadata, .metadata, .info-section'),
- hasActions: !!document.querySelector('.action-buttons, .export-buttons, .btn-group')
+ onResultsPage: !!resultsPage,
+ titleText: title?.textContent?.trim() || null,
+ hasReport: !!reportContainer,
+ hasMetadata: !!metadata,
+ pageTitle: document.title
};
});
- const passed = result.hasTitle || result.hasReport;
+ const passed = result.onResultsPage &&
+ result.titleText === 'Research Results' &&
+ result.hasReport && result.hasMetadata;
return {
passed,
message: passed
- ? `Results page structure OK (title=${result.hasTitle}, report=${result.hasReport}, metadata=${result.hasMetadata}, actions=${result.hasActions})`
- : 'Results page missing title and report content'
+ ? `Results page structure OK (#research-results, title="${result.titleText}", report container, metadata)`
+ : `Results page missing expected elements ` +
+ `(page=${result.onResultsPage}, title="${result.titleText}", ` +
+ `report=${result.hasReport}, metadata=${result.hasMetadata}, docTitle="${result.pageTitle}")`
};
},
async exportButtonsExist(page, baseUrl) {
- await navigateTo(page, `${baseUrl}/history`);
-
- const researchId = await page.evaluate(() => {
- const link = document.querySelector('a[href*="/results/"]');
- if (link) {
- const match = link.href.match(/\/results\/(\d+)/);
- return match ? match[1] : null;
- }
- return null;
- });
-
- if (!researchId) {
- return { passed: null, skipped: true, message: 'No completed research to test export buttons' };
- }
-
- await navigateTo(page, `${baseUrl}/results/${researchId}`);
+ // Export controls are rendered server-side in pages/results.html with
+ // stable ids, so navigate straight to the results page (no DB/LLM
+ // dependency) and assert the concrete controls by id instead of doing a
+ // substring match over arbitrary button text.
+ await navigateTo(page, `${baseUrl}/results/1`);
const result = await page.evaluate(() => {
- const buttons = document.querySelectorAll('button, a.btn, .dropdown-item');
- const buttonTexts = Array.from(buttons).map(b => b.textContent?.toLowerCase() || '');
-
return {
- hasPdf: buttonTexts.some(t => t.includes('pdf')),
- hasMarkdown: buttonTexts.some(t => t.includes('markdown') || t.includes('.md')),
- hasLatex: buttonTexts.some(t => t.includes('latex') || t.includes('tex')),
- hasExport: buttonTexts.some(t => t.includes('export') || t.includes('download')),
- foundButtons: buttonTexts.filter(t => t.includes('export') || t.includes('download') || t.includes('pdf')).slice(0, 5)
+ onResultsPage: !!document.querySelector('#research-results'),
+ hasPdfBtn: !!document.querySelector('#download-pdf-btn'),
+ hasExportDropdown: !!document.querySelector('#export-dropdown-btn[data-bs-toggle="dropdown"]'),
+ hasMarkdownBtn: !!document.querySelector('#export-markdown-btn'),
+ hasLatexBtn: !!document.querySelector('#export-latex-btn')
};
});
- const hasAnyExport = result.hasPdf || result.hasMarkdown || result.hasLatex || result.hasExport;
+ const passed = result.onResultsPage && result.hasPdfBtn &&
+ result.hasExportDropdown && result.hasMarkdownBtn;
return {
- passed: hasAnyExport,
- message: hasAnyExport
- ? `Export options found: PDF=${result.hasPdf}, Markdown=${result.hasMarkdown}, LaTeX=${result.hasLatex}`
- : 'No export buttons found'
+ passed,
+ message: passed
+ ? `Export controls present (#download-pdf-btn, #export-dropdown-btn, #export-markdown-btn, latex=${result.hasLatexBtn})`
+ : `Export controls missing ` +
+ `(page=${result.onResultsPage}, pdf=${result.hasPdfBtn}, ` +
+ `dropdown=${result.hasExportDropdown}, markdown=${result.hasMarkdownBtn})`
};
},