Merge pull request #26968 from overleaf/em-revert-jul8
Revert bad deploy GitOrigin-RevId: fd6227cf4fde7fd8053b47365154d59d15fa115e
This commit is contained in:
@@ -73,8 +73,6 @@ describe('SubscriptionGroupController', function () {
|
||||
.resolves(ctx.previewSubscriptionChangeData),
|
||||
checkBillingInfoExistence: sinon.stub().resolves(ctx.paymentMethod),
|
||||
updateSubscriptionPaymentTerms: sinon.stub().resolves(),
|
||||
ensureSubscriptionHasAdditionalLicenseAddOnWhenCollectionMethodIsManual:
|
||||
sinon.stub().resolves(),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -107,6 +105,12 @@ describe('SubscriptionGroupController', function () {
|
||||
},
|
||||
}
|
||||
|
||||
ctx.SplitTestHandler = {
|
||||
promises: {
|
||||
getAssignment: sinon.stub().resolves({ variant: 'enabled' }),
|
||||
},
|
||||
}
|
||||
|
||||
ctx.UserGetter = {
|
||||
promises: {
|
||||
getUserEmail: sinon.stub().resolves(ctx.user.email),
|
||||
@@ -136,7 +140,6 @@ describe('SubscriptionGroupController', function () {
|
||||
InactiveError: class extends Error {},
|
||||
SubtotalLimitExceededError: class extends Error {},
|
||||
HasPastDueInvoiceError: class extends Error {},
|
||||
HasNoAdditionalLicenseWhenManuallyCollectedError: class extends Error {},
|
||||
}
|
||||
|
||||
vi.doMock(
|
||||
@@ -168,6 +171,13 @@ describe('SubscriptionGroupController', function () {
|
||||
default: ctx.Modules,
|
||||
}))
|
||||
|
||||
vi.doMock(
|
||||
'../../../../app/src/Features/SplitTests/SplitTestHandler',
|
||||
() => ({
|
||||
default: ctx.SplitTestHandler,
|
||||
})
|
||||
)
|
||||
|
||||
vi.doMock('../../../../app/src/Features/User/UserGetter', () => ({
|
||||
default: ctx.UserGetter,
|
||||
}))
|
||||
@@ -446,9 +456,6 @@ describe('SubscriptionGroupController', function () {
|
||||
ctx.SubscriptionGroupHandler.promises.checkBillingInfoExistence
|
||||
.calledWith(ctx.recurlySubscription, ctx.adminUserId)
|
||||
.should.equal(true)
|
||||
ctx.SubscriptionGroupHandler.promises.ensureSubscriptionHasAdditionalLicenseAddOnWhenCollectionMethodIsManual
|
||||
.calledWith(ctx.recurlySubscription)
|
||||
.should.equal(true)
|
||||
page.should.equal('subscriptions/add-seats')
|
||||
props.subscriptionId.should.equal(ctx.subscriptionId)
|
||||
props.groupName.should.equal(ctx.subscription.teamName)
|
||||
@@ -514,28 +521,6 @@ describe('SubscriptionGroupController', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it('should redirect to manually collected subscription error page when collection method is manual and has no additional license add-on', async function (ctx) {
|
||||
await new Promise(resolve => {
|
||||
ctx.SubscriptionGroupHandler.promises.ensureSubscriptionHasAdditionalLicenseAddOnWhenCollectionMethodIsManual =
|
||||
sinon
|
||||
.stub()
|
||||
.throws(
|
||||
new ctx.Errors.HasNoAdditionalLicenseWhenManuallyCollectedError()
|
||||
)
|
||||
|
||||
const res = {
|
||||
redirect: url => {
|
||||
url.should.equal(
|
||||
'/user/subscription/group/manually-collected-subscription'
|
||||
)
|
||||
resolve()
|
||||
},
|
||||
}
|
||||
|
||||
ctx.Controller.addSeatsToGroupSubscription(ctx.req, res)
|
||||
})
|
||||
})
|
||||
|
||||
it('should redirect to subscription page when there is a pending change', async function (ctx) {
|
||||
await new Promise(resolve => {
|
||||
ctx.SubscriptionGroupHandler.promises.ensureSubscriptionHasNoPendingChanges =
|
||||
|
||||
@@ -806,49 +806,6 @@ describe('SubscriptionGroupHandler', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('ensureSubscriptionHasAdditionalLicenseAddOnWhenCollectionMethodIsManual', function () {
|
||||
it('should throw if the subscription is manually collected and has no additional license add-on', async function () {
|
||||
await expect(
|
||||
this.Handler.promises.ensureSubscriptionHasAdditionalLicenseAddOnWhenCollectionMethodIsManual(
|
||||
{
|
||||
isCollectionMethodManual: true,
|
||||
hasAddOn: sinon
|
||||
.stub()
|
||||
.withArgs('additional-license')
|
||||
.returns(false),
|
||||
}
|
||||
)
|
||||
).to.be.rejectedWith(
|
||||
'This subscription is being collected manually has no "additional-license" add-on'
|
||||
)
|
||||
})
|
||||
|
||||
it('should not throw if the subscription is not manually collected and has no additional license add-on and ', async function () {
|
||||
await expect(
|
||||
this.Handler.promises.ensureSubscriptionHasAdditionalLicenseAddOnWhenCollectionMethodIsManual(
|
||||
{
|
||||
isCollectionMethodManual: false,
|
||||
hasAddOn: sinon
|
||||
.stub()
|
||||
.withArgs('additional-license')
|
||||
.returns(false),
|
||||
}
|
||||
)
|
||||
).to.not.be.rejected
|
||||
})
|
||||
|
||||
it('should not throw if the subscription is not manually collected and has additional license add-on', async function () {
|
||||
await expect(
|
||||
this.Handler.promises.ensureSubscriptionHasAdditionalLicenseAddOnWhenCollectionMethodIsManual(
|
||||
{
|
||||
isCollectionMethodManual: true,
|
||||
hasAddOn: sinon.stub().withArgs('additional-license').returns(true),
|
||||
}
|
||||
)
|
||||
).to.not.be.rejected
|
||||
})
|
||||
})
|
||||
|
||||
describe('getGroupPlanUpgradePreview', function () {
|
||||
it('should generate preview for subscription upgrade', async function () {
|
||||
const result = await this.Handler.promises.getGroupPlanUpgradePreview(
|
||||
|
||||
@@ -48,7 +48,7 @@ describe('UserMembershipHandler', function () {
|
||||
|
||||
this.UserMembershipViewModel = {
|
||||
promises: {
|
||||
buildAsync: sinon.stub().resolves([{ _id: 'mock-member-id' }]),
|
||||
buildAsync: sinon.stub().resolves({ _id: 'mock-member-id' }),
|
||||
},
|
||||
build: sinon.stub().returns(this.newUser),
|
||||
}
|
||||
@@ -118,26 +118,26 @@ describe('UserMembershipHandler', function () {
|
||||
this.subscription,
|
||||
EntityConfigs.group
|
||||
)
|
||||
const expectedCallcount =
|
||||
this.subscription.member_ids.length +
|
||||
this.subscription.invited_emails.length +
|
||||
this.subscription.teamInvites.length
|
||||
expect(
|
||||
this.UserMembershipViewModel.promises.buildAsync
|
||||
).to.be.calledOnceWith(
|
||||
this.subscription.invited_emails.concat(
|
||||
this.subscription.teamInvites[0].email,
|
||||
this.subscription.member_ids
|
||||
)
|
||||
)
|
||||
this.UserMembershipViewModel.promises.buildAsync.callCount
|
||||
).to.equal(expectedCallcount)
|
||||
})
|
||||
})
|
||||
|
||||
describe('group managers', function () {
|
||||
describe('group mamagers', function () {
|
||||
it('build view model for all managers', async function () {
|
||||
await this.UserMembershipHandler.promises.getUsers(
|
||||
this.subscription,
|
||||
EntityConfigs.groupManagers
|
||||
)
|
||||
const expectedCallcount = this.subscription.manager_ids.length
|
||||
expect(
|
||||
this.UserMembershipViewModel.promises.buildAsync
|
||||
).to.be.calledOnceWith(this.subscription.manager_ids)
|
||||
this.UserMembershipViewModel.promises.buildAsync.callCount
|
||||
).to.equal(expectedCallcount)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -147,9 +147,11 @@ describe('UserMembershipHandler', function () {
|
||||
this.institution,
|
||||
EntityConfigs.institution
|
||||
)
|
||||
|
||||
const expectedCallcount = this.institution.managerIds.length
|
||||
expect(
|
||||
this.UserMembershipViewModel.promises.buildAsync
|
||||
).to.be.calledOnceWith(this.institution.managerIds)
|
||||
this.UserMembershipViewModel.promises.buildAsync.callCount
|
||||
).to.equal(expectedCallcount)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -25,7 +25,7 @@ const {
|
||||
|
||||
describe('UserMembershipViewModel', function () {
|
||||
beforeEach(function () {
|
||||
this.UserGetter = { getUsers: sinon.stub() }
|
||||
this.UserGetter = { getUser: sinon.stub() }
|
||||
this.UserMembershipViewModel = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'mongodb-legacy': { ObjectId },
|
||||
@@ -87,10 +87,9 @@ describe('UserMembershipViewModel', function () {
|
||||
})
|
||||
|
||||
it('build email', function (done) {
|
||||
this.UserGetter.getUsers.yields(null, [])
|
||||
return this.UserMembershipViewModel.buildAsync(
|
||||
[this.email],
|
||||
(error, [viewModel]) => {
|
||||
this.email,
|
||||
(error, viewModel) => {
|
||||
assertCalledWith(this.UserMembershipViewModel.build, this.email)
|
||||
return done()
|
||||
}
|
||||
@@ -98,10 +97,9 @@ describe('UserMembershipViewModel', function () {
|
||||
})
|
||||
|
||||
it('build user', function (done) {
|
||||
this.UserGetter.getUsers.yields(null, [])
|
||||
return this.UserMembershipViewModel.buildAsync(
|
||||
[this.user],
|
||||
(error, [viewModel]) => {
|
||||
this.user,
|
||||
(error, viewModel) => {
|
||||
assertCalledWith(this.UserMembershipViewModel.build, this.user)
|
||||
return done()
|
||||
}
|
||||
@@ -109,34 +107,30 @@ describe('UserMembershipViewModel', function () {
|
||||
})
|
||||
|
||||
it('build user id', function (done) {
|
||||
const user = {
|
||||
...this.user,
|
||||
_id: new ObjectId(),
|
||||
}
|
||||
this.UserGetter.getUsers.yields(null, [user])
|
||||
this.UserGetter.getUser.yields(null, this.user)
|
||||
return this.UserMembershipViewModel.buildAsync(
|
||||
[user._id],
|
||||
(error, [viewModel]) => {
|
||||
new ObjectId(),
|
||||
(error, viewModel) => {
|
||||
expect(error).not.to.exist
|
||||
assertNotCalled(this.UserMembershipViewModel.build)
|
||||
expect(viewModel._id.toString()).to.equal(user._id.toString())
|
||||
expect(viewModel.email).to.equal(user.email)
|
||||
expect(viewModel.first_name).to.equal(user.first_name)
|
||||
expect(viewModel._id).to.equal(this.user._id)
|
||||
expect(viewModel.email).to.equal(this.user.email)
|
||||
expect(viewModel.first_name).to.equal(this.user.first_name)
|
||||
expect(viewModel.invite).to.equal(false)
|
||||
expect(viewModel.email).to.exist
|
||||
expect(viewModel.enrollment).to.exist
|
||||
expect(viewModel.enrollment).to.deep.equal(user.enrollment)
|
||||
expect(viewModel.enrollment).to.deep.equal(this.user.enrollment)
|
||||
return done()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('build user id with error', function (done) {
|
||||
this.UserGetter.getUsers.yields(new Error('nope'), [])
|
||||
this.UserGetter.getUser.yields(new Error('nope'))
|
||||
const userId = new ObjectId()
|
||||
return this.UserMembershipViewModel.buildAsync(
|
||||
[userId],
|
||||
(error, [viewModel]) => {
|
||||
userId,
|
||||
(error, viewModel) => {
|
||||
expect(error).not.to.exist
|
||||
assertNotCalled(this.UserMembershipViewModel.build)
|
||||
expect(viewModel._id).to.equal(userId.toString())
|
||||
|
||||
Reference in New Issue
Block a user