aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/video-comments.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/video-comments.ts')
-rw-r--r--server/tests/api/check-params/video-comments.ts31
1 files changed, 16 insertions, 15 deletions
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index 659a10c41..a38420851 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -1,7 +1,9 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { VideoCreateResult } from '@shared/models'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
5import { 7import {
6 cleanupTests, 8 cleanupTests,
7 createUser, 9 createUser,
@@ -20,7 +22,6 @@ import {
20 checkBadStartPagination 22 checkBadStartPagination
21} from '../../../../shared/extra-utils/requests/check-api-params' 23} from '../../../../shared/extra-utils/requests/check-api-params'
22import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments' 24import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments'
23import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
24 25
25const expect = chai.expect 26const expect = chai.expect
26 27
@@ -28,7 +29,7 @@ describe('Test video comments API validator', function () {
28 let pathThread: string 29 let pathThread: string
29 let pathComment: string 30 let pathComment: string
30 let server: ServerInfo 31 let server: ServerInfo
31 let videoUUID: string 32 let video: VideoCreateResult
32 let userAccessToken: string 33 let userAccessToken: string
33 let userAccessToken2: string 34 let userAccessToken2: string
34 let commentId: number 35 let commentId: number
@@ -44,14 +45,14 @@ describe('Test video comments API validator', function () {
44 45
45 { 46 {
46 const res = await uploadVideo(server.url, server.accessToken, {}) 47 const res = await uploadVideo(server.url, server.accessToken, {})
47 videoUUID = res.body.video.uuid 48 video = res.body.video
48 pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads' 49 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
49 } 50 }
50 51
51 { 52 {
52 const res = await addVideoCommentThread(server.url, server.accessToken, videoUUID, 'coucou') 53 const res = await addVideoCommentThread(server.url, server.accessToken, video.uuid, 'coucou')
53 commentId = res.body.comment.id 54 commentId = res.body.comment.id
54 pathComment = '/api/v1/videos/' + videoUUID + '/comments/' + commentId 55 pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId
55 } 56 }
56 57
57 { 58 {
@@ -101,7 +102,7 @@ describe('Test video comments API validator', function () {
101 it('Should fail with an incorrect thread id', async function () { 102 it('Should fail with an incorrect thread id', async function () {
102 await makeGetRequest({ 103 await makeGetRequest({
103 url: server.url, 104 url: server.url,
104 path: '/api/v1/videos/' + videoUUID + '/comment-threads/156', 105 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156',
105 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 106 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
106 }) 107 })
107 }) 108 })
@@ -109,7 +110,7 @@ describe('Test video comments API validator', function () {
109 it('Should success with the correct params', async function () { 110 it('Should success with the correct params', async function () {
110 await makeGetRequest({ 111 await makeGetRequest({
111 url: server.url, 112 url: server.url,
112 path: '/api/v1/videos/' + videoUUID + '/comment-threads/' + commentId, 113 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId,
113 statusCodeExpected: HttpStatusCode.OK_200 114 statusCodeExpected: HttpStatusCode.OK_200
114 }) 115 })
115 }) 116 })
@@ -225,7 +226,7 @@ describe('Test video comments API validator', function () {
225 }) 226 })
226 227
227 it('Should fail with an incorrect comment', async function () { 228 it('Should fail with an incorrect comment', async function () {
228 const path = '/api/v1/videos/' + videoUUID + '/comments/124' 229 const path = '/api/v1/videos/' + video.uuid + '/comments/124'
229 const fields = { 230 const fields = {
230 text: 'super comment' 231 text: 'super comment'
231 } 232 }
@@ -272,7 +273,7 @@ describe('Test video comments API validator', function () {
272 }) 273 })
273 274
274 it('Should fail with an incorrect comment', async function () { 275 it('Should fail with an incorrect comment', async function () {
275 const path = '/api/v1/videos/' + videoUUID + '/comments/124' 276 const path = '/api/v1/videos/' + video.uuid + '/comments/124'
276 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 277 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
277 }) 278 })
278 279
@@ -280,11 +281,11 @@ describe('Test video comments API validator', function () {
280 let commentToDelete: number 281 let commentToDelete: number
281 282
282 { 283 {
283 const res = await addVideoCommentThread(server.url, userAccessToken, videoUUID, 'hello') 284 const res = await addVideoCommentThread(server.url, userAccessToken, video.uuid, 'hello')
284 commentToDelete = res.body.comment.id 285 commentToDelete = res.body.comment.id
285 } 286 }
286 287
287 const path = '/api/v1/videos/' + videoUUID + '/comments/' + commentToDelete 288 const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete
288 289
289 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 290 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
290 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) 291 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 })
@@ -323,8 +324,8 @@ describe('Test video comments API validator', function () {
323 describe('When a video has comments disabled', function () { 324 describe('When a video has comments disabled', function () {
324 before(async function () { 325 before(async function () {
325 const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false }) 326 const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false })
326 videoUUID = res.body.video.uuid 327 video = res.body.video
327 pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads' 328 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
328 }) 329 })
329 330
330 it('Should return an empty thread list', async function () { 331 it('Should return an empty thread list', async function () {