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

Merge pull request #8290 from overleaf/ta-redundant-subscription-saml

Don't Create Redundant Subscription Notification on SAML for Group Plans

GitOrigin-RevId: 99e66201c9423ff7e849b2d68d96651ad6015fd0
Timothée Alby 4 лет назад
Родитель
Сommit
b26c491eb5

+ 1 - 1
services/web/app/src/Features/User/SAMLIdentityManager.js

@@ -226,7 +226,7 @@ async function redundantSubscription(userId, providerId, providerName) {
   const subscription =
     await SubscriptionLocator.promises.getUserIndividualSubscription(userId)
 
-  if (subscription) {
+  if (subscription && !subscription.groupPlan) {
     await NotificationsBuilder.promises
       .redundantPersonalSubscription(
         {

+ 29 - 1
services/web/test/unit/src/User/SAMLIdentityManagerTests.js

@@ -536,6 +536,7 @@ describe('SAMLIdentityManager', function () {
     const userId = '1bv'
     const providerId = 123
     const providerName = 'University Name'
+
     describe('with a personal subscription', function () {
       beforeEach(function () {
         this.SubscriptionLocator.promises.getUserIndividualSubscription.resolves(
@@ -544,6 +545,7 @@ describe('SAMLIdentityManager', function () {
           }
         )
       })
+
       it('should create redundant personal subscription notification ', async function () {
         try {
           await this.SAMLIdentityManager.redundantSubscription(
@@ -558,7 +560,17 @@ describe('SAMLIdentityManager', function () {
           .to.have.been.calledOnce
       })
     })
-    describe('without a personal subscription', function () {
+
+    describe('with a group subscription', function () {
+      beforeEach(function () {
+        this.SubscriptionLocator.promises.getUserIndividualSubscription.resolves(
+          {
+            planCode: 'professional',
+            groupPlan: true,
+          }
+        )
+      })
+
       it('should create redundant personal subscription notification ', async function () {
         try {
           await this.SAMLIdentityManager.redundantSubscription(
@@ -573,5 +585,21 @@ describe('SAMLIdentityManager', function () {
           .to.not.have.been.called
       })
     })
+
+    describe('without a personal subscription', function () {
+      it('should not create redundant personal subscription notification ', async function () {
+        try {
+          await this.SAMLIdentityManager.redundantSubscription(
+            userId,
+            providerId,
+            providerName
+          )
+        } catch (error) {
+          expect(error).to.not.exist
+        }
+        expect(this.NotificationsBuilder.promises.redundantPersonalSubscription)
+          .to.not.have.been.called
+      })
+    })
   })
 })