Allow reviewers to resolve their own comments (#22582)

* Allow reviewers to resolve their own comments

* check if reviewer is comment author

* add missing translation

* add CommentsController tests

* added DocumentManagerTests

* added HttpControllerTests

* Add AuthorizationManagerTests

* added AuthorizationMiddlewareTests

* added DocumentUpdaterHandler test

* fix test descriptions

* remove returns from CommentsControllerTests

* use ensureUserCanResolveThread in authorizationMiddleware

* move canResolveThread to AuthorizationManager

* commentId as param in NotFoundError

* refactor canUserResolveThread

GitOrigin-RevId: 131c3d1eb9ac916eaaa9221d351a92bc07b80cdc
This commit is contained in:
Domagoj Kriskovic
2025-01-13 14:26:13 +01:00
committed by Copybot
parent 19ee929d65
commit 30ebad91b7
12 changed files with 486 additions and 1 deletions
@@ -184,6 +184,65 @@ describe('HttpController', function () {
})
})
describe('getComment', function () {
beforeEach(function () {
this.ranges = {
changes: 'mock',
comments: [
{
id: 'comment-id-1',
},
{
id: 'comment-id-2',
},
],
}
this.req = {
params: {
project_id: this.project_id,
doc_id: this.doc_id,
comment_id: this.comment_id,
},
query: {},
body: {},
}
})
beforeEach(function () {
this.DocumentManager.getCommentWithLock = sinon
.stub()
.callsArgWith(3, null, this.ranges.comments[0])
this.HttpController.getComment(this.req, this.res, this.next)
})
it('should get the comment', function () {
this.DocumentManager.getCommentWithLock
.calledWith(this.project_id, this.doc_id, this.comment_id)
.should.equal(true)
})
it('should return the comment as JSON', function () {
this.res.json
.calledWith({
id: 'comment-id-1',
})
.should.equal(true)
})
it('should log the request', function () {
this.logger.debug
.calledWith(
{
projectId: this.project_id,
docId: this.doc_id,
commentId: this.comment_id,
},
'getting comment via http'
)
.should.equal(true)
})
})
describe('setDoc', function () {
beforeEach(function () {
this.lines = ['one', 'two', 'three']