-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add self delete-user account notification email
- Loading branch information
1 parent
7e83195
commit 2ac796c
Showing
3 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
api/src/identity-access-management/domain/emails/create-self-delete-user-account.email.js
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,25 @@ | ||
import { EmailFactory } from '../../../shared/mail/domain/models/EmailFactory.js'; | ||
import { mailer } from '../../../shared/mail/infrastructure/services/mailer.js'; | ||
|
||
export function createSelfDeleteUserAccountEmail({ locale, email, firstName }) { | ||
const factory = new EmailFactory({ app: 'pix-app', locale }); | ||
|
||
const { i18n, defaultVariables } = factory; | ||
|
||
return factory.buildEmail({ | ||
template: mailer.selfAccountDeletionTemplateId, | ||
subject: i18n.__('self-account-deletion-email.subject'), | ||
to: email, | ||
variables: { | ||
homeName: defaultVariables.homeName, | ||
homeUrl: defaultVariables.homeUrl, | ||
helpdeskUrl: defaultVariables.helpdeskUrl, | ||
displayNationalLogo: defaultVariables.displayNationalLogo, | ||
doNotAnswer: i18n.__('common.email.m doNotAnswer'), | ||
moreOn: i18n.__('common.email.moreOn'), | ||
pixPresentation: i18n.__('common.email.pixPresentation'), | ||
title: i18n.__('self-account-deletion-email.params.title', { firstName }), | ||
// "contactUs" | ||
}, | ||
}); | ||
} |
32 changes: 32 additions & 0 deletions
32
...entity-access-management/unit/domain/emails/create-self-delete-user-account.email_test.js
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,32 @@ | ||
import { createSelfDeleteUserAccountEmail } from '../../../../../src/identity-access-management/domain/emails/create-self-delete-user-account.email.js'; | ||
import { Email } from '../../../../../src/shared/mail/domain/models/Email.js'; | ||
import { mailer } from '../../../../../src/shared/mail/infrastructure/services/mailer.js'; | ||
import { expect } from '../../../../test-helper.js'; | ||
|
||
describe('Unit | Identity Access Management | Domain | Email | create-self-delete-user-account', function () { | ||
it('creates self delete user account email with correct parameters', function () { | ||
const emailParams = { | ||
locale: 'fr', | ||
email: '[email protected]', | ||
firstName: 'John', | ||
token: '12345', | ||
}; | ||
|
||
const email = createSelfDeleteUserAccountEmail(emailParams); | ||
|
||
expect(email).to.be.instanceof(Email); | ||
expect(email).to.have.property('subject').that.is.a('string'); | ||
expect(email.to).to.equal(emailParams.email); | ||
expect(email.template).to.equal(mailer.selfAccountDeletionTemplateId); | ||
|
||
const variables = email.variables; | ||
expect(variables).to.have.property('displayNationalLogo').that.is.a('boolean'); | ||
expect(variables).to.have.property('doNotAnswer').that.is.a('string'); | ||
expect(variables).to.have.property('helpdeskUrl').that.is.a('string'); | ||
expect(variables).to.have.property('homeName').that.is.a('string'); | ||
expect(variables).to.have.property('homeUrl').that.is.a('string'); | ||
expect(variables).to.have.property('moreOn').that.is.a('string'); | ||
expect(variables).to.have.property('pixPresentation').that.is.a('string'); | ||
expect(variables).to.have.property('title').that.is.a('string'); | ||
}); | ||
}); |
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