|
@@ -142,6 +142,45 @@ describe('EmailBuilder', function() {
|
|
|
|
|
|
|
|
describe('templates', function() {
|
|
describe('templates', function() {
|
|
|
describe('CTA', 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() {
|
|
describe('confirmEmail', function() {
|
|
|
before(function() {
|
|
before(function() {
|
|
|
this.emailAddress = 'example@overleaf.com'
|
|
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('no CTA', function() {
|
|
|
describe('securityAlert', function() {
|
|
describe('securityAlert', function() {
|