|
@@ -431,6 +431,93 @@ describe('SubscriptionUpdater', function () {
|
|
|
assert.notEqual(this.subscription.groupPlan, true)
|
|
assert.notEqual(this.subscription.groupPlan, true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ describe('prevent subscription plan downgrade', function () {
|
|
|
|
|
+ describe('prevent professional to standard plan downgrade', function () {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.recurlyPlan.groupPlan = true
|
|
|
|
|
+ this.recurlyPlan.planCode = 'collaborator'
|
|
|
|
|
+ this.recurlySubscription.plan.plan_code = 'collaborator'
|
|
|
|
|
+ this.groupSubscription.planCode = 'professional'
|
|
|
|
|
+ })
|
|
|
|
|
+ it('should not downgrade from professional to standard plan when preventSubscriptionPlanDowngrade=true', async function () {
|
|
|
|
|
+ this.Settings.preventSubscriptionPlanDowngrade = true
|
|
|
|
|
+ await this.SubscriptionUpdater.promises.updateSubscriptionFromRecurly(
|
|
|
|
|
+ this.recurlySubscription,
|
|
|
|
|
+ this.groupSubscription,
|
|
|
|
|
+ {}
|
|
|
|
|
+ )
|
|
|
|
|
+ this.groupSubscription.planCode.should.equal('professional')
|
|
|
|
|
+
|
|
|
|
|
+ const adminUrl = `${this.Settings.adminUrl + '/admin/user/' + this.groupSubscription.admin_id}`
|
|
|
|
|
+ const groupUrl = `${this.Settings.adminUrl + '/admin/group/' + this.groupSubscription._id}`
|
|
|
|
|
+ let message = `\n**Recurly account:** <a href="${this.recurlySubscription?.account?.url}">${this.recurlySubscription?.account?.url}</a>`
|
|
|
|
|
+ message += `\n**Group admin:** <a href="${adminUrl}">${adminUrl}</a>`
|
|
|
|
|
+ message += `\n**Group:** <a href="${groupUrl}">${groupUrl}</a>`
|
|
|
|
|
+ expect(this.Modules.promises.hooks.fire).to.have.been.calledOnce
|
|
|
|
|
+ expect(this.Modules.promises.hooks.fire).to.have.been.calledWith(
|
|
|
|
|
+ 'sendSupportRequest',
|
|
|
|
|
+ {
|
|
|
|
|
+ subject: 'Skipped professional to standard downgrade',
|
|
|
|
|
+ inbox: 'support',
|
|
|
|
|
+ tags: 'Group subscription',
|
|
|
|
|
+ message,
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+ it('should downgrade from professional to standard plan when preventSubscriptionPlanDowngrade=false', async function () {
|
|
|
|
|
+ this.Settings.preventSubscriptionPlanDowngrade = false
|
|
|
|
|
+ await this.SubscriptionUpdater.promises.updateSubscriptionFromRecurly(
|
|
|
|
|
+ this.recurlySubscription,
|
|
|
|
|
+ this.groupSubscription,
|
|
|
|
|
+ {}
|
|
|
|
|
+ )
|
|
|
|
|
+ this.groupSubscription.planCode.should.equal('collaborator')
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ describe('prevent decreasing group size', function () {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.groupSubscription.membersLimit = 3
|
|
|
|
|
+ this.recurlyPlan.groupPlan = true
|
|
|
|
|
+ this.recurlyPlan.membersLimit = 2
|
|
|
|
|
+ })
|
|
|
|
|
+ it('should not reduce member limits when preventSubscriptionPlanDowngrade=true', async function () {
|
|
|
|
|
+ this.Settings.preventSubscriptionPlanDowngrade = true
|
|
|
|
|
+ await this.SubscriptionUpdater.promises.updateSubscriptionFromRecurly(
|
|
|
|
|
+ this.recurlySubscription,
|
|
|
|
|
+ this.groupSubscription,
|
|
|
|
|
+ {}
|
|
|
|
|
+ )
|
|
|
|
|
+ this.groupSubscription.membersLimit.should.equal(3)
|
|
|
|
|
+
|
|
|
|
|
+ const adminUrl = `${this.Settings.adminUrl + '/admin/user/' + this.groupSubscription.admin_id}`
|
|
|
|
|
+ const groupUrl = `${this.Settings.adminUrl + '/admin/group/' + this.groupSubscription._id}`
|
|
|
|
|
+ let message = `\n**Recurly account:** <a href="${this.recurlySubscription?.account?.url}">${this.recurlySubscription?.account?.url}</a>`
|
|
|
|
|
+ message += `\n**Group admin:** <a href="${adminUrl}">${adminUrl}</a>`
|
|
|
|
|
+ message += `\n**Group:** <a href="${groupUrl}">${groupUrl}</a>`
|
|
|
|
|
+ expect(this.Modules.promises.hooks.fire).to.have.been.calledOnce
|
|
|
|
|
+ expect(this.Modules.promises.hooks.fire).to.have.been.calledWith(
|
|
|
|
|
+ 'sendSupportRequest',
|
|
|
|
|
+ {
|
|
|
|
|
+ subject: 'Skipped group size downgrade',
|
|
|
|
|
+ inbox: 'support',
|
|
|
|
|
+ tags: 'Group subscription',
|
|
|
|
|
+ message,
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+ it('should reduce member limits when preventSubscriptionPlanDowngrade=false', async function () {
|
|
|
|
|
+ this.Settings.preventSubscriptionPlanDowngrade = false
|
|
|
|
|
+ await this.SubscriptionUpdater.promises.updateSubscriptionFromRecurly(
|
|
|
|
|
+ this.recurlySubscription,
|
|
|
|
|
+ this.groupSubscription,
|
|
|
|
|
+ {}
|
|
|
|
|
+ )
|
|
|
|
|
+ this.groupSubscription.membersLimit.should.equal(2)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
describe('when the plan allows adding more seats', function () {
|
|
describe('when the plan allows adding more seats', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.membersLimitAddOn = 'add_on1'
|
|
this.membersLimitAddOn = 'add_on1'
|