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

[MCR-2538] States are notified when CMS uploads questions about a submission #2068

Merged
merged 24 commits into from
Nov 30, 2023

Conversation

pearl-truss
Copy link
Contributor

@pearl-truss pearl-truss commented Nov 20, 2023

Summary

This PR creates a way for state users to be notified via email when someone from CMS sends a question for a submission they are a contact for

To Do

  • Attach screenshots of the actual email via the review app once it's deployed
  • Fix api unit test
  • Add failure api test for the createQuestion resolver
  • Add QA guidance once I figure out how to trigger the emails in the UI

Related issues

https://qmacbis.atlassian.net/browse/MCR-2538

Screenshots

Screenshot 2023-11-28 at 9 37 48 AM

Test cases covered

  • the to address list goes to the expected emails
  • no duplicate email addresses
  • subject line is correct
  • the email itself includes relevant info (like link to a submission, name, email and division of the CMS user who submitted the question)
  • renders overall email

QA guidance

  • Login in as a state user and find a submission, update the state contact to an email you can access
  • Login to the review app as a CMS user
  • Find a submitted submission and click on the QA tab, upload a question
  • Check the email that you used as the state contact

@pearl-truss pearl-truss changed the title [MCR-2538] email notifications to states [MCR-2538] States are notified when CMS uploads questions about a submission Nov 20, 2023
@pearl-truss pearl-truss marked this pull request as ready for review November 21, 2023 17:50
@pearl-truss pearl-truss requested a review from macrael November 21, 2023 17:50
Copy link
Contributor

@macrael macrael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, but I do think that we shouldn't add new functions to the emailer that are taking in the old HealthPlanPackage types. LMK if you want to pair on this, we might want to use some different test helper methods, for instance.

@@ -186,6 +195,27 @@ function newSESEmailer(config: EmailConfiguration): Emailer {
return await this.sendEmail(emailData)
}
},
sendQuestionsStateEmail: async function (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you are working on these four emails, I wonder if we could refactor the SESEmailer and the localEmailer code to be a little less repetitive


if (template instanceof Error) {
console.error(template)
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would throw this error if it's an error, that will fail the test. I don't think returning will fail the test but maybe it will b/c there haven't been any assertions? In general, if there's some kind of error in a test I like to throw it to fail.

Lots of our test helpers throw (see createAndSubmitTestHealthPlanPackage for instance)

This is a big exception to our general rule of "return Errors, don't throw" but it's basically the API of jest so it makes sense to me

@@ -77,6 +83,47 @@ export function createQuestionResolver(
throw new UserInputError(errMessage)
}

const conversionResult = convertContractWithRatesToFormData(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move away from converting the contract to the old HealthPlanPackage and HealthPlanFormData types? The rates refactor was the first step in deprecating those types. We're still converting to them in order to return them from our handlers, but when we convert the front end to be able to support rates across submissions the plan is to try and root those types out all together.

I think the only real change this would require would be for the sendQuestionsStateEmail function to take in a ContractWithRatesType instead of a HPFD type, but it should have all the data you need to compose the email in it, then.

@pearl-truss
Copy link
Contributor Author

@macrael thanks for the review! This is ready for another pass when you get a chance

Copy link
Contributor

@macrael macrael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, so glad to see the HPP stuff gone. I think more refactoring can come in further PRs or in this PR up to you. Also I'm happy to meet and try and work on the refactor together, I think I finally see something in how we could pull the sendEmail function out of the emailer thing

],
}
const sub: ContractRevisionWithRatesType = {
...mockContractRev({ formData: formDataWithDuplicateStateContacts }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's up with expanding mockContractRev here instead of just using it by itself?

)

if (template instanceof Error) {
console.error(template)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a bunch more of these instances where you're returning an error instead of throwing them, can you fix those too?

@@ -86,6 +102,30 @@ export function createQuestionResolver(
throw new Error(errMessage)
}

const dateAsked = new Date()
const sendQuestionsStateEmailResult =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay, I love how much less prep there is here now.

}
},
}
}

function newSESEmailer(config: EmailConfiguration): Emailer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very glad you maintained these entry points. I think we can simplify things a bit more. Looking at it I think the main weirdness is that sendEmail is not like the other functions. And I forgot that we also duplicate this structure in our testing helper too. I think we could break out the sendTestEmail, sendSESEmail, sendLocalEmail functions into something that you pass into a single "emailer". I can sketch it out or we can meet and talk it through.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I'm out this afternoon I'll take a pass at making these updates and push them up today. And maybe we can meet tomorrow if there are more changes to work through?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed up some changes that refactor the emailer that I believe address what you raised here. I do need to fix failing test next, the sendEmail function for the testEmailer isn't returning errors as expected

@pearl-truss pearl-truss merged commit 869f71e into main Nov 30, 2023
27 checks passed
@pearl-truss pearl-truss deleted the mcr-2538-email-notifications-to-states branch November 30, 2023 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants