Merge pull request #9 from rfc1437/copilot/update-category-assignment-widget

Unify post category editor with TagInput UI/behavior
This commit is contained in:
Georg Bauer
2026-02-17 14:10:38 +01:00
committed by GitHub
4 changed files with 72 additions and 226 deletions

View File

@@ -49,3 +49,40 @@ describe('TagInput subscriptions', () => {
});
});
});
describe('TagInput category mode', () => {
beforeEach(() => {
const onMock = vi.fn((_channel: string, _callback: (...args: unknown[]) => void) => vi.fn());
(window as any).electronAPI = {
...(window as any).electronAPI,
tags: {
getAll: vi.fn().mockResolvedValue([]),
create: vi.fn(),
},
meta: {
...(window as any).electronAPI?.meta,
getCategories: vi.fn().mockResolvedValue(['article']),
},
on: onMock,
};
});
it('loads categories from meta API in category mode', async () => {
render(
<TagInput
value={[]}
onChange={vi.fn()}
placeholder="Add categories..."
mode="category"
/>
);
await act(async () => {
await Promise.resolve();
});
expect(window.electronAPI.meta.getCategories).toHaveBeenCalledTimes(1);
expect(window.electronAPI.on).not.toHaveBeenCalled();
});
});