diff --git a/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormPhoneFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormPhoneFieldInput.tsx index 86f34a2f3..16ce72255 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormPhoneFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormPhoneFieldInput.tsx @@ -38,14 +38,14 @@ export const FormPhoneFieldInput = ({ onPersist({ primaryPhoneCountryCode: newCountry, primaryPhoneCallingCode: newCallingCode, - primaryPhoneNumber: defaultValue?.primaryPhoneNumber || '', + primaryPhoneNumber: defaultValue?.primaryPhoneNumber ?? '', }); }; const handleNumberChange = (number: string | number | null) => { onPersist({ - primaryPhoneCountryCode: defaultValue?.primaryPhoneCountryCode || '', - primaryPhoneCallingCode: defaultValue?.primaryPhoneCallingCode || '', + primaryPhoneCountryCode: defaultValue?.primaryPhoneCountryCode ?? '', + primaryPhoneCallingCode: defaultValue?.primaryPhoneCallingCode ?? '', primaryPhoneNumber: number ? `${number}` : '', }); }; @@ -58,7 +58,6 @@ export const FormPhoneFieldInput = ({ selectedCountryCode={defaultValue?.primaryPhoneCountryCode || ''} onPersist={handleCountryChange} readonly={readonly} - VariablePicker={VariablePicker} /> { + return ( + + ); + }, + onPersist: fn(), + }, + play: async ({ canvasElement, args }) => { + const canvas = within(canvasElement); + + const countryCodeDefaultValue = await canvas.findByText('No country'); + expect(countryCodeDefaultValue).toBeVisible(); + + const phoneNumberDefaultValue = + await canvas.findByPlaceholderText('Enter phone number'); + expect(phoneNumberDefaultValue).toHaveDisplayValue(''); + + const phoneNumberVariablePicker = await canvas.findByText('Add variable'); + + await userEvent.click(phoneNumberVariablePicker); + + const phoneNumberVariable = await canvas.findByText('test'); + expect(phoneNumberVariable).toBeVisible(); + + await waitFor(() => { + expect(args.onPersist).toHaveBeenCalledWith({ + primaryPhoneNumber: '{{test}}', + primaryPhoneCountryCode: '', + primaryPhoneCallingCode: '', + }); + }); + }, +}; + export const Disabled: Story = { args: { - label: 'Enter phone...', + label: 'Phone', readonly: true, VariablePicker: () =>
VariablePicker
, },