fix(settings): improve in-page search matching and coverage (#968)

* fix(settings): improve in-page search matching and coverage

Index AudioMuse and individual shortcut rows, tighten fuzzy matching so
junk queries return no hits, and scroll to the parent subsection when a
shortcut result is selected.

* docs: note PR #968 in changelog and settings credits
This commit is contained in:
cucadmuh
2026-06-03 23:56:54 +03:00
committed by GitHub
parent cd47a4b0fa
commit e8962c21ab
7 changed files with 131 additions and 26 deletions
@@ -0,0 +1,47 @@
import { describe, expect, it, vi } from 'vitest';
import { matchScore } from './settingsTabs';
import { searchSettings } from './settingsSearch';
const t = vi.fn((key: string) => {
const labels: Record<string, string> = {
'settings.audiomuseTitle': 'AudioMuse-AI (Navidrome)',
'settings.servers': 'Servers',
'settings.inputKeybindingsTitle': 'In-app shortcuts',
'settings.globalShortcutsTitle': 'Global shortcuts',
'settings.shortcutVolumeUp': 'Volume up',
'settings.shortcutVolumeDown': 'Volume down',
'settings.playbackTitle': 'Playback',
};
return labels[key] ?? key;
});
describe('matchScore', () => {
it('prefers earlier substring matches', () => {
expect(matchScore('volume up global shortcuts', 'volume')).toBeGreaterThan(0);
});
it('rejects repeated-character junk queries via fuzzy matching', () => {
expect(matchScore('database backup analytics strategy', 'aaaaaaa')).toBe(0);
});
it('still fuzzy-matches compact typos', () => {
expect(matchScore('equalizer eq bass treble', 'equl')).toBeGreaterThan(0);
});
});
describe('searchSettings', () => {
it('finds AudioMuse by product name', () => {
const hits = searchSettings('AudioMuse', 'library', t as any);
expect(hits.some(h => h.title.includes('AudioMuse'))).toBe(true);
});
it('finds global volume shortcuts', () => {
const hits = searchSettings('Volume', 'library', t as any);
expect(hits.some(h => h.title === 'Volume up')).toBe(true);
expect(hits.some(h => h.title === 'Volume down')).toBe(true);
});
it('returns nothing for nonsense queries', () => {
expect(searchSettings('aaaaaaa', 'library', t as any)).toEqual([]);
});
});