import { ComponentProps } from 'react'; import { render, screen } from '@testing-library/react'; import { ResourceDetailHeader } from './ResourceDetailHeader'; import { HeaderStats } from './HeaderStats'; import { ResourceStatBlock } from './ResourceStatBlock'; function renderComponent( props: Partial> = {} ) { const defaultProps: ComponentProps = { title: 'Test Group', icon: icon, ...props, }; return render(); } describe('ResourceDetailHeader', () => { it('should render title and icon', () => { renderComponent(); expect(screen.getByText('Test Group')).toBeVisible(); expect(screen.getByTestId('test-icon')).toBeVisible(); }); it('should render subtitle when provided', () => { renderComponent({ subtitleLabel: 'Environment Group' }); expect(screen.getByText('Environment Group')).toBeVisible(); }); it('should render description when provided', () => { renderComponent({ description: 'A test description' }); expect(screen.getByText('A test description')).toBeVisible(); }); it('should render badge when provided', () => { renderComponent({ badge: Multi-platform }); expect(screen.getByText('Multi-platform')).toBeVisible(); }); it('should render rightInfo when provided', () => { renderComponent({ rightInfo: 5 environments }); expect(screen.getByText('5 environments')).toBeVisible(); }); it('should render stat blocks supplied via rightInfo', () => { renderComponent({ rightInfo: ( Sync Status Synced Health Healthy ), }); expect(screen.getByText('Sync Status')).toBeVisible(); expect(screen.getByText('Synced')).toBeVisible(); expect(screen.getByText('Health')).toBeVisible(); expect(screen.getByText('Healthy')).toBeVisible(); }); it('should render the action bar segment when provided', () => { renderComponent({ actionBar: ( <> Add Environment Delete ), }); expect(screen.getByText('Add Environment')).toBeVisible(); expect(screen.getByText('Delete')).toBeVisible(); }); it('should not render the action bar segment when omitted', () => { renderComponent(); expect(screen.queryByText('Add Environment')).not.toBeInTheDocument(); }); });