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(logpanel): cover successful log download preflight (#5457)

Ziyang Guo218f2435c075
diff --git a/tests/js/components/logpanel.test.js b/tests/js/components/logpanel.test.js
index b90a1ca7e6..830c96b5e2 100644
--- a/tests/js/components/logpanel.test.js
+++ b/tests/js/components/logpanel.test.js
@@ -2620,6 +2620,40 @@ describe('downloadLogs — HEAD pre-flight', () => {
}
);
+ it('starts the native download after a successful pre-flight', async () => {
+ globalThis.fetch = vi.fn().mockResolvedValue({
+ ok: true,
+ status: 200,
+ });
+ let clickedAnchor = null;
+ const anchorClick = vi
+ .spyOn(window.HTMLAnchorElement.prototype, 'click')
+ .mockImplementation(function () {
+ clickedAnchor = this;
+ expect(document.body.contains(this)).toBe(true);
+ });
+ const appendChild = vi.spyOn(document.body, 'appendChild');
+ const removeChild = vi.spyOn(document.body, 'removeChild');
+
+ document.getElementById('log-download-button').click();
+
+ await vi.waitFor(() => {
+ expect(anchorClick).toHaveBeenCalledOnce();
+ });
+ expect(globalThis.fetch).toHaveBeenCalledWith(exportUrl, {
+ method: 'HEAD',
+ });
+ expect(clickedAnchor.getAttribute('href')).toBe(exportUrl);
+ expect(clickedAnchor.download).toBe(
+ `research_logs_${researchId}.jsonl`
+ );
+ expect(clickedAnchor.style.display).toBe('none');
+ expect(appendChild).toHaveBeenCalledWith(clickedAnchor);
+ expect(removeChild).toHaveBeenCalledWith(clickedAnchor);
+ expect(document.body.contains(clickedAnchor)).toBe(false);
+ expect(window.ui.showAlert).not.toHaveBeenCalled();
+ });
+
it('continues with the native download when the pre-flight request fails', async () => {
globalThis.fetch = vi.fn().mockRejectedValue(new Error('network down'));
const anchorClick = vi