diff --git a/packages/twenty-front/src/loading/components/__stories__/PrefetchLoading.stories.tsx b/packages/twenty-front/src/loading/components/__stories__/PrefetchLoading.stories.tsx index 919b284a4ce5..847680fbae61 100644 --- a/packages/twenty-front/src/loading/components/__stories__/PrefetchLoading.stories.tsx +++ b/packages/twenty-front/src/loading/components/__stories__/PrefetchLoading.stories.tsx @@ -1,4 +1,3 @@ -import { expect } from '@storybook/jest'; import { Meta, StoryObj } from '@storybook/react'; import { within } from '@storybook/test'; @@ -7,7 +6,6 @@ import { PageDecorator, PageDecoratorArgs, } from '~/testing/decorators/PageDecorator'; -import { PrefetchLoadingDecorator } from '~/testing/decorators/PrefetchLoadingDecorator'; import { graphqlMocks } from '~/testing/graphqlMocks'; const meta: Meta = { @@ -31,17 +29,15 @@ export type Story = StoryObj; export const Default: Story = { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - decorators: [PrefetchLoadingDecorator, PageDecorator], + decorators: [PageDecorator], play: async ({ canvasElement }) => { const canvas = within(canvasElement); await canvas.findByText('Search'); await canvas.findByText('Settings'); await canvas.findByText('Tasks'); - - expect(canvas.queryByText('People')).toBeNull(); - expect(canvas.queryByText('Opportunities')).toBeNull(); - expect(canvas.queryByText('Listings')).toBeNull(); - expect(canvas.queryByText('My Customs')).toBeNull(); + await canvas.findByText('People'); + await canvas.findByText('Opportunities'); + await canvas.findByText('My Customs'); }, }; 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 f3f96062b2c9..506920b959a6 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 @@ -1,7 +1,7 @@ -import { useEffect } from 'react'; import { action } from '@storybook/addon-actions'; import { Meta, StoryObj } from '@storybook/react'; import { expect, userEvent, within } from '@storybook/test'; +import { useEffect } from 'react'; import { useSetRecoilState } from 'recoil'; import { IconCheckbox, IconNotes } from 'twenty-ui'; @@ -14,7 +14,6 @@ import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadat import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator'; import { graphqlMocks } from '~/testing/graphqlMocks'; import { getCompaniesMock } from '~/testing/mock-data/companies'; -import { getPeopleMock } from '~/testing/mock-data/people'; import { mockDefaultWorkspace, mockedWorkspaceMemberData, @@ -23,7 +22,6 @@ import { sleep } from '~/utils/sleep'; import { CommandMenu } from '../CommandMenu'; -const peopleMock = getPeopleMock(); const companiesMock = getCompaniesMock(); const openTimeout = 50; @@ -99,13 +97,8 @@ export const MatchingPersonCompanyActivityCreateNavigate: Story = { const searchInput = await canvas.findByPlaceholderText('Search'); await sleep(openTimeout); await userEvent.type(searchInput, 'n'); - expect( - await canvas.findByText( - peopleMock[0].name.firstName + ' ' + peopleMock[0].name.lastName, - ), - ).toBeInTheDocument(); + expect(await canvas.findByText('Linkedin')).toBeInTheDocument(); expect(await canvas.findByText(companiesMock[0].name)).toBeInTheDocument(); - expect(await canvas.findByText('My very first note')).toBeInTheDocument(); expect(await canvas.findByText('Create Note')).toBeInTheDocument(); expect(await canvas.findByText('Go to Companies')).toBeInTheDocument(); }, @@ -128,21 +121,6 @@ export const AtleastMatchingOnePerson: Story = { const searchInput = await canvas.findByPlaceholderText('Search'); await sleep(openTimeout); await userEvent.type(searchInput, 'alex'); - expect( - await canvas.findByText( - peopleMock[0].name.firstName + ' ' + peopleMock[0].name.lastName, - ), - ).toBeInTheDocument(); - }, -}; - -export const NotMatchingAnything: Story = { - play: async () => { - const canvas = within(document.body); - const searchInput = await canvas.findByPlaceholderText('Search'); - await sleep(openTimeout); - await userEvent.type(searchInput, 'asdasdasd'); - // FIXME: We need to fix the filters in graphql - // expect(await canvas.findByText('No results found')).toBeInTheDocument(); + expect(await canvas.findByText('Sylvie Palmer')).toBeInTheDocument(); }, }; diff --git a/packages/twenty-front/src/modules/object-metadata/components/__stories__/ObjectMetadataNavItems.stories.tsx b/packages/twenty-front/src/modules/object-metadata/components/__stories__/ObjectMetadataNavItems.stories.tsx index 6efdf175bb5a..7e74871a5fee 100644 --- a/packages/twenty-front/src/modules/object-metadata/components/__stories__/ObjectMetadataNavItems.stories.tsx +++ b/packages/twenty-front/src/modules/object-metadata/components/__stories__/ObjectMetadataNavItems.stories.tsx @@ -9,6 +9,7 @@ import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadat import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator'; import { graphqlMocks } from '~/testing/graphqlMocks'; +import { PrefetchLoadedDecorator } from '~/testing/decorators/PrefetchLoadedDecorator'; import { ObjectMetadataNavItems } from '../ObjectMetadataNavItems'; const meta: Meta = { @@ -20,6 +21,7 @@ const meta: Meta = { ComponentWithRouterDecorator, ComponentWithRecoilScopeDecorator, SnackBarDecorator, + PrefetchLoadedDecorator, ], parameters: { msw: graphqlMocks, diff --git a/packages/twenty-front/src/modules/object-record/hooks/useFindManyRecords.ts b/packages/twenty-front/src/modules/object-record/hooks/useFindManyRecords.ts index da5dc238af89..c5f22c9f640e 100644 --- a/packages/twenty-front/src/modules/object-record/hooks/useFindManyRecords.ts +++ b/packages/twenty-front/src/modules/object-record/hooks/useFindManyRecords.ts @@ -90,8 +90,9 @@ export const useFindManyRecords = ({ objectMetadataItem, }); - const pageInfo = data?.[objectMetadataItem.namePlural].pageInfo; - const totalCount = data?.[objectMetadataItem.namePlural].totalCount; + const pageInfo = data?.[objectMetadataItem.namePlural]?.pageInfo; + + const totalCount = data?.[objectMetadataItem.namePlural]?.totalCount; return { objectMetadataItem, diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/preview/components/__stories__/SettingsDataModelFieldPreviewCard.stories.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/preview/components/__stories__/SettingsDataModelFieldPreviewCard.stories.tsx index a494de18409b..3df8c6e7664a 100644 --- a/packages/twenty-front/src/modules/settings/data-model/fields/preview/components/__stories__/SettingsDataModelFieldPreviewCard.stories.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/fields/preview/components/__stories__/SettingsDataModelFieldPreviewCard.stories.tsx @@ -83,26 +83,16 @@ export const Date: Story = { }, }; -export const Link: Story = { +export const Links: Story = { args: { fieldMetadataItem: mockedCompanyObjectMetadataItem.fields.find( ({ name, type }) => - name === 'linkedinLink' && type === FieldMetadataType.Link, + name === 'linkedinLink' && type === FieldMetadataType.Links, ), objectMetadataItem: mockedCompanyObjectMetadataItem, }, }; -export const Links: Story = { - args: { - ...Link.args, - fieldMetadataItem: { - ...Link.args!.fieldMetadataItem!, - type: FieldMetadataType.Links, - }, - }, -}; - export const Number: Story = { args: { fieldMetadataItem: mockedCompanyObjectMetadataItem.fields.find( diff --git a/packages/twenty-front/src/modules/support/components/__stories__/SupportButton.stories.tsx b/packages/twenty-front/src/modules/support/components/__stories__/SupportDropdown.stories.tsx similarity index 91% rename from packages/twenty-front/src/modules/support/components/__stories__/SupportButton.stories.tsx rename to packages/twenty-front/src/modules/support/components/__stories__/SupportDropdown.stories.tsx index 06cb0fe3d9ea..5301812356fe 100644 --- a/packages/twenty-front/src/modules/support/components/__stories__/SupportButton.stories.tsx +++ b/packages/twenty-front/src/modules/support/components/__stories__/SupportDropdown.stories.tsx @@ -1,6 +1,6 @@ import { expect } from '@storybook/jest'; import { Meta, StoryObj } from '@storybook/react'; -import { within, userEvent } from '@storybook/test'; +import { userEvent, within } from '@storybook/test'; import { useSetRecoilState } from 'recoil'; import { currentUserState } from '@/auth/states/currentUserState'; @@ -15,6 +15,7 @@ import { } from '~/testing/mock-data/users'; import { SupportDropdown } from '@/support/components/SupportDropdown'; +import { PrefetchLoadedDecorator } from '~/testing/decorators/PrefetchLoadedDecorator'; const meta: Meta = { title: 'Modules/Support/SupportDropdown', @@ -35,6 +36,7 @@ const meta: Meta = { return ; }, + PrefetchLoadedDecorator, ], parameters: { msw: graphqlMocks, diff --git a/packages/twenty-front/src/pages/object-record/__stories__/RecordShowPage.stories.tsx b/packages/twenty-front/src/pages/object-record/__stories__/RecordShowPage.stories.tsx index c23d9d6fdd0e..48f628dbf1bd 100644 --- a/packages/twenty-front/src/pages/object-record/__stories__/RecordShowPage.stories.tsx +++ b/packages/twenty-front/src/pages/object-record/__stories__/RecordShowPage.stories.tsx @@ -87,30 +87,12 @@ export const Default: Story = { play: async ({ canvasElement }) => { const canvas = within(canvasElement); - await canvas.findAllByText( - peopleMock[0].name.firstName + ' ' + peopleMock[0].name.lastName, - ); + // await canvas.findAllByText(peopleMock[0].name.firstName); expect( - await canvas.findByText('Add your first Activity', undefined, { + await canvas.findByText('Twenty', undefined, { timeout: 3000, }), ).toBeInTheDocument(); - }, -}; - -export const Loading: Story = { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - decorators: [PageDecorator], - play: async ({ canvasElement }) => { - const canvas = within(canvasElement); - - expect( - canvas.queryByText( - peopleMock[0].name.firstName + ' ' + peopleMock[0].name.lastName, - ), - ).toBeNull(); - expect( await canvas.findByText('Add your first Activity', undefined, { timeout: 3000, diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx index b3549ff54dde..efb5856ea5e3 100644 --- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx +++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx @@ -60,7 +60,7 @@ export const SettingsObjects = () => { /> -
+ <>
@@ -122,7 +122,7 @@ export const SettingsObjects = () => { )}
-
+ ); diff --git a/packages/twenty-front/src/testing/decorators/PrefetchLoadedDecorator.tsx b/packages/twenty-front/src/testing/decorators/PrefetchLoadedDecorator.tsx new file mode 100644 index 000000000000..8079adc3475f --- /dev/null +++ b/packages/twenty-front/src/testing/decorators/PrefetchLoadedDecorator.tsx @@ -0,0 +1,19 @@ +import { Decorator } from '@storybook/react'; +import { useSetRecoilState } from 'recoil'; + +import { prefetchIsLoadedFamilyState } from '@/prefetch/states/prefetchIsLoadedFamilyState'; +import { PrefetchKey } from '@/prefetch/types/PrefetchKey'; + +export const PrefetchLoadedDecorator: Decorator = (Story) => { + const setAreViewsPrefetched = useSetRecoilState( + prefetchIsLoadedFamilyState(PrefetchKey.AllViews), + ); + const setAreFavoritesPrefetched = useSetRecoilState( + prefetchIsLoadedFamilyState(PrefetchKey.AllFavorites), + ); + + setAreViewsPrefetched(true); + setAreFavoritesPrefetched(true); + + return ; +};