/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import * as chai from 'chai'
import 'mocha'
+import * as chai from 'chai'
+import { HttpStatusCode } from '@shared/core-utils'
import {
+ checkBadCountPagination,
+ checkBadSortPagination,
+ checkBadStartPagination,
cleanupTests,
createUser,
flushAndRunServer,
setAccessTokensToServers,
uploadVideo,
userLogin
-} from '../../../../shared/extra-utils'
-import {
- checkBadCountPagination,
- checkBadSortPagination,
- 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'
+} from '@shared/extra-utils'
+import { VideoCreateResult } from '@shared/models'
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')
- commentId = res.body.comment.id
- pathComment = '/api/v1/videos/' + videoUUID + '/comments/' + commentId
+ const created = await server.commentsCommand.createThread({ videoId: video.uuid, text: 'coucou' })
+ commentId = created.id
+ 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')
- commentToDelete = res.body.comment.id
+ const created = await server.commentsCommand.createThread({ videoId: video.uuid, text: 'hello' })
+ commentToDelete = created.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 })
}
{
- const res = await addVideoCommentThread(server.url, server.accessToken, anotherVideoUUID, 'hello')
- commentToDelete = res.body.comment.id
+ const created = await server.commentsCommand.createThread({ videoId: anotherVideoUUID, text: 'hello' })
+ commentToDelete = created.id
}
const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete
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 () {