From b26c491eb5f8b4a4dfe0d3d07403232203c94ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Alby?= Date: Tue, 7 Jun 2022 09:45:21 +0200 Subject: [PATCH] Merge pull request #8290 from overleaf/ta-redundant-subscription-saml Don't Create Redundant Subscription Notification on SAML for Group Plans GitOrigin-RevId: 99e66201c9423ff7e849b2d68d96651ad6015fd0 --- .../src/Features/User/SAMLIdentityManager.js | 2 +- .../unit/src/User/SAMLIdentityManagerTests.js | 30 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/services/web/app/src/Features/User/SAMLIdentityManager.js b/services/web/app/src/Features/User/SAMLIdentityManager.js index 543e2b9748..1fc2891cb4 100644 --- a/services/web/app/src/Features/User/SAMLIdentityManager.js +++ b/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( { diff --git a/services/web/test/unit/src/User/SAMLIdentityManagerTests.js b/services/web/test/unit/src/User/SAMLIdentityManagerTests.js index a3f6d05baf..a24f48771d 100644 --- a/services/web/test/unit/src/User/SAMLIdentityManagerTests.js +++ b/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 + }) + }) }) })