mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #26968 from overleaf/em-revert-jul8
Revert bad deploy GitOrigin-RevId: fd6227cf4fde7fd8053b47365154d59d15fa115e
This commit is contained in:
@@ -14,6 +14,9 @@ describe('<AddSeats />', function () {
|
||||
win.metaAttributesCache.set('ol-totalLicenses', this.totalLicenses)
|
||||
win.metaAttributesCache.set('ol-isProfessional', false)
|
||||
win.metaAttributesCache.set('ol-isCollectionMethodManual', true)
|
||||
win.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'flexible-group-licensing-for-manually-billed-subscriptions': 'enabled',
|
||||
})
|
||||
})
|
||||
|
||||
cy.mount(
|
||||
|
||||
+22
@@ -61,4 +61,26 @@ describe('MemberStatus', function () {
|
||||
cy.get('.security-state-not-managed').contains('Managed')
|
||||
})
|
||||
})
|
||||
|
||||
describe('with the group admin', function () {
|
||||
const user: User = {
|
||||
_id: 'some-user',
|
||||
email: 'some.user@example.com',
|
||||
first_name: 'Some',
|
||||
last_name: 'User',
|
||||
invite: false,
|
||||
last_active_at: new Date(),
|
||||
enrollment: undefined,
|
||||
isEntityAdmin: true,
|
||||
}
|
||||
beforeEach(function () {
|
||||
cy.mount(<ManagedUserStatus user={user} />)
|
||||
})
|
||||
|
||||
it('should render no state indicator', function () {
|
||||
cy.get('.security-state-group-admin')
|
||||
.contains('Managed')
|
||||
.should('not.exist')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
-10
@@ -121,16 +121,6 @@ describe('MembersList', function () {
|
||||
users[1].last_name
|
||||
)
|
||||
})
|
||||
it('should render the pagination navigation', function () {
|
||||
cy.window().then(win => {
|
||||
win.metaAttributesCache.set(
|
||||
'ol-users',
|
||||
Array.from({ length: 50 }).flatMap(() => users.flat())
|
||||
)
|
||||
})
|
||||
mountManagedUsersList()
|
||||
cy.findByRole('navigation', { name: /pagination navigation/i })
|
||||
})
|
||||
})
|
||||
|
||||
describe('empty user list', function () {
|
||||
|
||||
@@ -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