Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: in group creation don't show duplicate error message when members added again #1425

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/PeopleManagement/CreateGroupModalContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const CreateGroupModalContent = ({
onEmailAddressesChange([]);
return;
}
setLearnerEmails(prev => [...prev, ...value]);
// Merge new emails with old emails (removing duplicates)
setLearnerEmails(prev => _.union(prev, value));
setIsCreateGroupListSelection(true);
}, [onEmailAddressesChange, setIsCreateGroupListSelection]);

Expand Down
18 changes: 18 additions & 0 deletions src/components/PeopleManagement/tests/CreateGroupModal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,22 @@ describe('<CreateGroupModal />', () => {
)).toBeInTheDocument();
});
});
it('does not show duplicate error when members are bulk added multiple times', async () => {
render(<CreateGroupModalWrapper />);
// testing interaction with adding members from the datatable
const membersCheckboxes = screen.getAllByRole('checkbox');
// skipping first one because its the select all checkbox
userEvent.click(membersCheckboxes[1]);
const addMembersButton = screen.getByText('Add');
userEvent.click(addMembersButton);
// Select a second member while keeping first selected, and add again
userEvent.click(membersCheckboxes[2]);
userEvent.click(addMembersButton);

await waitFor(() => {
expect(screen.getAllByText('[email protected]')).toHaveLength(2);
expect(screen.getAllByText('[email protected]')).toHaveLength(2);
});
expect(screen.queryByText('Only 1 invite per email address will be sent.')).not.toBeInTheDocument();
});
});