Files
psysonic/src/utils/library/liveSearchDebug.test.ts
T
cucadmuh 91e7195e0f fix(library): scoped live search FTS, race, and multi-server advanced search (#868)
* fix(library): scoped live search FTS, race, and multi-server advanced search

Scope track_fts live search to active server_id so multi-server libraries
no longer show empty or wrong-server hits. Match Navidrome-style any-word
prefix matching and GROUP BY artist/album dedupe on track_fts only.

Frontend: parallel local vs search3 race (empty waits, 8s network timeout),
merge supplemental hits after both settle, debug via Settings → Logging →
Debug (frontend_debug_log). Advanced Search FTS subqueries use the same
server scope fix.

* docs: CHANGELOG and credits for PR #868 live search fix
2026-05-25 04:20:02 +03:00

38 lines
1.1 KiB
TypeScript

import { describe, expect, it, vi, beforeEach } from 'vitest';
import { onInvoke } from '@/test/mocks/tauri';
import { useAuthStore } from '@/store/authStore';
import { emitLiveSearchDebug } from './liveSearchDebug';
describe('emitLiveSearchDebug', () => {
beforeEach(() => {
useAuthStore.setState({ loggingMode: 'normal' });
});
it('forwards JSON to frontend_debug_log in debug mode', () => {
useAuthStore.setState({ loggingMode: 'debug' });
let captured: unknown;
onInvoke('frontend_debug_log', args => {
captured = args;
return undefined;
});
emitLiveSearchDebug('race_winner', { query: 'metal', winner: 'network' });
expect(captured).toEqual({
scope: 'live-search',
message: JSON.stringify({
step: 'race_winner',
details: { query: 'metal', winner: 'network' },
}),
});
});
it('is a no-op when logging mode is not debug', () => {
let invoked = false;
onInvoke('frontend_debug_log', () => {
invoked = true;
return undefined;
});
emitLiveSearchDebug('race_winner', { query: 'x' });
expect(invoked).toBe(false);
});
});