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:
ilkin-overleaf
2025-02-05 09:05:50 +00:00
committed by Copybot
parent 72be034435
commit 16130b79db
14 changed files with 242 additions and 2 deletions
@@ -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 () {