import { render, screen } from '@testing-library/react'; import ResponsiveActions from './ResponsiveActions'; import ResponsiveAction from '../ResponsiveAction'; describe('ResponsiveActions component', () => { describe('should render correctly', () => { test('ResponsiveActions', () => { const { container } = render( Persistent action Pinned action Overflow action ); expect(container).toMatchSnapshot(); }); test('ResponsiveActions with only isPersistent actions', () => { const { container } = render( Persistent action 1 Persistent action 2 ); // Should not have dropdown control when only persistent actions const dropdownControl = container.querySelector('[data-ouia-component-id="ResponsiveActions-menu-control"]'); expect(dropdownControl).toBeNull(); // Should have persistent actions const buttons = container.querySelectorAll('button'); expect(buttons).toHaveLength(2); }); test('ResponsiveActions with only isPinned actions', () => { const { container } = render( Pinned action 1 Pinned action 2 ); // Should have pinned actions as buttons const buttons = container.querySelectorAll('button'); expect(buttons).toHaveLength(2); expect(container).toMatchSnapshot(); }); test('ResponsiveActions with mix of isPersistent and isPinned actions', () => { const { container } = render( Persistent action Pinned action ); // Should have both persistent and pinned actions as buttons const buttons = container.querySelectorAll('button'); expect(buttons).toHaveLength(2); expect(container).toMatchSnapshot(); }); test('ResponsiveActions with all dropdown items disabled should disable kebab', () => { render( Disabled action 1 Disabled action 2 ); const kebabToggle = screen.getByRole('button', { name: /actions overflow menu/i }); expect(kebabToggle).toBeDisabled(); }); test('ResponsiveActions with some enabled dropdown items should not disable kebab', () => { render( Disabled action Enabled action ); const kebabToggle = screen.getByRole('button', { name: /actions overflow menu/i }); expect(kebabToggle).toBeEnabled(); }); test('ResponsiveActions with enabled pinned item and disabled regular item should disable kebab above breakpoint', () => { render( Enabled pinned action Disabled regular action ); const kebabToggle = screen.getByRole('button', { name: /actions overflow menu/i }); expect(kebabToggle).toBeDisabled(); }); test('ResponsiveActions with enabled pinned item and enabled regular item should not disable kebab', () => { render( Enabled pinned action Enabled regular action ); const kebabToggle = screen.getByRole('button', { name: /actions overflow menu/i }); expect(kebabToggle).toBeEnabled(); }); test('ResponsiveActions with all dropdown items disabled including pinned should disable kebab', () => { render( Disabled pinned action Disabled action ); const kebabToggle = screen.getByRole('button', { name: /actions overflow menu/i }); expect(kebabToggle).toBeDisabled(); }); test('ResponsiveActions with only persistent items should not render kebab', () => { const { container } = render( Persistent action ); // Should not have kebab when only persistent items exist const kebabToggle = container.querySelector('[data-ouia-component-id="ResponsiveActions-menu-dropdown-toggle"]'); expect(kebabToggle).toBeNull(); }); }); });