import { jsx as _jsx } from "react/jsx-runtime";
// @vitest-environment happy-dom
import { describe, expect, it, vi } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
// The Forms nav item shows a live unread total summed across active forms.
// Mock the sidebar-counts fetcher so the badge math is deterministic.
const fetchFormsSidebarCounts = vi.fn(async () => [
    { formId: 'f1', name: 'Contact Us', slug: 'contact-us', status: 'active', unread: 8 },
    { formId: 'f2', name: 'Project Inquiry', slug: 'project-inquiry', status: 'active', unread: 3 },
]);
vi.mock('../../lib/forms-service.js', () => ({
    fetchFormsSidebarCounts: () => fetchFormsSidebarCounts(),
}));
const { Sidebar } = await import('../../layout/Sidebar.js');
describe('Sidebar forms unread badge', () => {
    it('sums unread across active forms onto the Forms item', async () => {
        render(_jsx(Sidebar, { collapsed: false, onToggleCollapse: () => { }, currentPath: "/", onNavigate: () => { } }));
        // 8 + 3 = 11 unread surfaced as the Forms badge.
        await waitFor(() => expect(screen.getByLabelText('11 unread')).toBeTruthy());
    });
    it('renders no badge when there are no unread submissions', async () => {
        fetchFormsSidebarCounts.mockResolvedValueOnce([
            { formId: 'f1', name: 'Newsletter', slug: 'newsletter', status: 'active', unread: 0 },
        ]);
        render(_jsx(Sidebar, { collapsed: false, onToggleCollapse: () => { }, currentPath: "/", onNavigate: () => { } }));
        await screen.findByText('Forms');
        expect(screen.queryByLabelText(/unread$/)).toBeNull();
    });
});
//# sourceMappingURL=sidebar-forms-badge.render.test.js.map