diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-05 17:22:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-05-05 17:22:11 +0200 |
commit | fde37dc99c0ca43021ac3d1b3537f095ee6114b7 (patch) | |
tree | 1b7da7037fd428327831045ff82b47864be182f9 /server/tests | |
parent | 298b3fd31529c047e87d34d397af3b08833bd8d0 (diff) | |
download | PeerTube-fde37dc99c0ca43021ac3d1b3537f095ee6114b7.tar.gz PeerTube-fde37dc99c0ca43021ac3d1b3537f095ee6114b7.tar.zst PeerTube-fde37dc99c0ca43021ac3d1b3537f095ee6114b7.zip |
Add ability for video owners to delete comments
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/video-comments.ts | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index 38f069503..181282ce1 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts | |||
@@ -29,6 +29,7 @@ describe('Test video comments API validator', function () { | |||
29 | let server: ServerInfo | 29 | let server: ServerInfo |
30 | let videoUUID: string | 30 | let videoUUID: string |
31 | let userAccessToken: string | 31 | let userAccessToken: string |
32 | let userAccessToken2: string | ||
32 | let commentId: number | 33 | let commentId: number |
33 | 34 | ||
34 | // --------------------------------------------------------------- | 35 | // --------------------------------------------------------------- |
@@ -53,13 +54,16 @@ describe('Test video comments API validator', function () { | |||
53 | } | 54 | } |
54 | 55 | ||
55 | { | 56 | { |
56 | const user = { | 57 | const user = { username: 'user1', password: 'my super password' } |
57 | username: 'user1', | ||
58 | password: 'my super password' | ||
59 | } | ||
60 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 58 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
61 | userAccessToken = await userLogin(server, user) | 59 | userAccessToken = await userLogin(server, user) |
62 | } | 60 | } |
61 | |||
62 | { | ||
63 | const user = { username: 'user2', password: 'my super password' } | ||
64 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | ||
65 | userAccessToken2 = await userLogin(server, user) | ||
66 | } | ||
63 | }) | 67 | }) |
64 | 68 | ||
65 | describe('When listing video comment threads', function () { | 69 | describe('When listing video comment threads', function () { |
@@ -224,6 +228,40 @@ describe('Test video comments API validator', function () { | |||
224 | await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: 404 }) | 228 | await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: 404 }) |
225 | }) | 229 | }) |
226 | 230 | ||
231 | it('Should succeed with the same user', async function () { | ||
232 | let commentToDelete: number | ||
233 | |||
234 | { | ||
235 | const res = await addVideoCommentThread(server.url, userAccessToken, videoUUID, 'hello') | ||
236 | commentToDelete = res.body.comment.id | ||
237 | } | ||
238 | |||
239 | const path = '/api/v1/videos/' + videoUUID + '/comments/' + commentToDelete | ||
240 | |||
241 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: 403 }) | ||
242 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 204 }) | ||
243 | }) | ||
244 | |||
245 | it('Should succeed with the owner of the video', async function () { | ||
246 | let commentToDelete: number | ||
247 | let anotherVideoUUID: string | ||
248 | |||
249 | { | ||
250 | const res = await uploadVideo(server.url, userAccessToken, { name: 'video' }) | ||
251 | anotherVideoUUID = res.body.video.uuid | ||
252 | } | ||
253 | |||
254 | { | ||
255 | const res = await addVideoCommentThread(server.url, server.accessToken, anotherVideoUUID, 'hello') | ||
256 | commentToDelete = res.body.comment.id | ||
257 | } | ||
258 | |||
259 | const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete | ||
260 | |||
261 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: 403 }) | ||
262 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 204 }) | ||
263 | }) | ||
264 | |||
227 | it('Should succeed with the correct parameters', async function () { | 265 | it('Should succeed with the correct parameters', async function () { |
228 | await makeDeleteRequest({ url: server.url, path: pathComment, token: server.accessToken, statusCodeExpected: 204 }) | 266 | await makeDeleteRequest({ url: server.url, path: pathComment, token: server.accessToken, statusCodeExpected: 204 }) |
229 | }) | 267 | }) |