diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/EmailsFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/EmailsFieldInput.tsx index aa3ef4376..604a8000f 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/EmailsFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/EmailsFieldInput.tsx @@ -45,7 +45,9 @@ export const EmailsFieldInput = ({ [], ); - const isPrimaryEmail = (index: number) => index === 0 && emails?.length > 1; + const getShowPrimaryIcon = (index: number) => + index === 0 && emails.length > 1; + const getShowSetAsPrimaryButton = (index: number) => index > 0; const setIsFieldInError = useSetRecoilComponentStateV2( recordFieldInputIsFieldInErrorComponentState, @@ -77,8 +79,8 @@ export const EmailsFieldInput = ({ index === 0 && phones?.length > 1; + const getShowPrimaryIcon = (index: number) => + index === 0 && phones.length > 1; + const getShowSetAsPrimaryButton = (index: number) => index > 0; return ( { - expect(updateRecord).toHaveBeenCalledWith({ - variables: { - where: { id: 'record-id' }, - updateOneRecordInput: { - emails: { - primaryEmail: 'primary@example.com', - additionalEmails: [], - }, - }, - }, - }); - }); - expect(updateRecord).toHaveBeenCalledTimes(1); + expect(setPrimaryOption).not.toBeInTheDocument(); }, }; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/PhonesFieldInput.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/PhonesFieldInput.stories.tsx index 60786a05a..59b9a1e4b 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/PhonesFieldInput.stories.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/PhonesFieldInput.stories.tsx @@ -1,6 +1,6 @@ import { expect } from '@storybook/jest'; import { Meta, StoryObj } from '@storybook/react'; -import { fn, userEvent, waitFor, within } from '@storybook/test'; +import { fn, userEvent, within } from '@storybook/test'; import { useEffect } from 'react'; import { getCanvasElementForDropdownTesting } from 'twenty-ui/testing'; @@ -141,7 +141,7 @@ export const Default: Story = { }; // FIXME: We will have to fix that behavior, we should only be able to set an additional phone as the primary phone -export const CanSetPrimaryLinkAsPrimaryLink: Story = { +export const CanNotSetPrimaryLinkAsPrimaryLink: Story = { args: { value: { primaryPhoneCountryCode: 'FR', @@ -163,30 +163,16 @@ export const CanSetPrimaryLinkAsPrimaryLink: Story = { }); await userEvent.click(openDropdownButtons[0]); - const setPrimaryOption = await within( + const editOption = await within( getCanvasElementForDropdownTesting(), - ).findByText('Set as Primary'); + ).findByText('Edit'); - expect(setPrimaryOption).toBeVisible(); + expect(editOption).toBeVisible(); - await userEvent.click(setPrimaryOption); + const setPrimaryOption = within( + getCanvasElementForDropdownTesting(), + ).queryByText('Set as Primary'); - // Verify the update was called with swapped phones - await waitFor(() => { - expect(updateRecord).toHaveBeenCalledWith({ - variables: { - where: { id: 'record-id' }, - updateOneRecordInput: { - phones: { - primaryPhoneCallingCode: '+33', - primaryPhoneCountryCode: 'FR', - primaryPhoneNumber: '642646272', - additionalPhones: [], - }, - }, - }, - }); - }); - expect(updateRecord).toHaveBeenCalledTimes(1); + expect(setPrimaryOption).not.toBeInTheDocument(); }, };