From 4cdeb2474564432c9d3f11f5d4219ede54549987 Mon Sep 17 00:00:00 2001 From: Talia Date: Tue, 30 Mar 2021 12:34:54 -0400 Subject: [PATCH] fix: license reminder email doesn't need subject --- src/components/LicenseRemindModal/index.jsx | 2 +- src/data/validation/email.js | 4 ++-- src/data/validation/email.test.js | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/LicenseRemindModal/index.jsx b/src/components/LicenseRemindModal/index.jsx index f8c1e0793e..e873d5d3c0 100644 --- a/src/components/LicenseRemindModal/index.jsx +++ b/src/components/LicenseRemindModal/index.jsx @@ -62,7 +62,7 @@ class LicenseRemindModal extends React.Component { sendLicenseReminder, } = this.props; // Validate form data - validateEmailTemplateForm(formData, 'email-template-body'); + validateEmailTemplateForm(formData, 'email-template-body', false); // Configure the options to send to the assignment reminder API endpoint const options = { greeting: formData['email-template-greeting'], diff --git a/src/data/validation/email.js b/src/data/validation/email.js index d816a12eb7..06e8204822 100644 --- a/src/data/validation/email.js +++ b/src/data/validation/email.js @@ -111,10 +111,10 @@ is invalid. Please try again.`; return errorsDict; }; -const validateEmailTemplateForm = (formData, templateKey) => { +const validateEmailTemplateForm = (formData, templateKey, isSubjectRequired = true) => { // Takes redux form data and a string template key // Throws an error or otherwise returns nothing. - const errorsDict = validateEmailTemplateFields(formData, templateKey); + const errorsDict = validateEmailTemplateFields(formData, templateKey, isSubjectRequired); if (Object.keys(errorsDict) > 1 || errorsDict._error.length > 0) { throw new SubmissionError(errorsDict); diff --git a/src/data/validation/email.test.js b/src/data/validation/email.test.js index 67f95bdbd7..92e6209268 100644 --- a/src/data/validation/email.test.js +++ b/src/data/validation/email.test.js @@ -160,6 +160,13 @@ describe('email validation', () => { formData[EMAIL_TEMPLATE_SUBJECT_KEY] = 'Subject'; expect(validateEmailTemplateForm(formData, templateKey)).toBeUndefined(); }); + + it('returns nothing on successful validation (and no subject is required)', () => { + const formData = new FormData(); + formData[EMAIL_ADDRESS_CSV_FORM_DATA] = ['bobby1@test.com', 'bobby2@test.com']; + formData[templateKey] = 'Template 1'; + expect(validateEmailTemplateForm(formData, templateKey, false)).toBeUndefined(); + }); }); describe('validate email address and template form', () => {