Skip to content

The open alternative to Salesforce, designed for AI.

Stabilize frontend and twenty-ui stories (#28303)

Raphaël Bosi9b42217567c5
diff --git a/packages/twenty-front/.storybook/preview.tsx b/packages/twenty-front/.storybook/preview.tsx
index 8db064f17a1..6dc6073c9d0 100644
--- a/packages/twenty-front/.storybook/preview.tsx
+++ b/packages/twenty-front/.storybook/preview.tsx
@@ -11,6 +11,7 @@ import { type Preview } from '@storybook/react-vite';
import { http, HttpResponse } from 'msw';
import { initialize, mswLoader } from 'msw-storybook-addon';
import { SOURCE_LOCALE } from 'twenty-shared/translations';
+import { MOCKED_DATE } from '~/testing/constants/MockedDate';
// oxlint-disable-next-line no-restricted-imports
import { DateFormat } from '../src/modules/localization/constants/DateFormat';
@@ -32,6 +33,7 @@ import 'twenty-ui/style.css';
import 'twenty-ui/theme-light.css';
import 'twenty-ui/theme-dark.css';
import { GRAY_SCALE_LIGHT, ThemeProvider } from 'twenty-ui/theme';
+import { waitForStorybookFontsLoaded } from 'twenty-ui/testing';
// oxlint-disable-next-line no-restricted-imports
import { messages as enMessages } from '../src/locales/generated/en';
@@ -62,7 +64,7 @@ initialize(
{
onUnhandledRequest: async (request: Request) => {
const fileExtensionsToIgnore =
- /\.(ts|tsx|js|jsx|svg|css|png|woff2)(\?v=[a-zA-Z0-9]+)?/;
+ /\.(ts|tsx|js|jsx|svg|css|png|jpe?g|gif|webp|avif|woff2)(\?v=[a-zA-Z0-9]+)?/;
if (fileExtensionsToIgnore.test(request.url)) {
return;
@@ -101,17 +103,6 @@ const STORYBOOK_DEFAULT_USER_CONTEXT = {
timeZone: 'UTC',
};
-const INTER_FONT_WEIGHTS = ['400', '500', '600'];
-
-const waitForInterFontLoadedBeforeScreenshot = async () => {
- await Promise.all(
- INTER_FONT_WEIGHTS.map((weight) =>
- document.fonts.load(`${weight} 1em Inter`),
- ),
- );
- await document.fonts.ready;
-};
-
const preview: Preview = {
decorators: [
(Story) => {
@@ -138,7 +129,7 @@ const preview: Preview = {
resetJotaiStore();
},
- loaders: [mswLoader, waitForInterFontLoadedBeforeScreenshot],
+ loaders: [mswLoader, waitForStorybookFontsLoaded],
parameters: {
argos: {
@@ -151,7 +142,7 @@ const preview: Preview = {
date: /Date$/,
},
},
- mockingDate: new Date('2024-03-12T09:30:00.000Z'),
+ mockingDate: new Date(MOCKED_DATE),
options: {
storySort: {
order: ['UI', 'Modules', 'Pages'],
diff --git a/packages/twenty-front/.storybook/vitest.setup.ts b/packages/twenty-front/.storybook/vitest.setup.ts
index 44a048c6162..5779a45cb73 100644
--- a/packages/twenty-front/.storybook/vitest.setup.ts
+++ b/packages/twenty-front/.storybook/vitest.setup.ts
@@ -27,12 +27,14 @@ await waitForServiceWorkerToControlPage();
// Pre-warm the dynamic imports used by lazy() story components so the
// modules are cached before any test runs (avoids flaky timeouts and Argos
// screenshots that capture a Suspense skeleton instead of the loaded content).
-import('~/testing/utils/getTestEnrichedObjectMetadataItemsMock');
-import('react-markdown');
-import('remark-gfm');
-import('@/activities/components/ActivityRichTextEditor');
-import('@/object-record/record-field/ui/meta-types/input/components/RichTextFieldEditor');
-import('@/navigation-menu-item/display/sections/favorites/components/FavoritesSectionDispatcher');
-import('@/navigation-menu-item/display/sections/workspace/components/WorkspaceSectionDispatcher');
+await Promise.all([
+ import('~/testing/utils/getTestEnrichedObjectMetadataItemsMock'),
+ import('react-markdown'),
+ import('remark-gfm'),
+ import('@/activities/components/ActivityRichTextEditor'),
+ import('@/object-record/record-field/ui/meta-types/input/components/RichTextFieldEditor'),
+ import('@/navigation-menu-item/display/sections/favorites/components/FavoritesSectionDispatcher'),
+ import('@/navigation-menu-item/display/sections/workspace/components/WorkspaceSectionDispatcher'),
+]);
setProjectAnnotations([projectAnnotations]);
diff --git a/packages/twenty-front/src/modules/activities/timeline-activities/rows/components/__stories__/EventRowDate.stories.tsx b/packages/twenty-front/src/modules/activities/timeline-activities/rows/components/__stories__/EventRowDate.stories.tsx
index c556bb63dc7..54b76e725e2 100644
--- a/packages/twenty-front/src/modules/activities/timeline-activities/rows/components/__stories__/EventRowDate.stories.tsx
+++ b/packages/twenty-front/src/modules/activities/timeline-activities/rows/components/__stories__/EventRowDate.stories.tsx
@@ -1,9 +1,9 @@
+import { getMockedDateWithOffset } from '~/testing/utils/getMockedDateWithOffset';
import { EventRowDate } from '@/activities/timeline-activities/rows/components/EventRowDate';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { ComponentDecorator } from 'twenty-ui/testing';
-// stories run with a mocked date of 2024-03-12T09:30:00.000Z
const meta: Meta<typeof EventRowDate> = {
title: 'Modules/TimelineActivities/Rows/EventRowDate',
component: EventRowDate,
@@ -15,7 +15,7 @@ type Story = StoryObj<typeof EventRowDate>;
export const Default: Story = {
args: {
- happensAt: '2024-03-09T09:30:00.000Z',
+ happensAt: getMockedDateWithOffset({ days: -3 }),
},
};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/components/__stories__/AdvancedTextEditor.stories.tsx b/packages/twenty-front/src/modules/advanced-text-editor/components/__stories__/AdvancedTextEditor.stories.tsx
index 12e98a461c8..96aaf344a83 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/components/__stories__/AdvancedTextEditor.stories.tsx
+++ b/packages/twenty-front/src/modules/advanced-text-editor/components/__stories__/AdvancedTextEditor.stories.tsx
@@ -12,6 +12,7 @@ import { WorkflowStepActionDrawerDecorator } from '~/testing/decorators/Workflow
import { WorkflowStepDecorator } from '~/testing/decorators/WorkflowStepDecorator';
import { WorkspaceDecorator } from '~/testing/decorators/WorkspaceDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
+import { IMAGE_URL_MOCK } from '~/testing/mock-data/image-url';
import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';
const STORY_RICH_TEXT_PROFILE = {
@@ -57,12 +58,7 @@ const EditorWrapper = ({
const jsonContent = editor.getJSON();
onUpdate(JSON.stringify(jsonContent));
},
- onImageUpload: async (file: File) => {
- await new Promise((resolve) => setTimeout(resolve, 1000));
- return {
- url: `https://via.placeholder.com/400x200?text=${encodeURIComponent(file.name)}`,
- };
- },
+ onImageUpload: async () => ({ url: IMAGE_URL_MOCK }),
onImageUploadError: (_error: Error, _file: File) => {},
});
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessage.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessage.stories.tsx
index f0508206f51..fb1040ffcf6 100644
--- a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessage.stories.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatMessage.stories.tsx
@@ -1,3 +1,5 @@
+import { getMockedDateWithOffset } from '~/testing/utils/getMockedDateWithOffset';
+import { MOCKED_DATE } from '~/testing/constants/MockedDate';
import {
type Decorator,
type Meta,
@@ -19,6 +21,7 @@ import { styled } from '@linaria/react';
import { useStore } from 'jotai';
import { RootDecorator } from '~/testing/decorators/RootDecorator';
import { ToastDecorator } from '~/testing/decorators/ToastDecorator';
+import { IMAGE_URL_MOCK } from '~/testing/mock-data/image-url';
const StyledConversationContainer = styled.div`
display: flex;
@@ -38,7 +41,7 @@ const mockUserMessage: ExtendedUIMessage = {
},
],
metadata: {
- createdAt: new Date(Date.now() - 120000).toISOString(),
+ createdAt: getMockedDateWithOffset({ minutes: -2 }),
},
};
@@ -79,7 +82,7 @@ print("Chart saved successfully!")`,
{
fileId: '550e8400-e29b-41d4-a716-446655440005',
filename: 'sales_chart.png',
- url: 'https://picsum.photos/800/480',
+ url: IMAGE_URL_MOCK,
mimeType: 'image/png',
},
],
@@ -91,7 +94,7 @@ print("Chart saved successfully!")`,
},
],
metadata: {
- createdAt: new Date(Date.now() - 60000).toISOString(),
+ createdAt: getMockedDateWithOffset({ minutes: -1 }),
usage: {
inputTokens: 1250,
outputTokens: 890,
@@ -113,7 +116,7 @@ const mockSimpleTextResponse: ExtendedUIMessage = {
},
],
metadata: {
- createdAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
},
};
@@ -127,7 +130,7 @@ const mockStreamingMessage: ExtendedUIMessage = {
},
],
metadata: {
- createdAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
},
};
@@ -152,7 +155,7 @@ print("Done!")`,
},
],
metadata: {
- createdAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
},
};
@@ -183,7 +186,7 @@ print(df.head())`,
},
],
metadata: {
- createdAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
},
};
@@ -205,7 +208,7 @@ const mockThinkingStepsStreaming: ExtendedUIMessage = {
},
],
metadata: {
- createdAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
},
};
@@ -231,7 +234,7 @@ const mockThinkingStepsDone: ExtendedUIMessage = {
},
],
metadata: {
- createdAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
startedAt: '2026-01-01T10:00:00.000Z',
finishedAt: '2026-01-01T10:01:23.000Z',
},
@@ -264,7 +267,7 @@ const mockAnsweredForm: ExtendedUIMessage = {
},
],
metadata: {
- createdAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
},
};
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/CodeExecutionDisplay.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/CodeExecutionDisplay.stories.tsx
index bcb296eb8ec..60859950d57 100644
--- a/packages/twenty-front/src/modules/ai/components/__stories__/CodeExecutionDisplay.stories.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/CodeExecutionDisplay.stories.tsx
@@ -5,6 +5,7 @@ import { ComponentDecorator } from 'twenty-ui/testing';
import { CodeExecutionDisplay } from '@/ai/components/CodeExecutionDisplay';
import { ARGOS_CAPTURE_DISABLED } from '~/testing/constants/ArgosCaptureDisabled';
import { ToastDecorator } from '~/testing/decorators/ToastDecorator';
+import { IMAGE_URL_MOCK } from '~/testing/mock-data/image-url';
const samplePythonCode = `import pandas as pd
import matplotlib.pyplot as plt
@@ -106,13 +107,13 @@ export const WithImageFiles: Story = {
{
fileId: '550e8400-e29b-41d4-a716-446655440001',
filename: 'revenue_chart.png',
- url: 'https://picsum.photos/800/480',
+ url: IMAGE_URL_MOCK,
mimeType: 'image/png',
},
{
fileId: '550e8400-e29b-41d4-a716-446655440002',
filename: 'pie_chart.png',
- url: 'https://picsum.photos/600/400',
+ url: IMAGE_URL_MOCK,
mimeType: 'image/png',
},
],
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/TerminalOutput.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/TerminalOutput.stories.tsx
index 5f3fd1fc792..25f180ba714 100644
--- a/packages/twenty-front/src/modules/ai/components/__stories__/TerminalOutput.stories.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/TerminalOutput.stories.tsx
@@ -1,3 +1,4 @@
+import { MOCKED_DATE } from '~/testing/constants/MockedDate';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { expect, userEvent, waitFor, within } from 'storybook/test';
import { ComponentDecorator } from 'twenty-ui/testing';
@@ -124,9 +125,7 @@ export const Empty: Story = {
},
};
-const LONG_OUTPUT_BASE_TIMESTAMP_MS = new Date(
- '2024-03-12T09:30:00.000Z',
-).getTime();
+const LONG_OUTPUT_BASE_TIMESTAMP_MS = Date.parse(MOCKED_DATE);
export const LongOutput: Story = {
args: {
diff --git a/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenu.stories.tsx b/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenu.stories.tsx
index 783ca65de64..7841cce7b16 100644
--- a/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenu.stories.tsx
+++ b/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenu.stories.tsx
@@ -19,7 +19,6 @@ import {
mockedLimitedPermissionsUserData,
mockedWorkspaceMemberData,
} from '~/testing/mock-data/users';
-import { sleep } from '~/utils/sleep';
import { type SidePanelCommandMenuItemDisplayPage } from '@/command-menu-item/display/components/SidePanelCommandMenuItemDisplayPage';
import { CommandMenuComponentInstanceContext } from '@/command-menu/states/contexts/CommandMenuComponentInstanceContext';
@@ -42,8 +41,6 @@ import { ContextStorePageType, SidePanelPages } from 'twenty-shared/types';
import { IconDotsVertical, IconPlus } from 'twenty-ui/icon';
import { JestContextStoreSetter } from '~/testing/jest/JestContextStoreSetter';
-const openTimeout = 50;
-
const ContextStoreDecorator: Decorator = (Story) => {
return (
<RecordComponentInstanceContextsWrapper
@@ -174,7 +171,7 @@ export const MatchingNavigate: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const searchInput = await canvas.findByTestId(SIDE_PANEL_FOCUS_ID);
- await sleep(openTimeout);
+ await waitFor(() => expect(searchInput).toHaveFocus());
await userEvent.type(searchInput, 'ta');
expect(await canvas.findByText('Go to Tasks')).toBeVisible();
},
@@ -184,7 +181,7 @@ export const MatchingNavigateShortcuts: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const searchInput = await canvas.findByTestId(SIDE_PANEL_FOCUS_ID);
- await sleep(openTimeout);
+ await waitFor(() => expect(searchInput).toHaveFocus());
await userEvent.type(searchInput, 'gp');
expect(await canvas.findByText('Go to People')).toBeVisible();
},
@@ -194,7 +191,7 @@ export const NoResultsSearchFallback: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const searchInput = await canvas.findByTestId(SIDE_PANEL_FOCUS_ID);
- await sleep(openTimeout);
+ await waitFor(() => expect(searchInput).toHaveFocus());
await userEvent.type(searchInput, 'input without results');
expect(
await canvas.findByText('Use ‘input without results’ with...'),
diff --git a/packages/twenty-front/src/modules/file/components/__stories__/FileIcon.stories.tsx b/packages/twenty-front/src/modules/file/components/__stories__/FileIcon.stories.tsx
index 6ce0ae449a1..98aa06fb05b 100644
--- a/packages/twenty-front/src/modules/file/components/__stories__/FileIcon.stories.tsx
+++ b/packages/twenty-front/src/modules/file/components/__stories__/FileIcon.stories.tsx
@@ -1,5 +1,5 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { expect, fireEvent, waitFor } from 'storybook/test';
+import { expect, waitFor } from 'storybook/test';
import { FILE_CATEGORIES } from 'twenty-shared/types';
import { ComponentDecorator } from 'twenty-ui/testing';
@@ -8,7 +8,7 @@ import { FileIcon } from '@/file/components/FileIcon';
const IMAGE_DATA_URI =
'data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2216%22 height=%2216%22 viewBox=%220 0 16 16%22%3E%3Crect width=%2216%22 height=%2216%22 fill=%22%231D4ED8%22/%3E%3Ccircle cx=%228%22 cy=%228%22 r=%224%22 fill=%22%23FFFFFF%22/%3E%3C/svg%3E';
-const BROKEN_IMAGE_URL = 'https://example.invalid/missing-thumbnail.png';
+const BROKEN_IMAGE_URL = 'data:image/png;base64,invalid-image';
const meta: Meta<typeof FileIcon> = {
title: 'UI/File/FileIcon',
@@ -64,12 +64,6 @@ export const BrokenThumbnailFallsBackToIcon: Story = {
thumbnailUrl: BROKEN_IMAGE_URL,
},
play: async ({ canvasElement }) => {
- const thumbnail = canvasElement.querySelector('img');
-
- expect(thumbnail).not.toBeNull();
-
- fireEvent.error(thumbnail as HTMLImageElement);
-
await waitFor(() => {
expect(canvasElement.querySelector('img')).toBeNull();
expect(canvasElement.querySelector('svg')).not.toBeNull();
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/FilesFieldDisplay.perf.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/FilesFieldDisplay.perf.stories.tsx
index c01e8956357..3196112379b 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/FilesFieldDisplay.perf.stories.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/FilesFieldDisplay.perf.stories.tsx
@@ -5,6 +5,7 @@ import { ComponentDecorator } from 'twenty-ui/testing';
import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';
import { ToastDecorator } from '~/testing/decorators/ToastDecorator';
import { getProfilingStory } from '~/testing/profiling/utils/getProfilingStory';
+import { IMAGE_URL_MOCK } from '~/testing/mock-data/image-url';
const meta: Meta<typeof FilesDisplay> = {
title: 'UI/Data/Field/Display/FilesFieldDisplay',
@@ -30,7 +31,7 @@ const meta: Meta<typeof FilesDisplay> = {
fileId: 'file-3',
label: 'logo.png',
extension: '.png',
- url: 'https://example.com/logo.png',
+ url: IMAGE_URL_MOCK,
fileCategory: 'IMAGE',
},
],
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/__stories__/DateTimeFieldInput.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/__stories__/DateTimeFieldInput.stories.tsx
index ebfd14b352d..9ca4dda0df6 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/__stories__/DateTimeFieldInput.stories.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/__stories__/DateTimeFieldInput.stories.tsx
@@ -22,7 +22,7 @@ const {
handleEnterMocked,
} = getFieldInputEventContextProviderWithJestMocks();
-const formattedDate = new Date(2022, 0, 1, 2, 0, 0);
+const formattedDate = new Date('2022-01-01T02:00:00.000Z');
const DateFieldValueSetterEffect = ({ value }: { value: Date }) => {
const { setFieldValue } = useDateTimeField();
diff --git a/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/__stories__/SingleRecordPicker.stories.tsx b/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/__stories__/SingleRecordPicker.stories.tsx
index d2a4d5233b6..ee570fc59a0 100644
--- a/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/__stories__/SingleRecordPicker.stories.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/__stories__/SingleRecordPicker.stories.tsx
@@ -5,7 +5,6 @@ import { CoreObjectNameSingular } from 'twenty-shared/types';
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
import { ToastDecorator } from '~/testing/decorators/ToastDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
-import { sleep } from '~/utils/sleep';
import { SingleRecordPicker } from '@/object-record/record-picker/single-record-picker/components/SingleRecordPicker';
import { IconUserCircle } from 'twenty-ui/icon';
@@ -49,7 +48,6 @@ export const WithSearchFilter: Story = {
const searchInput = await canvas.findByRole('textbox');
await step('Enter search text', async () => {
- await sleep(50);
await userEvent.type(searchInput, 'a');
await expect(searchInput).toHaveValue('a');
});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/__stories__/RecordTable.stories.tsx b/packages/twenty-front/src/modules/object-record/record-table/__stories__/RecordTable.stories.tsx
index a6b62e28ba1..bb08e5e23ac 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/__stories__/RecordTable.stories.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/__stories__/RecordTable.stories.tsx
@@ -17,7 +17,6 @@ import { mockedViews } from '~/testing/mock-data/generated/metadata/views/mock-v
import { mockedWorkspaceMemberRecords } from '~/testing/mock-data/generated/data/workspaceMembers/mock-workspaceMembers-data';
import { getMockFieldMetadataItemOrThrow } from '~/testing/utils/getMockFieldMetadataItemOrThrow';
import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
-import { sleep } from '~/utils/sleep';
const companyView = mockedViews.find((v) => v.name === 'All Companies')!;
@@ -40,7 +39,35 @@ const meta: Meta = {
},
parameters: {
recordTableObjectNameSingular: 'company',
- msw: graphqlMocks,
+ msw: {
+ handlers: [
+ graphql.query('AggregateCompanies', () =>
+ HttpResponse.json({
+ data: {
+ companies: {
+ __typename: 'CompanyConnection',
+ totalCount: mockedCompanyRecords.length,
+ maxEmployees: 0,
+ percentageEmptyLinkedinLink: 0,
+ countNotEmptyAddress: 0,
+ },
+ },
+ }),
+ ),
+ graphql.query('FindOneWorkspaceMember', ({ variables }) =>
+ HttpResponse.json({
+ data: {
+ workspaceMember:
+ mockedWorkspaceMemberRecords.find(
+ (workspaceMemberRecord) =>
+ workspaceMemberRecord.id === variables.objectRecordId,
+ ) ?? null,
+ },
+ }),
+ ),
+ ...graphqlMocks.handlers,
+ ],
+ },
},
};
@@ -183,13 +210,14 @@ export const ScrolledLeft: Story = {
throw new Error('Scroll wrapper not found');
}
- await sleep(1000);
-
- fireEvent.scroll(scrollWrapper, {
- target: {
- scrollLeft: 100,
- },
- });
+ await waitFor(() =>
+ expect(scrollWrapper.scrollWidth).toBeGreaterThan(
+ scrollWrapper.clientWidth,
+ ),
+ );
+ scrollWrapper.scrollLeft = 100;
+ fireEvent.scroll(scrollWrapper);
+ await waitFor(() => expect(scrollWrapper.scrollLeft).toBe(100));
await canvas.findByText(mockedCompanyRecords[1].name);
},
@@ -217,37 +245,20 @@ export const ScrolledBottom: Story = {
throw new Error('Scroll wrapper not found');
}
- await sleep(1000);
-
- fireEvent.scroll(scrollWrapper, {
- target: {
- scrollTop: 80,
- },
- });
+ await waitFor(() =>
+ expect(scrollWrapper.scrollHeight).toBeGreaterThan(
+ scrollWrapper.clientHeight,
+ ),
+ );
+ scrollWrapper.scrollTop = 80;
+ fireEvent.scroll(scrollWrapper);
+ await waitFor(() => expect(scrollWrapper.scrollTop).toBe(80));
await canvas.findByText(mockedCompanyRecords[1].name);
},
};
export const MultiSelectPickerAnchorsToTableCell: Story = {
- parameters: {
- msw: {
- handlers: [
- ...graphqlMocks.handlers,
- graphql.query('FindOneWorkspaceMember', ({ variables }) =>
- HttpResponse.json({
- data: {
- workspaceMember:
- mockedWorkspaceMemberRecords.find(
- (workspaceMemberRecord) =>
- workspaceMemberRecord.id === variables.objectRecordId,
- ) ?? null,
- },
- }),
- ),
- ],
- },
- },
beforeEach: () => {
const originalViewFields = companyView.viewFields;
const originalWorkPolicy = mockedCompanyRecords[0].workPolicy;
diff --git a/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx b/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx
index 025ccb8793b..40f336f1218 100644
--- a/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx
@@ -1,3 +1,4 @@
+import { MOCKED_DATE } from '~/testing/constants/MockedDate';
import { TabListRoot } from '@/ui/layout/tab-list/components/TabListRoot';
import { Tabs } from 'twenty-ui/primitives/navigation';
import { Text } from 'twenty-ui/primitives/typography';
@@ -66,8 +67,8 @@ const createInitialTabs = (): PageLayoutTab[] => [
icon: 'IconPlus',
pageLayoutId: 'test-layout',
widgets: [],
- createdAt: new Date().toISOString(),
- updatedAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
+ updatedAt: MOCKED_DATE,
deletedAt: null,
},
{
@@ -81,8 +82,8 @@ const createInitialTabs = (): PageLayoutTab[] => [
position: 1,
pageLayoutId: 'test-layout',
widgets: [],
- createdAt: new Date().toISOString(),
- updatedAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
+ updatedAt: MOCKED_DATE,
deletedAt: null,
},
{
@@ -96,8 +97,8 @@ const createInitialTabs = (): PageLayoutTab[] => [
position: 2,
pageLayoutId: 'test-layout',
widgets: [],
- createdAt: new Date().toISOString(),
- updatedAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
+ updatedAt: MOCKED_DATE,
deletedAt: null,
},
];
@@ -156,8 +157,8 @@ const PageLayoutTabListPlayground = ({
position: nextIndex,
pageLayoutId: 'test-layout',
widgets: [],
- createdAt: new Date().toISOString(),
- updatedAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
+ updatedAt: MOCKED_DATE,
deletedAt: null,
},
],
diff --git a/packages/twenty-front/src/modules/page-layout/testing/pageLayoutDraftFixtures.ts b/packages/twenty-front/src/modules/page-layout/testing/pageLayoutDraftFixtures.ts
index b6a3bcffcee..232f7391ea8 100644
--- a/packages/twenty-front/src/modules/page-layout/testing/pageLayoutDraftFixtures.ts
+++ b/packages/twenty-front/src/modules/page-layout/testing/pageLayoutDraftFixtures.ts
@@ -1,3 +1,4 @@
+import { MOCKED_DATE } from '~/testing/constants/MockedDate';
import { type DraftPageLayout } from '@/page-layout/types/DraftPageLayout';
import { type PageLayoutTab } from '@/page-layout/types/PageLayoutTab';
import { type PageLayoutWidget } from '@/page-layout/types/PageLayoutWidget';
@@ -24,8 +25,8 @@ export const makeWidget = (
layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
index,
},
- createdAt: new Date().toISOString(),
- updatedAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
+ updatedAt: MOCKED_DATE,
deletedAt: null,
}) as unknown as PageLayoutWidget;
@@ -46,8 +47,8 @@ export const makeTab = (
layoutMode,
pageLayoutId: '',
widgets,
- createdAt: new Date().toISOString(),
- updatedAt: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
+ updatedAt: MOCKED_DATE,
deletedAt: null,
...overrides,
});
diff --git a/packages/twenty-front/src/modules/record-export/components/__stories__/RecordExportConnectionEffect.stories.tsx b/packages/twenty-front/src/modules/record-export/components/__stories__/RecordExportConnectionEffect.stories.tsx
index c383269e9aa..4c0fe2821c1 100644
--- a/packages/twenty-front/src/modules/record-export/components/__stories__/RecordExportConnectionEffect.stories.tsx
+++ b/packages/twenty-front/src/modules/record-export/components/__stories__/RecordExportConnectionEffect.stories.tsx
@@ -4,11 +4,20 @@ import { createRecordExportConnection } from '@/record-export/utils/createRecord
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { http, HttpResponse } from 'msw';
import { useState } from 'react';
-import { expect, spyOn, userEvent, waitFor, within } from 'storybook/test';
+import { expect, fn, spyOn, userEvent, waitFor, within } from 'storybook/test';
import { IconFileExport } from 'twenty-ui/icon';
+import { Button } from 'twenty-ui/primitives/input';
import { REACT_APP_SERVER_BASE_URL } from '~/config';
-const ExportExample = () => {
+const EXPORT_PROGRESS_BEFORE_COMPLETION = 42;
+
+type ExportExampleProps = {
+ shouldShowCompletionButton?: boolean;
+};
+
+const ExportExample = ({
+ shouldShowCompletionButton = true,
+}: ExportExampleProps) => {
const [connection] = useState(createRecordExportConnection);
const [isConnected, setIsConnected] = useState(true);
const [isExporting, setIsExporting] = useState(false);
@@ -45,14 +54,25 @@ const ExportExample = () => {
loading={isExporting}
progress={progress}
/>
- <button onClick={() => setIsConnected(false)}>Unmount connection</button>
+ {shouldShowCompletionButton && isExporting && (
+ <Button
+ onClick={() => completeExport()}
+ disabled={progress !== EXPORT_PROGRESS_BEFORE_COMPLETION}
+ >
+ Finish export
+ </Button>
+ )}
+ <Button onClick={() => setIsConnected(false)}>Unmount connection</Button>
{error && <p role="alert">{error}</p>}
</>
);
};
+const completeExport = fn<() => void>();
+
const exportHandler = (finish: 'completed' | 'interrupted' | 'wait') =>
http.post(`${REACT_APP_SERVER_BASE_URL}/metadata`, () => {
+ completeExport.mockReset();
const encoder = new TextEncoder();
const event = (progress: number) =>
encoder.encode(
@@ -71,17 +91,18 @@ const exportHandler = (finish: 'completed' | 'interrupted' | 'wait') =>
})}\n\n`,
);
const body = new ReadableStream({
- async start(controller) {
- controller.enqueue(event(42));
+ start(controller) {
+ controller.enqueue(event(EXPORT_PROGRESS_BEFORE_COMPLETION));
if (finish === 'wait') {
return;
}
- await new Promise((resolve) => setTimeout(resolve, 1000));
- if (finish === 'completed') {
- controller.enqueue(event(100));
- }
- controller.enqueue(encoder.encode('event: complete\ndata: null\n\n'));
- controller.close();
+ completeExport.mockImplementationOnce(() => {
+ if (finish === 'completed') {
+ controller.enqueue(event(100));
+ }
+ controller.enqueue(encoder.encode('event: complete\ndata: null\n\n'));
+ controller.close();
+ });
},
});
return new HttpResponse(body, {
@@ -92,6 +113,15 @@ const exportHandler = (finish: 'completed' | 'interrupted' | 'wait') =>
const meta: Meta<typeof ExportExample> = {
title: 'Modules/RecordExport/Connection',
component: ExportExample,
+ args: {
+ shouldShowCompletionButton: true,
+ },
+ beforeEach: () => {
+ completeExport.mockReset();
+ return () => {
+ completeExport.mockReset();
+ };
+ },
};
export default meta;
type Story = StoryObj<typeof ExportExample>;
@@ -109,6 +139,9 @@ export const AutomaticDownload: Story = {
await canvas.findByText('42%');
expect(canvas.getByRole('button', { name: 'Export' })).toBeDisabled();
expect(download).not.toHaveBeenCalled();
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Finish export' }),
+ );
await waitFor(() => expect(download).toHaveBeenCalledTimes(1), {
timeout: 5000,
});
@@ -119,6 +152,16 @@ export const AutomaticDownload: Story = {
await waitFor(() =>
expect(canvas.getByRole('button', { name: 'Export' })).toBeEnabled(),
);
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Export' }));
+ await canvas.findByText('42%');
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Finish export' }),
+ );
+ await waitFor(() => expect(download).toHaveBeenCalledTimes(2));
+ await waitFor(() =>
+ expect(canvas.getByRole('button', { name: 'Export' })).toBeEnabled(),
+ );
} finally {
download.mockRestore();
}
@@ -130,6 +173,10 @@ export const Interrupted: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await userEvent.click(canvas.getByRole('button', { name: 'Export' }));
+ await canvas.findByText('42%');
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Finish export' }),
+ );
expect(
await canvas.findByRole('alert', {}, { timeout: 5000 }),
).toHaveTextContent('export was interrupted');
@@ -138,6 +185,7 @@ export const Interrupted: Story = {
};
export const Unmount: Story = {
+ args: { shouldShowCompletionButton: false },
parameters: { msw: { handlers: [exportHandler('wait')] } },
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
@@ -154,6 +202,7 @@ export const Unmount: Story = {
};
export const PageHide: Story = {
+ args: { shouldShowCompletionButton: false },
parameters: { msw: { handlers: [exportHandler('wait')] } },
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
diff --git a/packages/twenty-front/src/modules/settings/developers/components/__stories__/GraphQLPlayground.stories.tsx b/packages/twenty-front/src/modules/settings/developers/components/__stories__/GraphQLPlayground.stories.tsx
index fdbe754eea7..4b5ff057808 100644
--- a/packages/twenty-front/src/modules/settings/developers/components/__stories__/GraphQLPlayground.stories.tsx
+++ b/packages/twenty-front/src/modules/settings/developers/components/__stories__/GraphQLPlayground.stories.tsx
@@ -1,3 +1,4 @@
+import { getMockedDateWithOffset } from '~/testing/utils/getMockedDateWithOffset';
import { GraphQLPlayground } from '@/settings/developers/components/GraphQLPlayground';
import { playgroundApiKeyState } from '@/settings/developers/states/playgroundApiKeyState';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
@@ -15,7 +16,7 @@ const PlaygroundApiKeySetterEffect = () => {
useEffect(() => {
setPlaygroundApiKey({
token: 'test-api-key-123',
- expiresAt: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
+ expiresAt: getMockedDateWithOffset({ hours: 1 }),
});
}, [setPlaygroundApiKey]);
diff --git a/packages/twenty-front/src/modules/settings/developers/components/__stories__/RestPlayground.stories.tsx b/packages/twenty-front/src/modules/settings/developers/components/__stories__/RestPlayground.stories.tsx
index 98d489012a9..14916c2a1f6 100644
--- a/packages/twenty-front/src/modules/settings/developers/components/__stories__/RestPlayground.stories.tsx
+++ b/packages/twenty-front/src/modules/settings/developers/components/__stories__/RestPlayground.stories.tsx
@@ -1,3 +1,4 @@
+import { getMockedDateWithOffset } from '~/testing/utils/getMockedDateWithOffset';
import { RestPlayground } from '@/settings/developers/components/RestPlayground';
import { playgroundApiKeyState } from '@/settings/developers/states/playgroundApiKeyState';
import { PlaygroundSchemas } from '@/settings/developers/types/PlaygroundSchemas';
@@ -14,7 +15,7 @@ const PlaygroundApiKeySetterEffect = () => {
useEffect(() => {
setPlaygroundApiKey({
token: 'test-api-key-123',
- expiresAt: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
+ expiresAt: getMockedDateWithOffset({ hours: 1 }),
});
}, [setPlaygroundApiKey]);
diff --git a/packages/twenty-front/src/modules/settings/developers/components/__stories__/SettingsApiKeysFieldItemTableRow.stories.tsx b/packages/twenty-front/src/modules/settings/developers/components/__stories__/SettingsApiKeysFieldItemTableRow.stories.tsx
index ccfc992aef3..d868746ec6c 100644
--- a/packages/twenty-front/src/modules/settings/developers/components/__stories__/SettingsApiKeysFieldItemTableRow.stories.tsx
+++ b/packages/twenty-front/src/modules/settings/developers/components/__stories__/SettingsApiKeysFieldItemTableRow.stories.tsx
@@ -1,3 +1,4 @@
+import { getMockedDateWithOffset } from '~/testing/utils/getMockedDateWithOffset';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { SettingsApiKeysFieldItemTableRow } from '@/settings/developers/components/SettingsApiKeysFieldItemTableRow';
@@ -12,7 +13,7 @@ const meta: Meta<typeof SettingsApiKeysFieldItemTableRow> = {
apiKey: {
id: '3f4a42e8-b81f-4f8c-9c20-1602e6b34791',
name: 'Zapier Api Key',
- expiresAt: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000).toISOString(), // 3 days from now
+ expiresAt: getMockedDateWithOffset({ days: 3 }),
revokedAt: null,
role: {
id: '1',
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/__stories__/ActorDisplay.stories.tsx b/packages/twenty-front/src/modules/ui/field/display/components/__stories__/ActorDisplay.stories.tsx
index e3f5b9e57bf..02f796f84e9 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/__stories__/ActorDisplay.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/__stories__/ActorDisplay.stories.tsx
@@ -3,7 +3,7 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
import { ActorDisplay } from '@/ui/field/display/components/ActorDisplay';
-import { CatalogDecorator } from 'twenty-ui/testing';
+import { AVATAR_URL_MOCK, CatalogDecorator } from 'twenty-ui/testing';
const meta: Meta = {
title: 'UI/Display/ActorDisplay',
@@ -47,7 +47,7 @@ export const Catalog: Story = {
},
{
name: 'avatarUrl',
- values: [null, 'https://picsum.photos/id/237/16/16'],
+ values: [null, AVATAR_URL_MOCK],
props: (avatarUrl: string) => ({ avatarUrl }),
},
],
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/__stories__/FileChip.stories.tsx b/packages/twenty-front/src/modules/ui/field/display/components/__stories__/FileChip.stories.tsx
index 3e568507b32..8e239134d17 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/__stories__/FileChip.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/__stories__/FileChip.stories.tsx
@@ -1,5 +1,5 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { expect, fireEvent, fn, waitFor, within } from 'storybook/test';
+import { expect, fn, waitFor, within } from 'storybook/test';
import { FILE_CATEGORIES } from 'twenty-shared/types';
import { ComponentDecorator } from 'twenty-ui/testing';
@@ -8,7 +8,7 @@ import { FileChip } from '@/ui/field/display/components/FileChip';
const IMAGE_DATA_URI =
'data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2216%22 height=%2216%22 viewBox=%220 0 16 16%22%3E%3Crect width=%2216%22 height=%2216%22 fill=%22%231D4ED8%22/%3E%3Ccircle cx=%228%22 cy=%228%22 r=%224%22 fill=%22%23FFFFFF%22/%3E%3C/svg%3E';
-const BROKEN_IMAGE_URL = 'https://example.invalid/missing-thumbnail.png';
+const BROKEN_IMAGE_URL = 'data:image/png;base64,invalid-image';
const meta: Meta<typeof FileChip> = {
title: 'UI/Field/Display/FileChip',
@@ -99,12 +99,9 @@ export const BrokenImageThumbnailFallback: Story = {
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const thumbnail = getThumbnail(canvasElement);
expect(await canvas.findByText('Expired image.png')).toBeVisible();
- fireEvent.error(thumbnail);
-
await waitFor(() => {
expect(canvasElement.querySelector('img')).toBeNull();
expect(canvasElement.querySelector('svg')).not.toBeNull();
diff --git a/packages/twenty-front/src/modules/ui/layout/dialog/components/__stories__/ConfirmationDialog.stories.tsx b/packages/twenty-front/src/modules/ui/layout/dialog/components/__stories__/ConfirmationDialog.stories.tsx
index 1dc148e9755..66eeca14d2e 100644
--- a/packages/twenty-front/src/modules/ui/layout/dialog/components/__stories__/ConfirmationDialog.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/dialog/components/__stories__/ConfirmationDialog.stories.tsx
@@ -12,7 +12,6 @@ import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentTyp
import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
import { ComponentDecorator } from 'twenty-ui/testing';
import { RootDecorator } from '~/testing/decorators/RootDecorator';
-import { sleep } from '~/utils/sleep';
const JotaiInitDecorator: Decorator = (Story) => {
jotaiStore.set(
@@ -49,9 +48,6 @@ export default meta;
type Story = StoryObj<typeof ConfirmationDialog>;
-const closeMock = fn();
-const confirmMock = fn();
-
export const Default: Story = {
args: {
dialogId: 'confirmation-modal',
@@ -137,19 +133,17 @@ export const CloseOnEscape: Story = {
title: 'Escape Key Test',
subtitle: 'This modal should close when pressing the Escape key.',
confirmButtonText: 'Confirm',
- onClose: closeMock,
+ onClose: fn(),
},
- play: async ({ canvasElement }) => {
+ play: async ({ canvasElement, args }) => {
const body = within(canvasElement.ownerDocument.body);
await body.findByText('Escape Key Test');
- closeMock.mockClear();
-
await userEvent.keyboard('{Escape}');
await waitFor(() => {
- expect(closeMock).toHaveBeenCalledTimes(1);
+ expect(args.onClose).toHaveBeenCalledTimes(1);
});
},
};
@@ -160,22 +154,23 @@ export const CloseOnClickOutside: Story = {
title: 'Click Outside Test',
subtitle: 'This modal should close when clicking outside of it.',
confirmButtonText: 'Confirm',
- onClose: closeMock,
+ onClose: fn(),
},
- play: async ({ canvasElement }) => {
+ play: async ({ canvasElement, args }) => {
const body = within(canvasElement.ownerDocument.body);
await body.findByText('Click Outside Test');
const backdrop = await body.findByTestId('dialog-viewport');
- // We need to wait for the outside click listener to be registered
- await sleep(100);
+ await waitFor(() =>
+ expect(body.getByRole('button', { name: 'Cancel' })).toHaveFocus(),
+ );
await userEvent.click(backdrop);
await waitFor(() => {
- expect(closeMock).toHaveBeenCalledTimes(1);
+ expect(args.onClose).toHaveBeenCalledTimes(1);
});
},
};
@@ -186,9 +181,9 @@ export const ConfirmWithEnterKey: Story = {
title: 'Enter Key Test',
subtitle: 'This modal should confirm when pressing the Enter key.',
confirmButtonText: 'Confirm',
- onConfirmClick: confirmMock,
+ onConfirmClick: fn(),
},
- play: async ({ canvasElement }) => {
+ play: async ({ canvasElement, args }) => {
const body = within(canvasElement.ownerDocument.body);
await body.findByText('Enter Key Test');
@@ -196,7 +191,7 @@ export const ConfirmWithEnterKey: Story = {
await userEvent.keyboard('{Enter}');
await waitFor(() => {
- expect(confirmMock).toHaveBeenCalledTimes(1);
+ expect(args.onConfirmClick).toHaveBeenCalledTimes(1);
});
},
};
@@ -207,9 +202,9 @@ export const CancelButtonClick: Story = {
title: 'Cancel Button Test',
subtitle: 'Clicking the cancel button should close the modal',
confirmButtonText: 'Confirm',
- onClose: closeMock,
+ onClose: fn(),
},
- play: async ({ canvasElement }) => {
+ play: async ({ canvasElement, args }) => {
const body = within(canvasElement.ownerDocument.body);
await body.findByText('Cancel Button Test');
@@ -220,7 +215,7 @@ export const CancelButtonClick: Story = {
await userEvent.click(cancelButton);
await waitFor(() => {
- expect(closeMock).toHaveBeenCalledTimes(1);
+ expect(args.onClose).toHaveBeenCalledTimes(1);
});
},
};
@@ -231,9 +226,9 @@ export const ConfirmButtonClick: Story = {
title: 'Confirm Button Test',
subtitle: 'Clicking the confirm button should trigger the confirm action',
confirmButtonText: 'Confirm',
- onConfirmClick: confirmMock,
+ onConfirmClick: fn(),
},
- play: async ({ canvasElement }) => {
+ play: async ({ canvasElement, args }) => {
const body = within(canvasElement.ownerDocument.body);
await body.findByText('Confirm Button Test');
@@ -245,7 +240,7 @@ export const ConfirmButtonClick: Story = {
await userEvent.click(confirmButton);
await waitFor(() => {
- expect(confirmMock).toHaveBeenCalledTimes(1);
+ expect(args.onConfirmClick).toHaveBeenCalledTimes(1);
});
},
};
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/components/__stories__/Dropdown.stories.tsx b/packages/twenty-front/src/modules/ui/layout/dropdown/components/__stories__/Dropdown.stories.tsx
index c3075dbaaa3..7dad270b7ac 100644
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/components/__stories__/Dropdown.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/components/__stories__/Dropdown.stories.tsx
@@ -162,39 +162,30 @@ export const InterfaceScale: Story = {
},
};
-const avatarUrl =
- 'https://s3-alpha-sig.figma.com/img/bbb5/4905/f0a52cc2b9aaeb0a82a360d478dae8bf?Expires=1687132800&Signature=iVBr0BADa3LHoFVGbwqO-wxC51n1o~ZyFD-w7nyTyFP4yB-Y6zFawL-igewaFf6PrlumCyMJThDLAAc-s-Cu35SBL8BjzLQ6HymzCXbrblUADMB208PnMAvc1EEUDq8TyryFjRO~GggLBk5yR0EXzZ3zenqnDEGEoQZR~TRqS~uDF-GwQB3eX~VdnuiU2iittWJkajIDmZtpN3yWtl4H630A3opQvBnVHZjXAL5YPkdh87-a-H~6FusWvvfJxfNC2ZzbrARzXofo8dUFtH7zUXGCC~eUk~hIuLbLuz024lFQOjiWq2VKyB7dQQuGFpM-OZQEV8tSfkViP8uzDLTaCg__&Key-Pair-Id=APKAQ4GOSFWCVNEHN3O4';
-
const optionsMock = [
{
id: '1',
name: 'Company A',
- avatarUrl,
},
{
id: '2',
name: 'Company B',
- avatarUrl,
},
{
id: '3',
name: 'Company C',
- avatarUrl,
},
{
id: '4',
name: 'Person 2',
- avatarUrl,
},
{
id: '5',
name: 'Company D',
- avatarUrl,
},
{
id: '6',
name: 'Person 1',
- avatarUrl,
},
];
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx
index cd77f0152ae..4a7df7823b6 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx
@@ -37,7 +37,7 @@ const tabs = [
{
id: 'activity',
title: 'Activity',
- logo: 'https://twenty-front-screenshots.s3.eu-west-3.amazonaws.com/server-icon.png',
+ logo: AVATAR_URL_MOCK,
disabled: true,
},
{ id: 'favorites', title: 'Favorites', Icon: IconHeart },
diff --git a/packages/twenty-front/src/modules/workflow/components/__stories__/WorkflowStepExecutionResult.stories.tsx b/packages/twenty-front/src/modules/workflow/components/__stories__/WorkflowStepExecutionResult.stories.tsx
index 21333f4384b..9175151efd3 100644
--- a/packages/twenty-front/src/modules/workflow/components/__stories__/WorkflowStepExecutionResult.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/components/__stories__/WorkflowStepExecutionResult.stories.tsx
@@ -1,3 +1,4 @@
+import { MOCKED_DATE } from '~/testing/constants/MockedDate';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { ComponentDecorator } from 'twenty-ui/testing';
@@ -132,8 +133,8 @@ export const LargeResult: Story = {
email: `user${i + 1}@example.com`,
active: i % 2 === 0,
metadata: {
- createdAt: new Date().toISOString(),
- lastLogin: new Date().toISOString(),
+ createdAt: MOCKED_DATE,
+ lastLogin: MOCKED_DATE,
permissions: ['read', 'write'],
},
})),
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/__stories__/HttpRequestExecutionResult.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/__stories__/HttpRequestExecutionResult.stories.tsx
index 75a6a46a712..622da049caf 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/__stories__/HttpRequestExecutionResult.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/__stories__/HttpRequestExecutionResult.stories.tsx
@@ -314,8 +314,10 @@ export const LargeResponse: Story = {
],
},
metadata: {
- createdAt: new Date(2023, 0, 1 + i).toISOString(),
- lastLogin: new Date(2023, 11, 1 + (i % 30)).toISOString(),
+ createdAt: new Date(Date.UTC(2023, 0, 1 + i)).toISOString(),
+ lastLogin: new Date(
+ Date.UTC(2023, 11, 1 + (i % 30)),
+ ).toISOString(),
permissions: ['read', 'write', 'admin'].slice(0, (i % 3) + 1),
},
})),
diff --git a/packages/twenty-front/src/pages/settings/__stories__/SettingsBilling.stories.tsx b/packages/twenty-front/src/pages/settings/__stories__/SettingsBilling.stories.tsx
index a7c595502a3..e43458d1c05 100644
--- a/packages/twenty-front/src/pages/settings/__stories__/SettingsBilling.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/__stories__/SettingsBilling.stories.tsx
@@ -7,7 +7,6 @@ import {
type PageDecoratorArgs,
} from '~/testing/decorators/PageDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
-import { sleep } from '~/utils/sleep';
import { getSettingsPath } from 'twenty-shared/utils';
@@ -32,14 +31,8 @@ export const Default: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- await sleep(1000);
-
- const buttons = await canvas.findAllByRole('button');
-
- expect(
- buttons.findIndex((button) =>
- button.outerHTML.includes('View billing details'),
- ),
- ).toBeGreaterThan(-1);
+ await expect(
+ await canvas.findByRole('button', { name: 'View billing details' }),
+ ).toBeVisible();
},
};
diff --git a/packages/twenty-front/src/pages/settings/__stories__/SettingsExperience.stories.tsx b/packages/twenty-front/src/pages/settings/__stories__/SettingsExperience.stories.tsx
index c3154994b2b..98bb45f6db0 100644
--- a/packages/twenty-front/src/pages/settings/__stories__/SettingsExperience.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/__stories__/SettingsExperience.stories.tsx
@@ -16,7 +16,7 @@ const meta: Meta<PageDecoratorArgs> = {
args: { routePath: '/settings/experience' },
parameters: {
msw: graphqlMocks,
- date: new Date(2021, 1, 1),
+ date: new Date('2021-02-01T00:00:00.000Z'),
},
};
diff --git a/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectDetail.stories.tsx b/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectDetail.stories.tsx
index 52b357ccb7b..c4463e54954 100644
--- a/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectDetail.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectDetail.stories.tsx
@@ -6,7 +6,6 @@ import {
type PageDecoratorArgs,
} from '~/testing/decorators/PageDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
-import { sleep } from '~/utils/sleep';
import { SettingsObjectDetailPage } from '~/pages/settings/data-model/SettingsObjectDetailPage';
@@ -28,8 +27,10 @@ export default meta;
export type Story = StoryObj<typeof SettingsObjectDetailPage>;
export const StandardObject: Story = {
- play: async () => {
- await sleep(100);
+ play: async ({ canvasElement }) => {
+ await expect(
+ await within(canvasElement).findByTestId('tab-fields'),
+ ).toBeVisible();
},
};
diff --git a/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectNewField/SettingsObjectNewFieldConfigure.stories.tsx b/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectNewField/SettingsObjectNewFieldConfigure.stories.tsx
index b78bba369a9..c150530408d 100644
--- a/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectNewField/SettingsObjectNewFieldConfigure.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectNewField/SettingsObjectNewFieldConfigure.stories.tsx
@@ -1,5 +1,6 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { userEvent, within } from 'storybook/test';
+import { graphql, HttpResponse } from 'msw';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
import { SettingsObjectNewFieldConfigure } from '~/pages/settings/data-model/new-field/SettingsObjectNewFieldConfigure';
import {
@@ -7,6 +8,13 @@ import {
type PageDecoratorArgs,
} from '~/testing/decorators/PageDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
+import {
+ type CreateOneFieldMetadataItemMutation,
+ type CreateOneFieldMetadataItemMutationVariables,
+ MetadataWritability,
+} from '~/generated-metadata/graphql';
+import { getMockFieldMetadataItemOrThrow } from '~/testing/utils/getMockFieldMetadataItemOrThrow';
+import { getMockObjectMetadataItemOrThrow } from '~/testing/utils/getMockObjectMetadataItemOrThrow';
const meta: Meta<PageDecoratorArgs> = {
title:
@@ -16,9 +24,42 @@ const meta: Meta<PageDecoratorArgs> = {
args: {
routePath: '/settings/objects/:objectNamePlural/new-field/configure',
routeParams: { ':objectNamePlural': 'companies' },
+ additionalRoutes: ['/settings/objects/companies'],
},
parameters: {
- msw: graphqlMocks,
+ msw: {
+ handlers: [
+ graphql.mutation<
+ CreateOneFieldMetadataItemMutation,
+ CreateOneFieldMetadataItemMutationVariables
+ >('CreateOneFieldMetadataItem', ({ variables }) => {
+ const fieldMetadataItem = getMockFieldMetadataItemOrThrow({
+ objectMetadataItem: getMockObjectMetadataItemOrThrow('company'),
+ fieldName: 'name',
+ });
+
+ return HttpResponse.json({
+ data: {
+ createOneField: {
+ ...fieldMetadataItem,
+ ...variables.input.field,
+ __typename: 'Field',
+ id: '20202020-0000-4000-8000-000000000001',
+ applicationId: fieldMetadataItem.applicationId ?? '',
+ writability: MetadataWritability.OPEN,
+ object: {
+ __typename: 'Object',
+ id: variables.input.field.objectMetadataId,
+ },
+ relation: null,
+ morphRelations: null,
+ },
+ },
+ });
+ }),
+ ...graphqlMocks.handlers,
+ ],
+ },
},
};
@@ -35,8 +76,12 @@ export const Default: Story = {
const employeeInput = await canvas.findByPlaceholderText('Employees');
await userEvent.type(employeeInput, 'Test');
- const saveButton = await canvas.findByText('Save');
- await new Promise((resolve) => setTimeout(resolve, 5000));
+ const saveButton = await canvas.findByRole('button', { name: 'Save' });
+ await userEvent.tab();
+ await waitFor(() => expect(saveButton).toBeEnabled());
await userEvent.click(saveButton);
+ await expect(
+ await canvas.findByText('Navigated to /settings/objects/companies'),
+ ).toBeVisible();
},
};
diff --git a/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectNewField/SettingsObjectNewFieldSelect.stories.tsx b/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectNewField/SettingsObjectNewFieldSelect.stories.tsx
index a6bd625f583..c6f8d864353 100644
--- a/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectNewField/SettingsObjectNewFieldSelect.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/data-model/__stories__/SettingsObjectNewField/SettingsObjectNewFieldSelect.stories.tsx
@@ -1,5 +1,5 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { userEvent, within } from 'storybook/test';
+import { expect, userEvent, within } from 'storybook/test';
import { SettingsObjectNewFieldSelect } from '~/pages/settings/data-model/new-field/SettingsObjectNewFieldSelect';
import {
@@ -33,9 +33,13 @@ export const Default: Story = {
await canvas.findByText('1. Select a field type');
const searchInput = await canvas.findByPlaceholderText('Search a type');
await userEvent.type(searchInput, 'Rela');
- await new Promise((resolve) => setTimeout(resolve, 1500));
+ await expect(
+ await canvas.findByRole('link', { name: 'Relation' }),
+ ).toBeVisible();
await userEvent.clear(searchInput);
await userEvent.type(searchInput, 'Num');
- await new Promise((resolve) => setTimeout(resolve, 1500));
+ await expect(
+ await canvas.findByRole('link', { name: 'Number' }),
+ ).toBeVisible();
},
};
diff --git a/packages/twenty-front/src/pages/settings/developers/__stories__/playground/SettingsGraphQLPlayground.stories.tsx b/packages/twenty-front/src/pages/settings/developers/__stories__/playground/SettingsGraphQLPlayground.stories.tsx
index 10c9d1a53bd..ec8057409e4 100644
--- a/packages/twenty-front/src/pages/settings/developers/__stories__/playground/SettingsGraphQLPlayground.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/developers/__stories__/playground/SettingsGraphQLPlayground.stories.tsx
@@ -1,3 +1,4 @@
+import { getMockedDateWithOffset } from '~/testing/utils/getMockedDateWithOffset';
import { playgroundApiKeyState } from '@/settings/developers/states/playgroundApiKeyState';
import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
import { type Meta, type StoryObj } from '@storybook/react-vite';
@@ -20,7 +21,7 @@ const meta: Meta<typeof SettingsGraphQLPlayground> = {
(Story) => {
jotaiStore.set(playgroundApiKeyState.atom, {
token: 'test-api-key',
- expiresAt: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
+ expiresAt: getMockedDateWithOffset({ hours: 1 }),
});
return <Story />;
},
diff --git a/packages/twenty-front/src/pages/settings/developers/__stories__/playground/SettingsRestPlayground.stories.tsx b/packages/twenty-front/src/pages/settings/developers/__stories__/playground/SettingsRestPlayground.stories.tsx
index 8d55e0a1cd7..872014c56a9 100644
--- a/packages/twenty-front/src/pages/settings/developers/__stories__/playground/SettingsRestPlayground.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/developers/__stories__/playground/SettingsRestPlayground.stories.tsx
@@ -1,3 +1,4 @@
+import { getMockedDateWithOffset } from '~/testing/utils/getMockedDateWithOffset';
import { playgroundApiKeyState } from '@/settings/developers/states/playgroundApiKeyState';
import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
import { type Meta, type StoryObj } from '@storybook/react-vite';
@@ -19,7 +20,7 @@ const meta: Meta<typeof SettingsRestPlayground> = {
(Story) => {
jotaiStore.set(playgroundApiKeyState.atom, {
token: 'test-api-key',
- expiresAt: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
+ expiresAt: getMockedDateWithOffset({ hours: 1 }),
});
return <Story />;
},
diff --git a/packages/twenty-front/src/pages/settings/logic-functions/__stories__/SettingsLogicFunctionDetail.stories.tsx b/packages/twenty-front/src/pages/settings/logic-functions/__stories__/SettingsLogicFunctionDetail.stories.tsx
index 42931f70ed0..01935fbaa3e 100644
--- a/packages/twenty-front/src/pages/settings/logic-functions/__stories__/SettingsLogicFunctionDetail.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/logic-functions/__stories__/SettingsLogicFunctionDetail.stories.tsx
@@ -10,7 +10,6 @@ import {
type PageDecoratorArgs,
} from '~/testing/decorators/PageDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
-import { sleep } from '~/utils/sleep';
const SOURCE_CODE_FULL_PATH =
'logic-function/20202020-1c25-4d02-bf25-6aeccf7ea419/adb4bd21-7670-4c81-9f74-1fc196fe87ea/source.ts';
@@ -70,7 +69,6 @@ export type Story = StoryObj<typeof SettingsLogicFunctionDetail>;
export const Default: Story = {
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
const canvas = within(canvasElement);
- await sleep(100);
await canvas.findByText('Name and describe your function', undefined, {
timeout: 3000,
});
diff --git a/packages/twenty-front/src/testing/constants/MockedDate.ts b/packages/twenty-front/src/testing/constants/MockedDate.ts
new file mode 100644
index 00000000000..f3ead93ccdd
--- /dev/null
+++ b/packages/twenty-front/src/testing/constants/MockedDate.ts
@@ -0,0 +1 @@
+export const MOCKED_DATE = '2024-03-12T09:30:00.000Z';
diff --git a/packages/twenty-front/src/testing/graphqlMocks.ts b/packages/twenty-front/src/testing/graphqlMocks.ts
index ec43dda4be8..742e9a0ef65 100644
--- a/packages/twenty-front/src/testing/graphqlMocks.ts
+++ b/packages/twenty-front/src/testing/graphqlMocks.ts
@@ -1,3 +1,4 @@
+import { MOCKED_DATE } from '~/testing/constants/MockedDate';
import { parse, type FieldNode } from 'graphql';
import { graphql, http, HttpResponse, type GraphQLQuery } from 'msw';
import { getOperationName } from '~/utils/getOperationName';
@@ -648,7 +649,7 @@ export const graphqlMocks = {
id: variables.input?.id,
name: 'Zapier Integration',
expiresAt: '2100-11-06T23:59:59.825Z',
- revokedAt: new Date().toISOString(),
+ revokedAt: MOCKED_DATE,
role: {
__typename: 'Role',
id: '1',
diff --git a/packages/twenty-front/src/testing/mock-data/image-url.ts b/packages/twenty-front/src/testing/mock-data/image-url.ts
new file mode 100644
index 00000000000..3ebc7995971
--- /dev/null
+++ b/packages/twenty-front/src/testing/mock-data/image-url.ts
@@ -0,0 +1,3 @@
+export const IMAGE_URL_MOCK = `data:image/svg+xml,${encodeURIComponent(
+ '<svg xmlns="http://www.w3.org/2000/svg" width="800" height="480" viewBox="0 0 800 480"><rect width="800" height="480" fill="#f3f4f6"/><path d="M80 60v340h640" fill="none" stroke="#9ca3af" stroke-width="2"/><path d="M120 400V260h60v140zm100 0V220h60v180zm100 0V240h60v160zm100 0V160h60v240zm100 0V100h60v300zm100 0V130h60v270z" fill="#3b82f6"/></svg>',
+)}`;
diff --git a/packages/twenty-front/src/testing/mock-data/users.ts b/packages/twenty-front/src/testing/mock-data/users.ts
index 1cfa112fba8..3bf6bfb79c5 100644
--- a/packages/twenty-front/src/testing/mock-data/users.ts
+++ b/packages/twenty-front/src/testing/mock-data/users.ts
@@ -1,3 +1,4 @@
+import { getMockedDateWithOffset } from '~/testing/utils/getMockedDateWithOffset';
import { type CurrentUserWorkspace } from '@/auth/states/currentUserWorkspaceState';
import { CUSTOM_WORKSPACE_APPLICATION_MOCK } from '@/object-metadata/hooks/__tests__/constants/CustomWorkspaceApplicationMock.test.constant';
import { type WorkspaceMember } from '@/workspace-member/types/WorkspaceMember';
@@ -98,7 +99,7 @@ export const mockCurrentWorkspace = {
id: '7efbc3f7-6e5e-4128-957e-8d86808cdf6a',
interval: SubscriptionInterval.Month,
status: SubscriptionStatus.Active,
- currentPeriodEnd: new Date().toString(),
+ currentPeriodEnd: getMockedDateWithOffset({ months: 1 }),
metadata: {
plan: PRO_PLAN.planKey,
},
diff --git a/packages/twenty-front/src/testing/utils/getMockedDateWithOffset.ts b/packages/twenty-front/src/testing/utils/getMockedDateWithOffset.ts
new file mode 100644
index 00000000000..5e4946235d9
--- /dev/null
+++ b/packages/twenty-front/src/testing/utils/getMockedDateWithOffset.ts
@@ -0,0 +1,9 @@
+import { Temporal } from 'temporal-polyfill';
+import { MOCKED_DATE } from '~/testing/constants/MockedDate';
+
+export const getMockedDateWithOffset = (offset: Temporal.DurationLike) =>
+ Temporal.Instant.from(MOCKED_DATE)
+ .toZonedDateTimeISO('UTC')
+ .add(offset)
+ .toInstant()
+ .toString({ fractionalSecondDigits: 3 });
diff --git a/packages/twenty-ui/.storybook/preview.tsx b/packages/twenty-ui/.storybook/preview.tsx
index 9060b75aa1d..63faf7779f6 100644
--- a/packages/twenty-ui/.storybook/preview.tsx
+++ b/packages/twenty-ui/.storybook/preview.tsx
@@ -3,17 +3,20 @@ import '@fontsource/dm-mono/500.css';
import '@fontsource/inter/400.css';
import '@fontsource/inter/500.css';
import '@fontsource/inter/600.css';
+import '@fontsource/inter/700.css';
import { type Preview } from '@storybook/react-vite';
import '@ui/styles/base/reset.scss';
import '@ui/theme/theme-light.css';
import '@ui/theme/theme-dark.css';
import { ThemeProvider } from '@ui/theme';
+import { waitForStorybookFontsLoaded } from '@ui/testing';
import './setupMonacoEnvironment';
const preview: Preview = {
tags: ['autodocs'],
+ loaders: [waitForStorybookFontsLoaded],
parameters: {
a11y: {
test: 'error',
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index d72dc9a33f8..23fb3b4c7be 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -1198,7 +1198,8 @@
"ComponentDecorator": "testing/decorators/ComponentDecorator",
"ComponentStorybookLayout": "testing/ComponentStorybookLayout",
"GroupedCatalog": "testing/GroupedCatalog",
- "overrideMediaQueryMatches": "testing/utils/overrideMediaQueryMatches"
+ "overrideMediaQueryMatches": "testing/utils/overrideMediaQueryMatches",
+ "waitForStorybookFontsLoaded": "testing/utils/waitForStorybookFontsLoaded"
},
"types": {
"CatalogDimension": "testing/decorators/CatalogDecorator",
diff --git a/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__stories__/AnimatedIconCrossfade.stories.tsx b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__stories__/AnimatedIconCrossfade.stories.tsx
index 4b50243ef8b..2dd369caf8e 100644
--- a/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__stories__/AnimatedIconCrossfade.stories.tsx
+++ b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__stories__/AnimatedIconCrossfade.stories.tsx
@@ -48,8 +48,6 @@ export const AnimatedIcon: Story = {
const button = within(canvasElement).getByRole('button', {
name: 'Edit actions',
});
- await document.fonts.load('500 1em Inter');
- await document.fonts.ready;
const icons = button.querySelectorAll('svg');
const pencil = icons[0]!;
const cross = icons[1]!;
diff --git a/packages/twenty-ui/src/testing/index.ts b/packages/twenty-ui/src/testing/index.ts
index 3a5ad2a4416..809e773bfda 100644
--- a/packages/twenty-ui/src/testing/index.ts
+++ b/packages/twenty-ui/src/testing/index.ts
@@ -19,3 +19,4 @@ export { GroupedCatalog } from './GroupedCatalog';
export { AVATAR_URL_MOCK } from './mocks/avatarUrlMock';
export type { CatalogStory } from './types/CatalogStory';
export { overrideMediaQueryMatches } from './utils/overrideMediaQueryMatches';
+export { waitForStorybookFontsLoaded } from './utils/waitForStorybookFontsLoaded';
diff --git a/packages/twenty-ui/src/testing/utils/waitForStorybookFontsLoaded.ts b/packages/twenty-ui/src/testing/utils/waitForStorybookFontsLoaded.ts
new file mode 100644
index 00000000000..db3a1a6b46c
--- /dev/null
+++ b/packages/twenty-ui/src/testing/utils/waitForStorybookFontsLoaded.ts
@@ -0,0 +1,13 @@
+const STORYBOOK_FONTS = [
+ '400 1em Inter',
+ '500 1em Inter',
+ '600 1em Inter',
+ '700 1em Inter',
+ '400 1em "DM Mono"',
+ '500 1em "DM Mono"',
+];
+
+export const waitForStorybookFontsLoaded = async () => {
+ await Promise.all(STORYBOOK_FONTS.map((font) => document.fonts.load(font)));
+ await document.fonts.ready;
+};