mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-21 03:31:42 +00:00
Merge pull request #3198 from overleaf/jel-new-cta-email-testEmail
Convert testEmail to new email handling GitOrigin-RevId: 4230875a360b03de5e5dbaff83fb99187ef745b1
This commit is contained in:
parent
dfb58a69c4
commit
739b301419
2 changed files with 40 additions and 2 deletions
|
@ -354,7 +354,7 @@ templates.verifyEmailToJoinTeam = ctaTemplate({
|
|||
}
|
||||
})
|
||||
|
||||
templates.testEmail = CTAEmailTemplate({
|
||||
templates.testEmail = ctaTemplate({
|
||||
subject() {
|
||||
return `A Test Email from ${settings.appName}`
|
||||
},
|
||||
|
@ -365,7 +365,7 @@ templates.testEmail = CTAEmailTemplate({
|
|||
return 'Hi,'
|
||||
},
|
||||
message() {
|
||||
return `This is a test Email from ${settings.appName}`
|
||||
return [`This is a test Email from ${settings.appName}`]
|
||||
},
|
||||
ctaText() {
|
||||
return `Open ${settings.appName}`
|
||||
|
|
|
@ -391,6 +391,44 @@ describe('EmailBuilder', function() {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('testEmail', function() {
|
||||
before(function() {
|
||||
this.emailAddress = 'example@overleaf.com'
|
||||
this.opts = {
|
||||
to: this.emailAddress
|
||||
}
|
||||
this.email = this.EmailBuilder.buildEmail('testEmail', 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("Open ${this.settings.appName}")`
|
||||
)
|
||||
expect(buttonLink.length).to.equal(1)
|
||||
expect(buttonLink.attr('href')).to.equal(this.settings.siteUrl)
|
||||
const fallback = dom('.avoid-auto-linking').last()
|
||||
expect(fallback.length).to.equal(1)
|
||||
const fallbackLink = fallback.html()
|
||||
expect(fallbackLink).to.contain(this.settings.siteUrl)
|
||||
})
|
||||
})
|
||||
|
||||
describe('plain text email', function() {
|
||||
it('should contain the CTA link', function() {
|
||||
expect(this.email.text).to.contain(
|
||||
`Open ${this.settings.appName}: ${this.settings.siteUrl}`
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('no CTA', function() {
|
||||
describe('securityAlert', function() {
|
||||
|
|
Loading…
Reference in a new issue