import { describe, expect, it } from 'vitest';
import { buildNavItems } from '../../layout/Sidebar.js';
// Plugin adminNavItems (collected onto `_pluginNavItems` by cms-core's
// applyPlugins) must surface in the admin sidebar, without doubling a built-in
// destination or one of the plugin's own collections.
const baseCollections = {
    collections: {
        pages: { slug: 'pages', labels: { singular: 'Page', plural: 'Pages' }, type: 'page' },
    },
};
describe('buildNavItems — plugin nav items', () => {
    it('adds a plugin-contributed custom nav link', () => {
        const items = buildNavItems({
            ...baseCollections,
            _pluginNavItems: [{ label: 'Redirects', icon: 'arrow-right-left', path: '/redirects' }],
        });
        const redirects = items.find((i) => i.path === '/redirects');
        expect(redirects).toBeDefined();
        expect(redirects?.label).toBe('Redirects');
        expect(redirects?.group).toBe('Content');
    });
    it('does not double a built-in destination path', () => {
        const items = buildNavItems({
            ...baseCollections,
            _pluginNavItems: [{ label: 'Media Library', icon: 'image', path: '/media' }],
        });
        expect(items.filter((i) => i.path === '/media')).toHaveLength(1);
    });
    it('falls back to a default icon for an unknown icon string and still renders', () => {
        const items = buildNavItems({
            ...baseCollections,
            _pluginNavItems: [{ label: 'Custom', icon: 'no-such-icon', path: '/custom' }],
        });
        const custom = items.find((i) => i.path === '/custom');
        expect(custom).toBeDefined();
        expect(custom?.icon).toBeTruthy();
    });
    it('ignores malformed plugin nav entries', () => {
        const items = buildNavItems({
            ...baseCollections,
            _pluginNavItems: [{ label: 'No path' }, null, { path: '/ok', label: 'Ok', icon: 'menu' }],
        });
        expect(items.find((i) => i.path === '/ok')).toBeDefined();
    });
});
//# sourceMappingURL=sidebar-plugin-nav.test.js.map