mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-28 19:41:33 +02:00
Merge pull request #23203 from overleaf/ii-flexible-group-licensing-no-billing-details
[web] FL handle subscriptions with missing billing info GitOrigin-RevId: 34209299c039992a80da5739e086beb5d0ede7b0
This commit is contained in:
@@ -99,6 +99,7 @@ describe('RecurlyClient', function () {
|
||||
let client
|
||||
this.client = client = {
|
||||
getAccount: sinon.stub(),
|
||||
getBillingInfo: sinon.stub(),
|
||||
listAccountSubscriptions: sinon.stub(),
|
||||
previewSubscriptionChange: sinon.stub(),
|
||||
}
|
||||
@@ -108,6 +109,9 @@ describe('RecurlyClient', function () {
|
||||
return client
|
||||
},
|
||||
}
|
||||
this.Errors = {
|
||||
MissingBillingInfoError: class MissingBillingInfoError extends Error {},
|
||||
}
|
||||
|
||||
return (this.RecurlyClient = SandboxedModule.require(MODULE_PATH, {
|
||||
globals: {
|
||||
@@ -124,6 +128,7 @@ describe('RecurlyClient', function () {
|
||||
debug: sinon.stub(),
|
||||
},
|
||||
'../User/UserGetter': this.UserGetter,
|
||||
'./Errors': this.Errors,
|
||||
},
|
||||
}))
|
||||
})
|
||||
@@ -463,4 +468,22 @@ describe('RecurlyClient', function () {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('getPaymentMethod', function () {
|
||||
it('should throw MissingBillingInfoError', async function () {
|
||||
this.client.getBillingInfo = sinon
|
||||
.stub()
|
||||
.throws(new recurly.errors.NotFoundError())
|
||||
await expect(
|
||||
this.RecurlyClient.promises.getPaymentMethod(this.user._id)
|
||||
).to.be.rejectedWith(this.Errors.MissingBillingInfoError)
|
||||
})
|
||||
|
||||
it('should rethrow errors different than MissingBillingInfoError', async function () {
|
||||
this.client.getBillingInfo = sinon.stub().throws(new Error())
|
||||
await expect(
|
||||
this.RecurlyClient.promises.getPaymentMethod(this.user._id)
|
||||
).to.be.rejectedWith(Error)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -103,7 +103,13 @@ describe('SubscriptionGroupController', function () {
|
||||
},
|
||||
}
|
||||
|
||||
this.RecurlyClient = {}
|
||||
this.paymentMethod = { cardType: 'Visa', lastFour: '1111' }
|
||||
|
||||
this.RecurlyClient = {
|
||||
promises: {
|
||||
getPaymentMethod: sinon.stub().resolves(this.paymentMethod),
|
||||
},
|
||||
}
|
||||
|
||||
this.SubscriptionController = {}
|
||||
|
||||
@@ -113,6 +119,10 @@ describe('SubscriptionGroupController', function () {
|
||||
isProfessionalGroupPlan: sinon.stub().returns(false),
|
||||
}
|
||||
|
||||
this.Errors = {
|
||||
MissingBillingInfoError: class MissingBillingInfoError extends Error {},
|
||||
}
|
||||
|
||||
this.Controller = await esmock.strict(modulePath, {
|
||||
'../../../../app/src/Features/Subscription/SubscriptionGroupHandler':
|
||||
this.SubscriptionGroupHandler,
|
||||
@@ -135,6 +145,7 @@ describe('SubscriptionGroupController', function () {
|
||||
'../../../../app/src/Features/Subscription/RecurlyClient':
|
||||
this.RecurlyClient,
|
||||
'../../../../app/src/Features/Subscription/PlansHelper': this.PlansHelper,
|
||||
'../../../../app/src/Features/Subscription/Errors': this.Errors,
|
||||
'../../../../app/src/models/Subscription': this.SubscriptionModel,
|
||||
'@overleaf/logger': {
|
||||
err: sinon.stub(),
|
||||
@@ -375,6 +386,23 @@ describe('SubscriptionGroupController', function () {
|
||||
|
||||
this.Controller.addSeatsToGroupSubscription(this.req, res)
|
||||
})
|
||||
|
||||
it('should redirect to missing billing information page when billing information is missing', function (done) {
|
||||
this.RecurlyClient.promises.getPaymentMethod = sinon
|
||||
.stub()
|
||||
.throws(new this.Errors.MissingBillingInfoError())
|
||||
|
||||
const res = {
|
||||
redirect: url => {
|
||||
url.should.equal(
|
||||
'/user/subscription/group/missing-billing-information'
|
||||
)
|
||||
done()
|
||||
},
|
||||
}
|
||||
|
||||
this.Controller.addSeatsToGroupSubscription(this.req, res)
|
||||
})
|
||||
})
|
||||
|
||||
describe('previewAddSeatsSubscriptionChange', function () {
|
||||
@@ -549,6 +577,21 @@ describe('SubscriptionGroupController', function () {
|
||||
|
||||
this.Controller.subscriptionUpgradePage(this.req, res)
|
||||
})
|
||||
|
||||
it('should redirect to missing billing information page when billing information is missing', function (done) {
|
||||
this.RecurlyClient.promises.getPaymentMethod = sinon
|
||||
.stub()
|
||||
.throws(new this.Errors.MissingBillingInfoError())
|
||||
|
||||
const res = {
|
||||
redirect: url => {
|
||||
url.should.equal('/user/subscription')
|
||||
done()
|
||||
},
|
||||
}
|
||||
|
||||
this.Controller.subscriptionUpgradePage(this.req, res)
|
||||
})
|
||||
})
|
||||
|
||||
describe('upgradeSubscription', function () {
|
||||
|
||||
@@ -302,6 +302,7 @@ describe('SubscriptionGroupHandler', function () {
|
||||
)
|
||||
|
||||
expect(data).to.deep.equal({
|
||||
userId: this.adminUser_id,
|
||||
subscription: { groupPlan: true },
|
||||
plan: {
|
||||
membersLimit: 5,
|
||||
|
||||
Reference in New Issue
Block a user