-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: email notification when latest sow upload
x
- Loading branch information
1 parent
9994004
commit bf25ab4
Showing
7 changed files
with
187 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
EmailTemplate, | ||
EmailTemplateProvider, | ||
} from '../handleEmailNotification'; | ||
|
||
const notifySowUpload: EmailTemplateProvider = ( | ||
applicationId: string, | ||
url: string, | ||
initiator: any, | ||
params: any | ||
): EmailTemplate => { | ||
const { ccbcNumber, amendmentNumber } = params; | ||
const amendmentLink = `<a href='${url}/analyst/application/${applicationId}/project?section=projectInformation'>${amendmentNumber}</a>`; | ||
const description = amendmentNumber | ||
? `Amendment ${amendmentLink} for ${ccbcNumber} due to a change request.` | ||
: `${ccbcNumber}.`; | ||
return { | ||
emailTo: [70], | ||
emailCC: [], | ||
tag: 'sow-upload-review', | ||
subject: `Action Required - Review Project Description and Project Type for ${ccbcNumber}`, | ||
body: ` | ||
<h1>${initiator.givenName} has uploaded a SOW for ${description}</h1> | ||
<p>Please review the Project Description and Project Type in the header <a href='${url}/analyst/application/${applicationId}/summary'>here</a> and update if required.</p> | ||
<p>To unsubscribe from this notification please forward this email with your request to <a href="mailto:meherzad.romer@gov.bc.ca">meherzad.romer@gov.bc.ca<a/></p> | ||
`, | ||
}; | ||
}; | ||
|
||
export default notifySowUpload; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/tests/backend/lib/emails/templates/notifySowUpload.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import notifySowUpload from 'backend/lib/emails/templates/notifySowUpload'; | ||
|
||
describe('notifySowUpload template', () => { | ||
it('should return an email template with correct properties', () => { | ||
const applicationId = '1'; | ||
const url = 'http://mock_host.ca'; | ||
|
||
const emailTemplate = notifySowUpload( | ||
applicationId, | ||
url, | ||
{}, | ||
{ ccbcNumber: 'CCBC-101', amendmentNumber: 1 } | ||
); | ||
|
||
expect(emailTemplate).toEqual( | ||
expect.objectContaining({ | ||
emailTo: [70], | ||
emailCC: [], | ||
tag: 'sow-upload-review', | ||
subject: | ||
'Action Required - Review Project Description and Project Type for CCBC-101', | ||
body: expect.anything(), | ||
}) | ||
); | ||
}); | ||
|
||
it('should include correct URL in the body for original sow upload', () => { | ||
const applicationId = '1'; | ||
const url = 'http://mock_host.ca'; | ||
|
||
const emailTemplate: any = notifySowUpload( | ||
applicationId, | ||
url, | ||
{ givenName: 'uniqueStringName' }, | ||
{ ccbcNumber: 'CCBC-101' } | ||
); | ||
|
||
expect(emailTemplate.body).toContain( | ||
`<a href='http://mock_host.ca/analyst/application/1/summary'>here</a>` | ||
); | ||
|
||
expect(emailTemplate.body).toContain('uniqueStringName'); | ||
}); | ||
|
||
it('should include correct URL in the body for amendment sow upload', () => { | ||
const applicationId = '1'; | ||
const url = 'http://mock_host.ca'; | ||
|
||
const emailTemplate: any = notifySowUpload( | ||
applicationId, | ||
url, | ||
{ givenName: 'uniqueStringName' }, | ||
{ ccbcNumber: 'CCBC-101', amendmentNumber: 1 } | ||
); | ||
|
||
expect(emailTemplate.body).toContain( | ||
`<a href='http://mock_host.ca/analyst/application/1/summary'>here</a>` | ||
); | ||
expect(emailTemplate.body).toContain( | ||
`<a href='http://mock_host.ca/analyst/application/1/project?section=projectInformation'>1</a>` | ||
); | ||
|
||
expect(emailTemplate.body).toContain('uniqueStringName'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters