Merge pull request #23131 from overleaf/kh-teardown-link-sharing-split-tests

[web] tear down link sharing split tests

GitOrigin-RevId: 449e9f368405aea1500035269428e7ae0c37d8fb
This commit is contained in:
Kristina
2025-02-03 10:09:28 +01:00
committed by Copybot
parent 8831fb9a18
commit e3fdcdd601
24 changed files with 806 additions and 2264 deletions

View File

@@ -1031,108 +1031,56 @@ describe('ProjectController', function () {
})
})
describe('link sharing changes active', function () {
describe('when user is a read write token member (and not already a named editor)', function () {
beforeEach(function () {
this.SplitTestHandler.promises.getAssignmentForUser.callsFake(
async (userId, test) => {
if (test === 'link-sharing-warning') {
return { variant: 'active' }
}
}
this.CollaboratorsGetter.promises.userIsTokenMember.resolves(true)
this.CollaboratorsGetter.promises.userIsReadWriteTokenMember.resolves(
true
)
this.CollaboratorsGetter.promises.isUserInvitedReadWriteMemberOfProject.resolves(
false
)
})
describe('when user is a read write token member (and not already a named editor)', function () {
beforeEach(function () {
this.CollaboratorsGetter.promises.userIsTokenMember.resolves(true)
this.CollaboratorsGetter.promises.userIsReadWriteTokenMember.resolves(
true
)
this.CollaboratorsGetter.promises.isUserInvitedReadWriteMemberOfProject.resolves(
false
)
})
it('should redirect to the sharing-updates page', function (done) {
this.res.redirect = url => {
expect(url).to.equal(`/project/${this.project_id}/sharing-updates`)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
})
describe('when user is a read write token member but also a named editor', function () {
beforeEach(function () {
this.CollaboratorsGetter.promises.userIsTokenMember.resolves(true)
this.CollaboratorsGetter.promises.userIsReadWriteTokenMember.resolves(
true
)
this.CollaboratorsGetter.promises.isUserInvitedReadWriteMemberOfProject.resolves(
true
)
})
it('should not redirect to the sharing-updates page, and should load the editor', function (done) {
this.res.render = (pageName, opts) => {
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should redirect to the sharing-updates page', function (done) {
this.res.redirect = url => {
expect(url).to.equal(`/project/${this.project_id}/sharing-updates`)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
})
describe('link sharing enforcement', function () {
describe('when not active (default)', function () {
beforeEach(function () {
this.SplitTestHandler.promises.getAssignmentForUser.callsFake(
async (userId, test) => {
if (test === 'link-sharing-warning') {
return { variant: 'active' }
} else if (test === 'link-sharing-enforcement') {
return { variant: 'default' }
}
}
)
})
it('should not call the collaborator limit enforcement check', function (done) {
this.res.render = (pageName, opts) => {
this.Modules.promises.hooks.fire.should.not.have.been.calledWith(
'enforceCollaboratorLimit'
)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
describe('when user is a read write token member but also a named editor', function () {
beforeEach(function () {
this.CollaboratorsGetter.promises.userIsTokenMember.resolves(true)
this.CollaboratorsGetter.promises.userIsReadWriteTokenMember.resolves(
true
)
this.CollaboratorsGetter.promises.isUserInvitedReadWriteMemberOfProject.resolves(
true
)
})
describe('when active', function () {
beforeEach(function () {
this.SplitTestHandler.promises.getAssignmentForUser.callsFake(
async (userId, test) => {
if (test === 'link-sharing-warning') {
return { variant: 'active' }
} else if (test === 'link-sharing-enforcement') {
return { variant: 'active' }
}
}
)
})
it('should call the collaborator limit enforcement check', function (done) {
this.res.render = (pageName, opts) => {
this.Modules.promises.hooks.fire.should.have.been.calledWith(
'enforceCollaboratorLimit',
this.project_id
)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
it('should not redirect to the sharing-updates page, and should load the editor', function (done) {
this.res.render = (pageName, opts) => {
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
})
it('should call the collaborator limit enforcement check', function (done) {
this.res.render = (pageName, opts) => {
this.Modules.promises.hooks.fire.should.have.been.calledWith(
'enforceCollaboratorLimit',
this.project_id
)
done()
}
this.ProjectController.loadEditor(this.req, this.res)
})
describe('chatEnabled flag', function () {
it('should be set to false when the feature is disabled', function (done) {
this.Features.hasFeature = sinon.stub().withArgs('chat').returns(false)