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.

fix(ui-tests): stop logpanel prune-cap counter test timing out (#5057)

LearningCircuite02629509b67
diff --git a/tests/js/components/logpanel.test.js b/tests/js/components/logpanel.test.js
index a18e3ea2f2..3a9f3c3424 100644
--- a/tests/js/components/logpanel.test.js
+++ b/tests/js/components/logpanel.test.js
@@ -904,6 +904,22 @@ describe('per-category counters', () => {
return trimmed === '' ? 0 : parseInt(trimmed, 10);
}
+ afterEach(() => {
+ // Safety net for the prune-cap test below, which enables fake
+ // timers to keep addLogEntryToPanel's per-call setTimeout(autoscroll,
+ // 0) (logpanel.js:1138) from piling 501 real-timer tasks. Restore
+ // real timers here so a failure mid-test can't leak faked timers
+ // into a neighbour. No-op for the real-timer tests in this block;
+ // mirrors the cleanup half of the `ordering invariants` /
+ // `content dedup bypass` sibling blocks (including the fetch-mock
+ // teardown, since the batch-load test below mocks fetch). The
+ // beforeEach half is intentionally omitted because the batch-load
+ // test depends on a real setTimeout(resolve, 10).
+ vi.clearAllTimers();
+ vi.useRealTimers();
+ delete globalThis.fetch;
+ });
+
it('increments the matching category count when addLog is called', () => {
setupPanelDom({ page: 'progress' });
window._logPanelState.expanded = true;
@@ -962,7 +978,20 @@ describe('per-category counters', () => {
expect(getFilterCount('info')).toBe(1);
});
- it('decrements the matching category count when the cap prunes an entry', () => {
+ // Explicit timeout + faked timers: this test fills the DOM to the real
+ // MAX_LOG_ENTRIES cap (501 inserts) to exercise the live prune path.
+ // Each addLog -> addLogEntryToPanel queues a setTimeout(autoscroll, 0)
+ // (logpanel.js:1138) AND runs a full-container querySelectorAll
+ // dedup/insert/scan -- O(n^2) DOM work (~2.6-2.9s in happy-dom). Without
+ // faked timers the 501 real setTimeout tasks pile onto the timer queue
+ // and blow the 5s default. Same flake + same fix as the `ordering
+ // invariants` prune test (see release notes 1.8.1 / #4304). Faking timers
+ // here rather than in a beforeEach because the batch-load test below
+ // depends on a real setTimeout(resolve, 10). The assertions read DOM
+ // contents only, so leaving the autoscroll timers queued (unflushed) is
+ // fine.
+ it('decrements the matching category count when the cap prunes an entry', { timeout: 20000 }, () => {
+ vi.useFakeTimers();
setupPanelDom({ page: 'progress' });
window._logPanelState.expanded = true;