community-platform
community-platform copied to clipboard
[testing] Improve testing of notification email content
Is your feature request related to a problem? Please describe. Did you know the platform sends notification emails to users?! Pretty cool. You can find the code in this directory in the functions workspace. The readme has more information about the email process.
Describe the solution you'd like The file createNotificationEmails file handles the logic of generating the email HTML and inserting the email into the database. In the test for this file, we generate a snapshot of the HTML. This is a good check to ensure the emails we're sending match our design specs. However, snapshots of a big HTML blob are not very readable, and we really want to ensure we're sending the correct content in our emails to users.
To improve testing, please create some expect statements that check the HTML for dynamically generated content. For example, it would be important to check that a we're sending the right message, i.e. "New comment on your how-to by User 1", and the HTML contains the correct link, i.e. https://community.preciousplastic.com/test.
For an example, check out this commit, which does the same for moderation emails.
You run these tests locally with the command yarn workspace functions test:watch