/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import * as chai from 'chai'
import 'mocha'
+import * as chai from 'chai'
+import { VideoCreateResult } from '@shared/models'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import {
cleanupTests,
createUser,
checkBadStartPagination
} from '../../../../shared/extra-utils/requests/check-api-params'
import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const expect = chai.expect
let pathThread: string
let pathComment: string
let server: ServerInfo
- let videoUUID: string
+ let video: VideoCreateResult
let userAccessToken: string
let userAccessToken2: string
let commentId: number
{
const res = await uploadVideo(server.url, server.accessToken, {})
- videoUUID = res.body.video.uuid
- pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads'
+ video = res.body.video
+ pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
}
{
- const res = await addVideoCommentThread(server.url, server.accessToken, videoUUID, 'coucou')
+ const res = await addVideoCommentThread(server.url, server.accessToken, video.uuid, 'coucou')
commentId = res.body.comment.id
- pathComment = '/api/v1/videos/' + videoUUID + '/comments/' + commentId
+ pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId
}
{
it('Should fail with an incorrect thread id', async function () {
await makeGetRequest({
url: server.url,
- path: '/api/v1/videos/' + videoUUID + '/comment-threads/156',
+ path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156',
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
})
})
it('Should success with the correct params', async function () {
await makeGetRequest({
url: server.url,
- path: '/api/v1/videos/' + videoUUID + '/comment-threads/' + commentId,
+ path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId,
statusCodeExpected: HttpStatusCode.OK_200
})
})
})
it('Should fail with an incorrect comment', async function () {
- const path = '/api/v1/videos/' + videoUUID + '/comments/124'
+ const path = '/api/v1/videos/' + video.uuid + '/comments/124'
const fields = {
text: 'super comment'
}
})
it('Should fail with an incorrect comment', async function () {
- const path = '/api/v1/videos/' + videoUUID + '/comments/124'
+ const path = '/api/v1/videos/' + video.uuid + '/comments/124'
await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
})
let commentToDelete: number
{
- const res = await addVideoCommentThread(server.url, userAccessToken, videoUUID, 'hello')
+ const res = await addVideoCommentThread(server.url, userAccessToken, video.uuid, 'hello')
commentToDelete = res.body.comment.id
}
- const path = '/api/v1/videos/' + videoUUID + '/comments/' + commentToDelete
+ const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete
await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 })
describe('When a video has comments disabled', function () {
before(async function () {
const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false })
- videoUUID = res.body.video.uuid
- pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads'
+ video = res.body.video
+ pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
})
it('Should return an empty thread list', async function () {