diff --git a/src/account/components/AccountProfile.test.js b/src/account/components/AccountProfile.test.js index 578bca6e5..a1cca489c 100644 --- a/src/account/components/AccountProfile.test.js +++ b/src/account/components/AccountProfile.test.js @@ -245,7 +245,7 @@ test('AccountProfile: Save language', async () => { }); }); -test('AccountProfile: Save group notifications', async () => { +const testNotificationsSetting = async (key, checkboxLabel) => { terrasoApi.requestGraphQL.mockImplementation(query => { const trimmedQuery = query.trim(); @@ -288,18 +288,16 @@ test('AccountProfile: Save group notifications', async () => { } if (trimmedQuery.startsWith('mutation updateUserPreference(')) { return Promise.resolve( - _.set( - 'updateUserPreference.preference', - { key: 'group_notifications', value: 'true' }, - {} - ) + _.set('updateUserPreference.preference', { key, value: 'true' }, {}) ); } }); await setup(); - const checkbox = screen.getByRole('checkbox'); + const checkbox = screen.getByRole('checkbox', { + name: checkboxLabel, + }); expect(checkbox.checked).toEqual(false); await act(async () => fireEvent.click(checkbox)); @@ -311,12 +309,24 @@ test('AccountProfile: Save group notifications', async () => { expect(terrasoApi.requestGraphQL).toHaveBeenCalledTimes(4); expect(terrasoApi.requestGraphQL.mock.calls[3][1]).toStrictEqual({ input: { - key: 'group_notifications', + key, userEmail: 'group@group.org', value: 'true', }, }); -}); +}; + +test('AccountProfile: Save group notifications', async () => + testNotificationsSetting( + 'group_notifications', + 'A group I manage has pending requests or my request to join a closed group is approved' + )); + +test('AccountProfile: Save story map notifications', async () => + testNotificationsSetting( + 'story_map_notifications', + 'I am invited to edit a story map' + )); test('AccountProfile: Save error', async () => { terrasoApi.requestGraphQL.mockImplementation(query => {