mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Ensure track changes is enabled for reviewers when switching roles (#22645)
* Ensure track changes is enabled for reviewers when switching roles
* update track_changes.${userId} if track_changes is an object
GitOrigin-RevId: 3e803f4d475dbb67ff85b30095307ea58a07b2bc
This commit is contained in:
committed by
Copybot
parent
61d300de6a
commit
2d57e347aa
@@ -640,33 +640,86 @@ 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,
|
||||
describe('sets a collaborator to reviewer when track changes is enabled for everyone', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectGetter.promises.getProject = sinon.stub().resolves({
|
||||
_id: new ObjectId(),
|
||||
owner_ref: this.addingUserId,
|
||||
name: 'Foo',
|
||||
track_changes: true,
|
||||
})
|
||||
})
|
||||
it('should correctly update the project', 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 },
|
||||
$set: { track_changes: { [this.userId]: true } },
|
||||
$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'
|
||||
)
|
||||
.chain('exec')
|
||||
.resolves({ matchedCount: 1 })
|
||||
await this.CollaboratorsHandler.promises.setCollaboratorPrivilegeLevel(
|
||||
this.projectId,
|
||||
this.userId,
|
||||
'review'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('sets a collaborator to reviewer when track changes is not enabled for everyone', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectGetter.promises.getProject = sinon.stub().resolves({
|
||||
_id: new ObjectId(),
|
||||
owner_ref: this.addingUserId,
|
||||
name: 'Foo',
|
||||
track_changes: {
|
||||
[this.userId]: true,
|
||||
},
|
||||
})
|
||||
})
|
||||
it('should correctly update the project', 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 },
|
||||
$set: { [`track_changes.${this.userId}`]: true },
|
||||
$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 () {
|
||||
|
||||
Reference in New Issue
Block a user