|
@@ -507,6 +507,28 @@ describe('SubscriptionController', function () {
|
|
|
it('should load an empty list of groups with settings available', function (ctx) {
|
|
it('should load an empty list of groups with settings available', function (ctx) {
|
|
|
expect(ctx.data.groupSettingsEnabledFor).to.deep.equal([])
|
|
expect(ctx.data.groupSettingsEnabledFor).to.deep.equal([])
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ describe('when errorCode query param is present', function () {
|
|
|
|
|
+ beforeEach(async function (ctx) {
|
|
|
|
|
+ ctx.req.query.errorCode = 'payment_failed'
|
|
|
|
|
+ await new Promise((resolve, reject) => {
|
|
|
|
|
+ ctx.res.render = (view, data) => {
|
|
|
|
|
+ ctx.data = data
|
|
|
|
|
+ expect(view).to.equal('subscriptions/dashboard-react')
|
|
|
|
|
+ resolve()
|
|
|
|
|
+ }
|
|
|
|
|
+ ctx.SubscriptionController.userSubscriptionPage(
|
|
|
|
|
+ ctx.req,
|
|
|
|
|
+ ctx.res,
|
|
|
|
|
+ ctx.rejectOnError(reject)
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('should pass redirectedPaymentErrorCode to the view', function (ctx) {
|
|
|
|
|
+ expect(ctx.data.redirectedPaymentErrorCode).to.equal('payment_failed')
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('updateAccountEmailAddress via put', function () {
|
|
describe('updateAccountEmailAddress via put', function () {
|
|
@@ -1527,13 +1549,43 @@ describe('SubscriptionController', function () {
|
|
|
await ctx.SubscriptionController.previewAddonPurchase(ctx.req, ctx.res)
|
|
await ctx.SubscriptionController.previewAddonPurchase(ctx.req, ctx.res)
|
|
|
|
|
|
|
|
expect(ctx.res.render).to.have.been.calledWith(
|
|
expect(ctx.res.render).to.have.been.calledWith(
|
|
|
- 'subscriptions/preview-change'
|
|
|
|
|
|
|
+ 'subscriptions/preview-change',
|
|
|
|
|
+ sinon.match({
|
|
|
|
|
+ changePreview: sinon.match.object,
|
|
|
|
|
+ purchaseReferrer: 'fake-referrer',
|
|
|
|
|
+ redirectedPaymentErrorCode: undefined,
|
|
|
|
|
+ })
|
|
|
)
|
|
)
|
|
|
expect(
|
|
expect(
|
|
|
ctx.SubscriptionHandler.promises.previewAddonPurchase
|
|
ctx.SubscriptionHandler.promises.previewAddonPurchase
|
|
|
).to.have.been.calledWith(ctx.user._id, 'assistant')
|
|
).to.have.been.calledWith(ctx.user._id, 'assistant')
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ it('should pass redirectedPaymentErrorCode to the view when errorCode query param is present', async function (ctx) {
|
|
|
|
|
+ const normalSubscription = {
|
|
|
|
|
+ _id: 'sub-123',
|
|
|
|
|
+ customAccount: false,
|
|
|
|
|
+ collectionMethod: 'automatic',
|
|
|
|
|
+ }
|
|
|
|
|
+ ctx.SubscriptionLocator.promises.getUsersSubscription.resolves(
|
|
|
|
|
+ normalSubscription
|
|
|
|
|
+ )
|
|
|
|
|
+ ctx.req.query.errorCode = 'payment_failed'
|
|
|
|
|
+
|
|
|
|
|
+ ctx.res.render = sinon.stub()
|
|
|
|
|
+
|
|
|
|
|
+ await ctx.SubscriptionController.previewAddonPurchase(ctx.req, ctx.res)
|
|
|
|
|
+
|
|
|
|
|
+ expect(ctx.res.render).to.have.been.calledWith(
|
|
|
|
|
+ 'subscriptions/preview-change',
|
|
|
|
|
+ sinon.match({
|
|
|
|
|
+ changePreview: sinon.match.object,
|
|
|
|
|
+ purchaseReferrer: 'fake-referrer',
|
|
|
|
|
+ redirectedPaymentErrorCode: 'payment_failed',
|
|
|
|
|
+ })
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it('should proceed with preview when customAccount is undefined and collectionMethod is automatic', async function (ctx) {
|
|
it('should proceed with preview when customAccount is undefined and collectionMethod is automatic', async function (ctx) {
|
|
|
const normalSubscription = {
|
|
const normalSubscription = {
|
|
|
_id: 'sub-123',
|
|
_id: 'sub-123',
|