import { jsx as _jsx } from "react/jsx-runtime";
import { afterEach, describe, expect, it, vi } from 'vitest';
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
import { ThemeProvider } from '../../../../theme';
import { ChatHeader } from '../ChatHeader';
const renderHeader = (overrideProps = {}) => {
    const props = {
        onNewSession: vi.fn(),
        onToggleSettings: vi.fn(),
        isSettingsOpen: false,
        ...overrideProps
    };
    return render(_jsx(ThemeProvider, { initialThemeName: 'light', children: _jsx(ChatHeader, { ...props }) }));
};
afterEach(() => {
    cleanup();
});
describe('ChatHeader', () => {
    it('renders a sessions toggle when handler provided', () => {
        const handleToggleSessions = vi.fn();
        renderHeader({ onToggleSessions: handleToggleSessions, isSessionsOpen: false });
        const button = screen.getByRole('button', { name: 'Show session history' });
        fireEvent.click(button);
        expect(handleToggleSessions).toHaveBeenCalledTimes(1);
    });
    it('omits sessions toggle when handler not provided', () => {
        renderHeader();
        const buttons = screen.queryAllByRole('button', { name: /sessions/i });
        expect(buttons.length).toBe(0);
    });
});
