Merge pull request #17730 from overleaf/rh-acct-delete-email

[web] Send email notification on account deletion

GitOrigin-RevId: 03c0effba0ee3b829f5b4fe377fe67d05776ba3f
This commit is contained in:
roo hutton
2024-04-10 08:04:12 +00:00
committed by Copybot
parent 8bde496da4
commit bf7a18db8b
3 changed files with 53 additions and 2 deletions
@@ -100,6 +100,12 @@ describe('UserDeleter', function () {
deleteOnboardingDataCollection: sinon.stub().resolves(),
}
this.EmailHandler = {
promises: {
sendEmail: sinon.stub().resolves(),
},
}
this.UserDeleter = SandboxedModule.require(modulePath, {
requires: {
'../../models/User': { User },
@@ -119,6 +125,7 @@ describe('UserDeleter', function () {
'../../infrastructure/Modules': this.Modules,
'../OnboardingDataCollection/OnboardingDataCollectionManager':
this.OnboardingDataCollectionManager,
'../Email/EmailHandler': this.EmailHandler,
},
})
})
@@ -251,6 +258,16 @@ describe('UserDeleter', function () {
await this.UserDeleter.promises.deleteUser(this.userId, {})
this.DeletedUserMock.verify()
})
it('should email the user', async function () {
await this.UserDeleter.promises.deleteUser(this.userId, {})
const emailOptions = {
to: 'bob@bob.com',
}
expect(
this.EmailHandler.promises.sendEmail
).to.have.been.calledWith('deletedAccount', emailOptions)
})
})
describe('when unsubscribing from mailchimp fails', function () {