mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #3211 from overleaf/jel-new-cta-email-projectInvite
Convert projectInvite to new email handling GitOrigin-RevId: 88b6383832ab12b524890532a120c6f2f0f28c8c
This commit is contained in:
parent
a6be3179fd
commit
562fb35416
2 changed files with 61 additions and 6 deletions
|
@ -290,7 +290,7 @@ templates.confirmEmail = ctaTemplate({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
templates.projectInvite = CTAEmailTemplate({
|
templates.projectInvite = ctaTemplate({
|
||||||
subject(opts) {
|
subject(opts) {
|
||||||
return `${_.escape(
|
return `${_.escape(
|
||||||
SpamSafe.safeProjectName(opts.project.name, 'New Project')
|
SpamSafe.safeProjectName(opts.project.name, 'New Project')
|
||||||
|
@ -306,11 +306,13 @@ templates.projectInvite = CTAEmailTemplate({
|
||||||
)}`
|
)}`
|
||||||
},
|
},
|
||||||
message(opts) {
|
message(opts) {
|
||||||
return `${_.escape(
|
return [
|
||||||
SpamSafe.safeEmail(opts.owner.email, 'a collaborator')
|
`${_.escape(
|
||||||
)} wants to share ${_.escape(
|
SpamSafe.safeEmail(opts.owner.email, 'a collaborator')
|
||||||
SpamSafe.safeProjectName(opts.project.name, 'a new project')
|
)} wants to share ${_.escape(
|
||||||
)} with you.`
|
SpamSafe.safeProjectName(opts.project.name, 'a new project')
|
||||||
|
)} with you.`
|
||||||
|
]
|
||||||
},
|
},
|
||||||
ctaText() {
|
ctaText() {
|
||||||
return 'View project'
|
return 'View project'
|
||||||
|
|
|
@ -468,6 +468,59 @@ describe('EmailBuilder', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('projectInvite', function() {
|
||||||
|
before(function() {
|
||||||
|
this.emailAddress = 'example@overleaf.com'
|
||||||
|
this.owner = {
|
||||||
|
email: 'owner@example.com',
|
||||||
|
name: 'Bailey'
|
||||||
|
}
|
||||||
|
this.projectName = 'Top Secret'
|
||||||
|
this.opts = {
|
||||||
|
inviteUrl:
|
||||||
|
`${
|
||||||
|
this.settings.siteUrl
|
||||||
|
}/project/projectId123/invite/token/aToken123?` +
|
||||||
|
[
|
||||||
|
`project_name=${encodeURIComponent(this.projectName)}`,
|
||||||
|
`user_first_name=${encodeURIComponent(this.owner.name)}`
|
||||||
|
].join('&'),
|
||||||
|
owner: {
|
||||||
|
email: this.owner.email
|
||||||
|
},
|
||||||
|
project: {
|
||||||
|
name: this.projectName
|
||||||
|
},
|
||||||
|
to: this.emailAddress
|
||||||
|
}
|
||||||
|
this.email = this.EmailBuilder.buildEmail('projectInvite', this.opts)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should build the email', function() {
|
||||||
|
expect(this.email.html).to.exist
|
||||||
|
expect(this.email.text).to.exist
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('HTML email', function() {
|
||||||
|
it('should include a CTA button and a fallback CTA link', function() {
|
||||||
|
const dom = cheerio.load(this.email.html)
|
||||||
|
const buttonLink = dom('a:contains("View project")')
|
||||||
|
expect(buttonLink.length).to.equal(1)
|
||||||
|
expect(buttonLink.attr('href')).to.equal(this.opts.inviteUrl)
|
||||||
|
const fallback = dom('.avoid-auto-linking').last()
|
||||||
|
expect(fallback.length).to.equal(1)
|
||||||
|
const fallbackLink = fallback.html().replace(/&/g, '&')
|
||||||
|
expect(fallbackLink).to.contain(this.opts.inviteUrl)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('plain text email', function() {
|
||||||
|
it('should contain the CTA link', function() {
|
||||||
|
expect(this.email.text).to.contain(this.opts.inviteUrl)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
describe('no CTA', function() {
|
describe('no CTA', function() {
|
||||||
describe('securityAlert', function() {
|
describe('securityAlert', function() {
|
||||||
|
|
Loading…
Reference in a new issue