Skip to content

The open alternative to Salesforce, designed for AI.

Fix Modal stories

Charles Bochetd6215cad4640
diff --git a/packages/twenty-front/src/modules/ui/layout/modal/components/__stories__/ConfirmationModal.stories.tsx b/packages/twenty-front/src/modules/ui/layout/modal/components/__stories__/ConfirmationModal.stories.tsx
index 478f13a40da..6990b9429a0 100644
--- a/packages/twenty-front/src/modules/ui/layout/modal/components/__stories__/ConfirmationModal.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/modal/components/__stories__/ConfirmationModal.stories.tsx
@@ -7,6 +7,7 @@ import { internalHotkeysEnabledScopesState } from '@/ui/utilities/hotkey/states/
import { ComponentDecorator } from 'twenty-ui/testing';
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
import { RootDecorator } from '~/testing/decorators/RootDecorator';
+import { sleep } from '~/utils/sleep';
import { isModalOpenedComponentState } from '../../states/isModalOpenedComponentState';
import { ConfirmationModal } from '../ConfirmationModal';
@@ -101,6 +102,9 @@ export const CloseOnClickOutside: Story = {
const backdrop = await canvas.findByTestId('modal-backdrop');
+ // We need to wait for the outside click listener to be registered
+ await sleep(100);
+
await userEvent.click(backdrop);
await waitFor(() => {
diff --git a/packages/twenty-front/src/modules/ui/layout/modal/components/__stories__/Modal.stories.tsx b/packages/twenty-front/src/modules/ui/layout/modal/components/__stories__/Modal.stories.tsx
index 5ba8441d6f4..e75b044854a 100644
--- a/packages/twenty-front/src/modules/ui/layout/modal/components/__stories__/Modal.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/modal/components/__stories__/Modal.stories.tsx
@@ -7,6 +7,7 @@ import { internalHotkeysEnabledScopesState } from '@/ui/utilities/hotkey/states/
import { ComponentDecorator } from 'twenty-ui/testing';
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
import { RootDecorator } from '~/testing/decorators/RootDecorator';
+import { sleep } from '~/utils/sleep';
import { isModalOpenedComponentState } from '../../states/isModalOpenedComponentState';
import { Modal } from '../Modal';
@@ -87,7 +88,9 @@ export const CloseClosableModalOnClickOutside: Story = {
await canvas.findByText('Click Outside Test');
- const backdrop = document.querySelector('.modal-backdrop') as HTMLElement;
+ const backdrop = await canvas.findByTestId('modal-backdrop');
+ // We need to wait for the outside click listener to be registered
+ await sleep(100);
await userEvent.click(backdrop);
await waitFor(() => {