mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-17 02:34:05 +00:00
Merge pull request #3197 from overleaf/jel-new-cta-email-subscription-alerts
Convert subscription emails to new email handling GitOrigin-RevId: bd10389aca073a1a21778af8c362e9254ddc70f1
This commit is contained in:
parent
e1bcf93374
commit
dfb58a69c4
2 changed files with 86 additions and 11 deletions
|
@ -210,19 +210,19 @@ Click here to set your password and log in:\
|
|||
}
|
||||
})
|
||||
|
||||
templates.canceledSubscription = CTAEmailTemplate({
|
||||
templates.canceledSubscription = ctaTemplate({
|
||||
subject() {
|
||||
return `${settings.appName} thoughts`
|
||||
},
|
||||
message() {
|
||||
return `\
|
||||
We are sorry to see you cancelled your ${
|
||||
settings.appName
|
||||
} premium subscription. Would you mind giving us some feedback on what the site is lacking at the moment via this quick survey?\
|
||||
`
|
||||
return [
|
||||
`We are sorry to see you cancelled your ${
|
||||
settings.appName
|
||||
} premium subscription. Would you mind giving us some feedback on what the site is lacking at the moment via this quick survey?`
|
||||
]
|
||||
},
|
||||
secondaryMessage() {
|
||||
return 'Thank you in advance!'
|
||||
return ['Thank you in advance!']
|
||||
},
|
||||
ctaText() {
|
||||
return 'Leave Feedback'
|
||||
|
@ -232,14 +232,12 @@ We are sorry to see you cancelled your ${
|
|||
}
|
||||
})
|
||||
|
||||
templates.reactivatedSubscription = CTAEmailTemplate({
|
||||
templates.reactivatedSubscription = ctaTemplate({
|
||||
subject() {
|
||||
return `Subscription Reactivated - ${settings.appName}`
|
||||
},
|
||||
message(opts) {
|
||||
return `\
|
||||
Your subscription was reactivated successfully.\
|
||||
`
|
||||
return ['Your subscription was reactivated successfully.']
|
||||
},
|
||||
ctaText() {
|
||||
return 'View Subscription Dashboard'
|
||||
|
|
|
@ -142,6 +142,45 @@ describe('EmailBuilder', function() {
|
|||
|
||||
describe('templates', function() {
|
||||
describe('CTA', function() {
|
||||
describe('canceledSubscription', function() {
|
||||
beforeEach(function() {
|
||||
this.emailAddress = 'example@overleaf.com'
|
||||
this.opts = {
|
||||
to: this.emailAddress
|
||||
}
|
||||
this.email = this.EmailBuilder.buildEmail(
|
||||
'canceledSubscription',
|
||||
this.opts
|
||||
)
|
||||
this.expectedUrl =
|
||||
'https://docs.google.com/forms/d/e/1FAIpQLSfa7z_s-cucRRXm70N4jEcSbFsZeb0yuKThHGQL8ySEaQzF0Q/viewform?usp=sf_link'
|
||||
})
|
||||
|
||||
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("Leave Feedback")')
|
||||
expect(buttonLink.length).to.equal(1)
|
||||
expect(buttonLink.attr('href')).to.equal(this.expectedUrl)
|
||||
const fallback = dom('.avoid-auto-linking').last()
|
||||
expect(fallback.length).to.equal(1)
|
||||
const fallbackLink = fallback.html()
|
||||
expect(fallbackLink).to.contain(this.expectedUrl)
|
||||
})
|
||||
})
|
||||
|
||||
describe('plain text email', function() {
|
||||
it('should contain the CTA link', function() {
|
||||
expect(this.email.text).to.contain(this.expectedUrl)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('confirmEmail', function() {
|
||||
before(function() {
|
||||
this.emailAddress = 'example@overleaf.com'
|
||||
|
@ -314,6 +353,44 @@ describe('EmailBuilder', function() {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('reactivatedSubscription', function() {
|
||||
before(function() {
|
||||
this.emailAddress = 'example@overleaf.com'
|
||||
this.opts = {
|
||||
to: this.emailAddress
|
||||
}
|
||||
this.email = this.EmailBuilder.buildEmail(
|
||||
'reactivatedSubscription',
|
||||
this.opts
|
||||
)
|
||||
this.expectedUrl = `${this.settings.siteUrl}/user/subscription`
|
||||
})
|
||||
|
||||
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 Subscription Dashboard")')
|
||||
expect(buttonLink.length).to.equal(1)
|
||||
expect(buttonLink.attr('href')).to.equal(this.expectedUrl)
|
||||
const fallback = dom('.avoid-auto-linking').last()
|
||||
expect(fallback.length).to.equal(1)
|
||||
const fallbackLink = fallback.html()
|
||||
expect(fallbackLink).to.contain(this.expectedUrl)
|
||||
})
|
||||
})
|
||||
|
||||
describe('plain text email', function() {
|
||||
it('should contain the CTA link', function() {
|
||||
expect(this.email.text).to.contain(this.expectedUrl)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('no CTA', function() {
|
||||
describe('securityAlert', function() {
|
||||
|
|
Loading…
Reference in a new issue