feat: align post category input with tag widget behavior

Co-authored-by: rfc1437 <774975+rfc1437@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-17 12:45:19 +00:00
parent beb951db97
commit 2f963df9d2
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();
});
});