Просмотр исходного кода

Merge pull request #3212 from overleaf/jel-new-cta-email-confirmEmail

Convert confirmEmail to new email handling

GitOrigin-RevId: 66d1bd7503d36cc74adfadc983003c31c2c57bd1
Jessica Lawshe 6 лет назад
Родитель
Сommit
e1bcf93374

+ 2 - 2
services/web/app/src/Features/Email/EmailBuilder.js

@@ -273,7 +273,7 @@ templates.passwordResetRequested = ctaTemplate({
   }
   }
 })
 })
 
 
-templates.confirmEmail = CTAEmailTemplate({
+templates.confirmEmail = ctaTemplate({
   subject() {
   subject() {
     return `Confirm Email - ${settings.appName}`
     return `Confirm Email - ${settings.appName}`
   },
   },
@@ -281,7 +281,7 @@ templates.confirmEmail = CTAEmailTemplate({
     return 'Confirm Email'
     return 'Confirm Email'
   },
   },
   message() {
   message() {
-    return `Please confirm your email on ${settings.appName}.`
+    return [`Please confirm your email on ${settings.appName}.`]
   },
   },
   ctaText() {
   ctaText() {
     return 'Confirm Email'
     return 'Confirm Email'

+ 39 - 0
services/web/test/unit/src/Email/EmailBuilderTests.js

@@ -142,6 +142,45 @@ describe('EmailBuilder', function() {
 
 
   describe('templates', function() {
   describe('templates', function() {
     describe('CTA', function() {
     describe('CTA', function() {
+      describe('confirmEmail', function() {
+        before(function() {
+          this.emailAddress = 'example@overleaf.com'
+          this.userId = 'abc123'
+          this.opts = {
+            to: this.emailAddress,
+            confirmEmailUrl: `${
+              this.settings.siteUrl
+            }/user/emails/confirm?token=aToken123`,
+            sendingUser_id: this.userId
+          }
+          this.email = this.EmailBuilder.buildEmail('confirmEmail', 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("Confirm Email")')
+            expect(buttonLink.length).to.equal(1)
+            expect(buttonLink.attr('href')).to.equal(this.opts.confirmEmailUrl)
+            const fallback = dom('.avoid-auto-linking').last()
+            expect(fallback.length).to.equal(1)
+            const fallbackLink = fallback.html()
+            expect(fallbackLink).to.contain(this.opts.confirmEmailUrl)
+          })
+        })
+
+        describe('plain text email', function() {
+          it('should contain the CTA link', function() {
+            expect(this.email.text).to.contain(this.opts.confirmEmailUrl)
+          })
+        })
+      })
+
       describe('ownershipTransferConfirmationNewOwner', function() {
       describe('ownershipTransferConfirmationNewOwner', function() {
         before(function() {
         before(function() {
           this.emailAddress = 'example@overleaf.com'
           this.emailAddress = 'example@overleaf.com'