diff --git a/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-device-desktop-action-dialog-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-device-desktop-action-dialog-1-snap.png index df71a81de1..7a36fcb06c 100644 Binary files a/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-device-desktop-action-dialog-1-snap.png and b/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-device-desktop-action-dialog-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-device-mobile-ios-action-dialog-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-device-mobile-ios-action-dialog-1-snap.png index 7dc9bb3b01..21705c512f 100644 Binary files a/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-device-mobile-ios-action-dialog-1-snap.png and b/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-device-mobile-ios-action-dialog-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-optional-elements-are-not-displayed-if-not-provided-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-optional-elements-are-not-displayed-if-not-provided-1-snap.png new file mode 100644 index 0000000000..18dea849e7 Binary files /dev/null and b/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-dialog-optional-elements-are-not-displayed-if-not-provided-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-select-options-are-correctly-positioned-inside-a-dialog-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-select-options-are-correctly-positioned-inside-a-dialog-1-snap.png index c61c70f83a..b0214daf68 100644 Binary files a/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-select-options-are-correctly-positioned-inside-a-dialog-1-snap.png and b/src/__screenshot_tests__/__image_snapshots__/dialog-screenshot-test-tsx-select-options-are-correctly-positioned-inside-a-dialog-1-snap.png differ diff --git a/src/__screenshot_tests__/dialog-screenshot-test.tsx b/src/__screenshot_tests__/dialog-screenshot-test.tsx index 67c3d1402c..3ab5e8da45 100644 --- a/src/__screenshot_tests__/dialog-screenshot-test.tsx +++ b/src/__screenshot_tests__/dialog-screenshot-test.tsx @@ -40,3 +40,26 @@ test('Select options are correctly positioned inside a dialog', async () => { const image = await page.screenshot({fullPage: true}); expect(image).toMatchImageSnapshot(); }); + +test('Dialog optional elements are not displayed if not provided', async () => { + const page = await openStoryPage({ + id: 'components-modals--dialog', + device: 'DESKTOP', + args: { + message: 'Message', + title: '', + subtitle: '', + onAccept: false, + onCancel: false, + link: false, + icon: false, + extra: false, + }, + }); + + await (await screen.findByRole('button', {name: 'Open'})).click(); + await screen.findByRole('dialog'); + + const image = await page.screenshot({fullPage: true}); + expect(image).toMatchImageSnapshot(); +}); diff --git a/src/__stories__/dialog-story.tsx b/src/__stories__/dialog-story.tsx index 7f81333edb..aef4bcfaae 100644 --- a/src/__stories__/dialog-story.tsx +++ b/src/__stories__/dialog-story.tsx @@ -63,7 +63,35 @@ export const Confirm: StoryComponent<{destructive: boolean}> = ({destructive}) = ); }; -export const Dialog: StoryComponent = () => { +Confirm.args = { + destructive: false, +}; + +type DialogArgs = { + title: string; + subtitle: string; + message: string; + acceptText: string; + cancelText: string; + onAccept: boolean; + onCancel: boolean; + link: boolean; + icon: boolean; + extra: boolean; +}; + +export const Dialog: StoryComponent = ({ + onAccept, + onCancel, + link, + icon, + extra, + title, + subtitle, + message, + acceptText, + cancelText, +}) => { const {dialog} = useDialog(); return ( { aria-haspopup="dialog" onPress={() => dialog({ - title: 'Title', - subtitle: 'Subtitle', - message: 'Message', - acceptText: 'Accept terms and conditions', - extra: ( + title, + subtitle, + message, + acceptText, + cancelText, + extra: extra ? ( Extra content