feat(#248): admin tag page complete overhaul — tree panel, merge, subtree delete, new edit components #249

Merged
marcel merged 51 commits from feat/issue-221-tag-hierarchy into main 2026-04-17 10:24:10 +02:00
2 changed files with 25 additions and 1 deletions
Showing only changes of commit 6f6ff8e9ed - Show all commits

View File

@@ -66,4 +66,22 @@ describe('createTypeahead', () => {
expect(fetchUrl).toHaveBeenCalledTimes(1);
expect(fetchUrl).toHaveBeenCalledWith('foo');
});
it('fetch error logs to console.error and sets results to empty', async () => {
const fetchUrl = vi.fn().mockRejectedValue(new Error('network error'));
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
const ta = createTypeahead({ fetchUrl, debounceMs: 0 });
ta.setQuery('foo');
await vi.advanceTimersByTimeAsync(0);
expect(errorSpy).toHaveBeenCalled();
expect(ta.results).toEqual([]);
errorSpy.mockRestore();
});
it('setActiveIndex updates activeIndex', () => {
const ta = createTypeahead({ fetchUrl: vi.fn().mockResolvedValue([]) });
expect(ta.activeIndex).toBe(-1);
ta.setActiveIndex(2);
expect(ta.activeIndex).toBe(2);
});
});

View File

@@ -23,7 +23,8 @@ export function createTypeahead<T>(options: Options<T>) {
loading = true;
try {
results = await fetchUrl(q);
} catch {
} catch (e) {
console.error('typeahead fetch error', e);
results = [];
} finally {
loading = false;
@@ -36,6 +37,10 @@ export function createTypeahead<T>(options: Options<T>) {
activeIndex = -1;
}
function setActiveIndex(idx: number) {
activeIndex = idx;
}
function select(item: T) {
onSelect?.(item);
close();
@@ -64,6 +69,7 @@ export function createTypeahead<T>(options: Options<T>) {
return activeIndex;
},
setQuery,
setActiveIndex,
close,
select,
openWith