diff --git a/src/components/bulk-email-tool/bulk-email-form/BulkEmailForm.jsx b/src/components/bulk-email-tool/bulk-email-form/BulkEmailForm.jsx index 8817335..bc0e532 100644 --- a/src/components/bulk-email-tool/bulk-email-form/BulkEmailForm.jsx +++ b/src/components/bulk-email-tool/bulk-email-form/BulkEmailForm.jsx @@ -122,6 +122,14 @@ function BulkEmailForm(props) { const onRecipientChange = (event) => { if (event.target.checked) { dispatch(addRecipient(event.target.value)); + // if "All Learners" is checked then we want to remove any cohorts, verified learners, and audit learners + if (event.target.value === 'learners') { + editor.emailRecipients.forEach(recipient => { + if (/^cohort/.test(recipient) || /^track/.test(recipient)) { + dispatch(removeRecipient(recipient)); + } + }); + } } else { dispatch(removeRecipient(event.target.value)); } diff --git a/src/components/bulk-email-tool/bulk-email-form/bulk-email-recipient/BulkEmailRecipient.jsx b/src/components/bulk-email-tool/bulk-email-form/bulk-email-recipient/BulkEmailRecipient.jsx index c58172a..2bafefc 100644 --- a/src/components/bulk-email-tool/bulk-email-form/bulk-email-recipient/BulkEmailRecipient.jsx +++ b/src/components/bulk-email-tool/bulk-email-form/bulk-email-recipient/BulkEmailRecipient.jsx @@ -69,6 +69,7 @@ export default function BulkEmailRecipient(props) { group === DEFAULT_GROUPS.ALL_LEARNERS)} className="col col-lg-4 col-sm-6 col-12" > group === (DEFAULT_GROUPS.AUDIT || DEFAULT_GROUPS.VERIFIED))} className="col col-lg-4 col-sm-6 col-12" > - + ); } @@ -91,6 +93,16 @@ describe('bulk-email-form', () => { fireEvent.click(await screen.findByRole('button', { name: /continue/i })); expect(await screen.findByText('An error occured while attempting to send the email.')).toBeInTheDocument(); }); + test('Checking "All Learners" disables each learner group', async () => { + render(renderBulkEmailForm()); + fireEvent.click(screen.getByRole('checkbox', { name: 'All Learners' })); + const verifiedLearners = screen.getByRole('checkbox', { name: 'Learners in the verified certificate track' }); + const auditLearners = screen.getByRole('checkbox', { name: 'Learners in the audit track' }); + const { cohorts } = cohortFactory.build(); + cohorts.forEach(cohort => expect(screen.getByRole('checkbox', { name: `Cohort: ${cohort}` })).toBeDisabled()); + expect(verifiedLearners).toBeDisabled(); + expect(auditLearners).toBeDisabled(); + }); test('Shows scheduling form when checkbox is checked and submit is changed', async () => { render(renderBulkEmailForm()); const scheduleCheckbox = screen.getByText('Schedule this email for a future date');