~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
/**
* Tests for pages/notes.js — loadNotes search dispatch.
*
* loadNotes routes to a loader by mode + query length: SEMANTIC + query(>=2)
* -> semantic search; HYBRID + query(>=2) -> keyword + semantic in parallel;
* TEXT mode, or a query under 2 chars (incl. empty "show everything"), -> the
* plain keyword listing.
*
* Driven via the production-inert window.__notesTest hook; loader identity is
* inferred from the fetched URLs.
*/
let hook;
beforeAll(async () => {
window.__VITEST_TEST__ = true;
globalThis.safeFetch = vi.fn(() =>
Promise.resolve({ json: () => Promise.resolve({ success: true, notes: [], results: [] }) })
);
globalThis.escapeHtml = (s) => String(s ?? '');
// Hybrid merge stub (keeps loadNotesHybridSearch happy).
await import('@js/components/semantic_search.js');
window.SemanticSearch = {
...window.SemanticSearch, buildTieredResults: () => ({ tier1: [], tier2: [], tier3: [] }) };
await import('@js/pages/notes.js');
hook = window.__notesTest;
});
afterAll(() => {
delete window.__VITEST_TEST__;
delete window.SemanticSearch;
});
function setup() {
const grid = document.createElement('div');
const empty = document.createElement('div');
const notice = document.createElement('div');
document.body.append(grid, empty, notice);
hook.setDomRefs({ grid, empty, notice });
window.ui = { showMessage: vi.fn() };
}
function urlsHit(fetchMock) {
return fetchMock.mock.calls.map(([u]) => u);
}
describe('loadNotes dispatch', () => {
it('SEMANTIC + query -> semantic search only', async () => {
setup();
hook.setMode('semantic');
hook.setSearchState({ search: 'meaning' });
const fetchMock = vi.fn(() =>
Promise.resolve({ json: () => Promise.resolve({ success: true, results: [] }) })
);
globalThis.safeFetch = fetchMock;
await hook.loadNotes();
const urls = urlsHit(fetchMock);
expect(urls.some((u) => u.includes('/semantic-search'))).toBe(true);
expect(urls.some((u) => /\/api\/notes\?/.test(u))).toBe(false); // no keyword listing
});
it('HYBRID + query -> keyword AND semantic in parallel', async () => {
setup();
hook.setMode('hybrid');
hook.setSearchState({ search: 'meaning' });
const fetchMock = vi.fn(() =>
Promise.resolve({ json: () => Promise.resolve({ success: true, notes: [], results: [] }) })
);
globalThis.safeFetch = fetchMock;
await hook.loadNotes();
const urls = urlsHit(fetchMock);
expect(urls.some((u) => u.includes('/semantic-search'))).toBe(true);
expect(urls.some((u) => /\/api\/notes\?/.test(u))).toBe(true);
});
it('TEXT mode + query -> keyword listing only', async () => {
setup();
hook.setMode('text');
hook.setSearchState({ search: 'meaning' });
const fetchMock = vi.fn(() =>
Promise.resolve({ json: () => Promise.resolve({ success: true, notes: [] }) })
);
globalThis.safeFetch = fetchMock;
await hook.loadNotes();
const urls = urlsHit(fetchMock);
expect(urls.some((u) => u.includes('/semantic-search'))).toBe(false);
expect(urls.some((u) => /\/api\/notes\?/.test(u))).toBe(true);
});
it('SEMANTIC mode but query under 2 chars -> falls through to keyword', async () => {
setup();
hook.setMode('semantic');
hook.setSearchState({ search: 'x' }); // 1 char
const fetchMock = vi.fn(() =>
Promise.resolve({ json: () => Promise.resolve({ success: true, notes: [] }) })
);
globalThis.safeFetch = fetchMock;
await hook.loadNotes();
const urls = urlsHit(fetchMock);
expect(urls.some((u) => u.includes('/semantic-search'))).toBe(false);
expect(urls.some((u) => /\/api\/notes\?/.test(u))).toBe(true);
});
});