|
|
@@ -65,10 +65,8 @@ describe('CollaboratorsHandler', function () {
|
|
|
this.CollaboratorsGetter = {
|
|
|
promises: {
|
|
|
dangerouslyGetAllProjectsUserIsMemberOf: sinon.stub(),
|
|
|
- getMemberIdsWithPrivilegeLevels: sinon.stub().resolves([]),
|
|
|
},
|
|
|
}
|
|
|
- this.EditorRealTimeController = { emitToRoom: sinon.stub() }
|
|
|
this.CollaboratorsHandler = SandboxedModule.require(MODULE_PATH, {
|
|
|
requires: {
|
|
|
'../User/UserGetter': this.UserGetter,
|
|
|
@@ -78,7 +76,6 @@ describe('CollaboratorsHandler', function () {
|
|
|
'../ThirdPartyDataStore/TpdsUpdateSender': this.TpdsUpdateSender,
|
|
|
'../Project/ProjectGetter': this.ProjectGetter,
|
|
|
'../Project/ProjectHelper': this.ProjectHelper,
|
|
|
- '../Editor/EditorRealTimeController': this.EditorRealTimeController,
|
|
|
'./CollaboratorsGetter': this.CollaboratorsGetter,
|
|
|
},
|
|
|
})
|
|
|
@@ -108,7 +105,6 @@ describe('CollaboratorsHandler', function () {
|
|
|
{
|
|
|
$pull: {
|
|
|
collaberator_refs: this.userId,
|
|
|
- reviewer_refs: this.userId,
|
|
|
readOnly_refs: this.userId,
|
|
|
pendingEditor_refs: this.userId,
|
|
|
tokenAccessReadOnly_refs: this.userId,
|
|
|
@@ -152,7 +148,6 @@ describe('CollaboratorsHandler', function () {
|
|
|
},
|
|
|
$pull: {
|
|
|
collaberator_refs: this.userId,
|
|
|
- reviewer_refs: this.userId,
|
|
|
readOnly_refs: this.userId,
|
|
|
pendingEditor_refs: this.userId,
|
|
|
tokenAccessReadOnly_refs: this.userId,
|
|
|
@@ -188,7 +183,6 @@ describe('CollaboratorsHandler', function () {
|
|
|
{
|
|
|
$pull: {
|
|
|
collaberator_refs: this.userId,
|
|
|
- reviewer_refs: this.userId,
|
|
|
readOnly_refs: this.userId,
|
|
|
pendingEditor_refs: this.userId,
|
|
|
tokenAccessReadOnly_refs: this.userId,
|
|
|
@@ -308,43 +302,6 @@ describe('CollaboratorsHandler', function () {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- describe('as reviewer', function () {
|
|
|
- beforeEach(async function () {
|
|
|
- this.ProjectMock.expects('updateOne')
|
|
|
- .withArgs(
|
|
|
- {
|
|
|
- _id: this.project._id,
|
|
|
- },
|
|
|
- {
|
|
|
- track_changes: { [this.userId]: true },
|
|
|
- $addToSet: { reviewer_refs: this.userId },
|
|
|
- }
|
|
|
- )
|
|
|
- .chain('exec')
|
|
|
- .resolves()
|
|
|
- await this.CollaboratorsHandler.promises.addUserIdToProject(
|
|
|
- this.project._id,
|
|
|
- this.addingUserId,
|
|
|
- this.userId,
|
|
|
- 'review'
|
|
|
- )
|
|
|
- })
|
|
|
-
|
|
|
- it('should update the client with new track changes settings', function () {
|
|
|
- return this.EditorRealTimeController.emitToRoom
|
|
|
- .calledWith(this.project._id, 'toggle-track-changes', {
|
|
|
- [this.userId]: true,
|
|
|
- })
|
|
|
- .should.equal(true)
|
|
|
- })
|
|
|
-
|
|
|
- it('should flush the project to the TPDS', function () {
|
|
|
- expect(
|
|
|
- this.TpdsProjectFlusher.promises.flushProjectToTpds
|
|
|
- ).to.have.been.calledWith(this.project._id)
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
describe('with invalid privilegeLevel', function () {
|
|
|
it('should call the callback with an error', async function () {
|
|
|
await expect(
|
|
|
@@ -448,7 +405,6 @@ describe('CollaboratorsHandler', function () {
|
|
|
{
|
|
|
$pull: {
|
|
|
collaberator_refs: this.userId,
|
|
|
- reviewer_refs: this.userId,
|
|
|
readOnly_refs: this.userId,
|
|
|
pendingEditor_refs: this.userId,
|
|
|
tokenAccessReadOnly_refs: this.userId,
|
|
|
@@ -590,14 +546,12 @@ describe('CollaboratorsHandler', function () {
|
|
|
$or: [
|
|
|
{ collaberator_refs: this.userId },
|
|
|
{ readOnly_refs: this.userId },
|
|
|
- { reviewer_refs: this.userId },
|
|
|
],
|
|
|
},
|
|
|
{
|
|
|
$pull: {
|
|
|
collaberator_refs: this.userId,
|
|
|
pendingEditor_refs: this.userId,
|
|
|
- reviewer_refs: this.userId,
|
|
|
},
|
|
|
$addToSet: { readOnly_refs: this.userId },
|
|
|
}
|
|
|
@@ -619,14 +573,12 @@ describe('CollaboratorsHandler', function () {
|
|
|
$or: [
|
|
|
{ collaberator_refs: this.userId },
|
|
|
{ readOnly_refs: this.userId },
|
|
|
- { reviewer_refs: this.userId },
|
|
|
],
|
|
|
},
|
|
|
{
|
|
|
$addToSet: { collaberator_refs: this.userId },
|
|
|
$pull: {
|
|
|
readOnly_refs: this.userId,
|
|
|
- reviewer_refs: this.userId,
|
|
|
pendingEditor_refs: this.userId,
|
|
|
},
|
|
|
}
|
|
|
@@ -640,35 +592,6 @@ describe('CollaboratorsHandler', function () {
|
|
|
)
|
|
|
})
|
|
|
|
|
|
- it('sets a collaborator to reviewer', async function () {
|
|
|
- this.ProjectMock.expects('updateOne')
|
|
|
- .withArgs(
|
|
|
- {
|
|
|
- _id: this.projectId,
|
|
|
- $or: [
|
|
|
- { collaberator_refs: this.userId },
|
|
|
- { readOnly_refs: this.userId },
|
|
|
- { reviewer_refs: this.userId },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- $addToSet: { reviewer_refs: this.userId },
|
|
|
- $pull: {
|
|
|
- readOnly_refs: this.userId,
|
|
|
- collaberator_refs: this.userId,
|
|
|
- pendingEditor_refs: this.userId,
|
|
|
- },
|
|
|
- }
|
|
|
- )
|
|
|
- .chain('exec')
|
|
|
- .resolves({ matchedCount: 1 })
|
|
|
- await this.CollaboratorsHandler.promises.setCollaboratorPrivilegeLevel(
|
|
|
- this.projectId,
|
|
|
- this.userId,
|
|
|
- 'review'
|
|
|
- )
|
|
|
- })
|
|
|
-
|
|
|
it('sets a collaborator to read-only as a pendingEditor', async function () {
|
|
|
this.ProjectMock.expects('updateOne')
|
|
|
.withArgs(
|
|
|
@@ -677,7 +600,6 @@ describe('CollaboratorsHandler', function () {
|
|
|
$or: [
|
|
|
{ collaberator_refs: this.userId },
|
|
|
{ readOnly_refs: this.userId },
|
|
|
- { reviewer_refs: this.userId },
|
|
|
],
|
|
|
},
|
|
|
{
|
|
|
@@ -687,7 +609,6 @@ describe('CollaboratorsHandler', function () {
|
|
|
},
|
|
|
$pull: {
|
|
|
collaberator_refs: this.userId,
|
|
|
- reviewer_refs: this.userId,
|
|
|
},
|
|
|
}
|
|
|
)
|