diff --git a/src/GraphQl/Mutations/mutations.ts b/src/GraphQl/Mutations/mutations.ts index 5547aa38b9..3a68033de0 100644 --- a/src/GraphQl/Mutations/mutations.ts +++ b/src/GraphQl/Mutations/mutations.ts @@ -87,10 +87,16 @@ export const UPDATE_USER_MUTATION = gql` $firstName: String $lastName: String $email: EmailAddress + $appLanguageCode: String $file: String ) { updateUserProfile( - data: { firstName: $firstName, lastName: $lastName, email: $email } + data: { + firstName: $firstName + lastName: $lastName + email: $email + appLanguageCode: $appLanguageCode + } file: $file ) { _id diff --git a/src/components/UserUpdate/UserUpdate.test.tsx b/src/components/UserUpdate/UserUpdate.test.tsx index c9dd5d2472..a32bef6e8a 100644 --- a/src/components/UserUpdate/UserUpdate.test.tsx +++ b/src/components/UserUpdate/UserUpdate.test.tsx @@ -92,6 +92,28 @@ describe('Testing User Update', () => { global.alert = jest.fn(); + test('should display warnings for blank form submission', async () => { + jest.spyOn(toast, 'warning'); + + render( + + + + + + + , + ); + + await wait(); + + userEvent.click(screen.getByText(/Save Changes/i)); + + expect(toast.warning).toHaveBeenCalledWith('First Name cannot be blank!'); + expect(toast.warning).toHaveBeenCalledWith('Last Name cannot be blank!'); + expect(toast.warning).toHaveBeenCalledWith('Email cannot be blank!'); + }); + test('should render props and text elements test for the page component', async () => { render( @@ -115,6 +137,7 @@ describe('Testing User Update', () => { ); userEvent.type(screen.getByPlaceholderText(/Email/i), formData.email); userEvent.selectOptions(screen.getByTestId('applangcode'), 'Français'); + userEvent.upload(screen.getByLabelText(/Display Image:/i), formData.image); await wait(); @@ -134,25 +157,4 @@ describe('Testing User Update', () => { expect(screen.getByPlaceholderText(/Email/i)).toBeInTheDocument(); expect(screen.getByText(/Display Image/i)).toBeInTheDocument(); }); - test('should display warnings for blank form submission', async () => { - jest.spyOn(toast, 'warning'); - - render( - - - - - - - , - ); - - await wait(); - - userEvent.click(screen.getByText(/Save Changes/i)); - - expect(toast.warning).toHaveBeenCalledWith('First Name cannot be blank!'); - expect(toast.warning).toHaveBeenCalledWith('Last Name cannot be blank!'); - expect(toast.warning).toHaveBeenCalledWith('Email cannot be blank!'); - }); }); diff --git a/src/components/UserUpdate/UserUpdate.tsx b/src/components/UserUpdate/UserUpdate.tsx index 143e47616d..fe4f8f3f4e 100644 --- a/src/components/UserUpdate/UserUpdate.tsx +++ b/src/components/UserUpdate/UserUpdate.tsx @@ -36,7 +36,7 @@ const UserUpdate: React.FC = ({ lastName: '', email: '', password: '', - applangcode: '', + appLanguageCode: '', file: '', }); @@ -56,7 +56,7 @@ const UserUpdate: React.FC = ({ firstName: data?.user?.firstName, lastName: data?.user?.lastName, email: data?.user?.email, - applangcode: data?.user?.applangcode, + appLanguageCode: data?.user?.appLanguageCode, }); } }, [data]); @@ -75,7 +75,7 @@ const UserUpdate: React.FC = ({ const firstName = formState.firstName; const lastName = formState.lastName; const email = formState.email; - const applangcode = formState.applangcode; + const appLanguageCode = formState.appLanguageCode; const file = formState.file; let toSubmit = true; if (firstName.trim().length == 0 || !firstName) { @@ -98,7 +98,7 @@ const UserUpdate: React.FC = ({ firstName, lastName, email, - applangcode, + appLanguageCode, file, }, }); @@ -109,7 +109,7 @@ const UserUpdate: React.FC = ({ lastName: '', email: '', password: '', - applangcode: '', + appLanguageCode: '', file: '', }); @@ -138,7 +138,6 @@ const UserUpdate: React.FC = ({ <>
- {/*

Update Your Details

*/}
@@ -207,7 +206,7 @@ const UserUpdate: React.FC = ({ onChange={(e): void => { setFormState({ ...formState, - applangcode: e.target.value, + appLanguageCode: e.target.value, }); }} >