diff --git a/src/components/OrgPeopleListCard/OrgPeopleListCard.spec.tsx b/src/components/OrgPeopleListCard/OrgPeopleListCard.spec.tsx index 3023c82319..485ad1ae11 100644 --- a/src/components/OrgPeopleListCard/OrgPeopleListCard.spec.tsx +++ b/src/components/OrgPeopleListCard/OrgPeopleListCard.spec.tsx @@ -83,6 +83,45 @@ describe('Testing Organization People List Card', () => { }); }); + const NULL_DATA_MOCKS = [ + { + request: { + query: REMOVE_MEMBER_MUTATION, + variables: { + userid: '1', + orgid: '456', + }, + }, + result: { + data: null, + }, + }, + ]; + + test('should handle null data response from mutation', async () => { + const link = new StaticMockLink(NULL_DATA_MOCKS, true); + + render( + + + + + + + , + ); + + // Click remove button + const removeButton = screen.getByTestId('removeMemberBtn'); + await userEvent.click(removeButton); + + // Verify that success toast and toggleRemoveModal were not called + await waitFor(() => { + expect(toast.success).not.toHaveBeenCalled(); + expect(props.toggleRemoveModal).not.toHaveBeenCalled(); + }); + }); + test('should render modal and handle successful member removal', async () => { const link = new StaticMockLink(MOCKS, true); @@ -123,14 +162,7 @@ describe('Testing Organization People List Card', () => { await waitFor( () => { expect(toast.success).toHaveBeenCalled(); - }, - { timeout: 3000 }, - ); - - // Check if page reload is triggered after delay - await waitFor( - () => { - expect(window.location.reload).toHaveBeenCalled(); + expect(props.toggleRemoveModal).toHaveBeenCalled(); }, { timeout: 3000 }, ); diff --git a/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx b/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx index 8a028227f1..e7171bff71 100644 --- a/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx +++ b/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx @@ -55,12 +55,9 @@ function orgPeopleListCard( orgid: currentUrl, }, }); - // If the mutation is successful, show a success message and reload the page if (data) { toast.success(t('memberRemoved') as string); - setTimeout(() => { - window.location.reload(); - }, 2000); + props.toggleRemoveModal(); } } catch (error: unknown) { errorHandler(t, error);