diff --git a/packages/gamut/src/Modals/Dialog.tsx b/packages/gamut/src/Modals/Dialog.tsx index e2cfe79088..33933e7fea 100644 --- a/packages/gamut/src/Modals/Dialog.tsx +++ b/packages/gamut/src/Modals/Dialog.tsx @@ -25,6 +25,7 @@ export interface DialogProps extends ModalBaseProps { >; confirmCta: DialogButtonProps; cancelCta?: DialogButtonProps; + closeButtonTipText?: string; } export const Dialog: React.FC = ({ @@ -36,6 +37,7 @@ export const Dialog: React.FC = ({ onRequestClose, image, size = 'small', + closeButtonTipText = 'Close dialog', ...rest }) => { const onConfirm: DialogButtonProps['onClick'] = ( @@ -69,12 +71,11 @@ export const Dialog: React.FC = ({ diff --git a/packages/gamut/src/Modals/__tests__/Dialog.test.tsx b/packages/gamut/src/Modals/__tests__/Dialog.test.tsx index a55f18acee..9c3fb890a4 100644 --- a/packages/gamut/src/Modals/__tests__/Dialog.test.tsx +++ b/packages/gamut/src/Modals/__tests__/Dialog.test.tsx @@ -20,6 +20,7 @@ const defaultProps = { children: 'Cancel', onClick: onCancel, }, + closeButtonTipText: 'Close Dialog', }; const renderView = setupRtl(Dialog, defaultProps); @@ -43,8 +44,9 @@ describe('Dialog', () => { it('requests closing the dialog when the close button is clicked', () => { const { view } = renderView(); + const ariaLabel = defaultProps.closeButtonTipText.split(' ')[0]; - fireEvent.click(view.getByLabelText('Close Dialog')); + fireEvent.click(view.getByLabelText(ariaLabel)); expect(onRequestClose.mock.calls.length).toBe(1); });