feat: category menus

This commit is contained in:
2026-02-21 21:41:41 +01:00
parent c7123a142a
commit e1d470a44a
14 changed files with 547 additions and 31 deletions

View File

@@ -14,15 +14,20 @@ describe('MenuEditorView entry editor', () => {
get: vi.fn().mockResolvedValue({
items: [
{
id: 'root-page',
id: 'menu-home',
title: 'Home',
kind: 'page',
pageSlug: 'home',
children: [],
},
],
}),
save: vi.fn().mockResolvedValue({ items: [] }),
},
meta: {
...(window as any).electronAPI?.meta,
getCategories: vi.fn().mockResolvedValue(['news', 'tech']),
},
posts: {
...(window as any).electronAPI?.posts,
filter: vi.fn().mockResolvedValue([
@@ -188,4 +193,28 @@ describe('MenuEditorView entry editor', () => {
expect(screen.getByText('About')).toBeInTheDocument();
});
it('shows a category archive create button (C+) in toolbar', async () => {
render(<MenuEditorView />);
await screen.findByRole('button', { name: /add entry/i });
expect(screen.getByRole('button', { name: /add category archive/i })).toBeInTheDocument();
});
it('opens category input when category archive button is clicked', async () => {
render(<MenuEditorView />);
const button = await screen.findByRole('button', { name: /add category archive/i });
fireEvent.click(button);
expect(await screen.findByPlaceholderText(/type a category name/i)).toBeInTheDocument();
});
it('disables delete action when Home entry is selected', async () => {
render(<MenuEditorView />);
await screen.findByText('Home');
const deleteButton = screen.getByRole('button', { name: /^delete$/i });
expect(deleteButton).toBeDisabled();
});
});