-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import { omit } from 'lodash'
checkBadSortPagination,
checkBadStartPagination
} from '../../../../shared/extra-utils/requests/check-api-params'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const expect = chai.expect
{
const res = await getMyUserInformation(server.url, server.accessToken)
- channelId = res.body.videoChannels[ 0 ].id
- channelName = res.body.videoChannels[ 0 ].name
+ channelId = res.body.videoChannels[0].id
+ channelName = res.body.videoChannels[0].name
accountName = res.body.account.name + '@' + res.body.account.host
}
})
- describe('When listing a video', function () {
+ describe('When listing videos', function () {
it('Should fail with a bad start pagination', async function () {
await checkBadStartPagination(server.url, path)
})
await checkBadSortPagination(server.url, path)
})
+ it('Should fail with a bad skipVideos query', async function () {
+ await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: 'toto' } })
+ })
+
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
+ await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: false } })
})
})
await makeGetRequest({
url: server.url,
path: join(path, 'search'),
- statusCodeExpected: 400
+ statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
})
})
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
+ await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
})
})
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: 200 })
+ await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: HttpStatusCode.OK_200 })
})
})
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
+ await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
})
})
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
+ await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
})
})
describe('When adding a video', function () {
let baseCorrectParams
const baseCorrectAttaches = {
- 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
}
before(function () {
})
it('Should fail with a bad originally published at attribute', async function () {
- const fields = immutableAssign(baseCorrectParams, { 'originallyPublishedAt': 'toto' })
+ const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' })
const attaches = baseCorrectAttaches
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
it('Should fail with an incorrect input file', async function () {
const fields = baseCorrectParams
let attaches = {
- 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm')
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm')
}
- await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
+ await makeUploadRequest({
+ url: server.url,
+ path: path + '/upload',
+ token: server.accessToken,
+ fields,
+ attaches,
+ statusCodeExpected: HttpStatusCode.UNPROCESSABLE_ENTITY_422
+ })
attaches = {
- 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv')
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv')
}
- await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
+ await makeUploadRequest({
+ url: server.url,
+ path: path + '/upload',
+ token: server.accessToken,
+ fields,
+ attaches,
+ statusCodeExpected: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415
+ })
})
it('Should fail with an incorrect thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png'),
- 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
+ thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
it('Should fail with a big thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'),
- 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
+ thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
it('Should fail with an incorrect preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png'),
- 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
+ previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
it('Should fail with a big preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'),
- 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
+ previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
token: server.accessToken,
fields,
attaches,
- statusCodeExpected: 200
+ statusCodeExpected: HttpStatusCode.OK_200
})
}
token: server.accessToken,
fields,
attaches,
- statusCodeExpected: 200
+ statusCodeExpected: HttpStatusCode.OK_200
})
}
token: server.accessToken,
fields,
attaches,
- statusCodeExpected: 200
+ statusCodeExpected: HttpStatusCode.OK_200
})
}
})
path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
token: server.accessToken,
fields,
- statusCodeExpected: 404
+ statusCodeExpected: HttpStatusCode.NOT_FOUND_404
})
})
it('Should fail with an incorrect thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
+ thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({
it('Should fail with a big thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
+ thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
}
await makeUploadRequest({
it('Should fail with an incorrect preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
+ previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({
it('Should fail with a big preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
+ previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
}
await makeUploadRequest({
it('Should fail with a video of another user without the appropriate right', async function () {
const fields = baseCorrectParams
- await makePutBodyRequest({ url: server.url, path: path + videoId, token: userAccessToken, fields, statusCodeExpected: 403 })
+ await makePutBodyRequest({
+ url: server.url,
+ path: path + videoId,
+ token: userAccessToken,
+ fields,
+ statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ })
})
it('Should fail with a video of another server')
it('Should succeed with the correct parameters', async function () {
const fields = baseCorrectParams
- await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields, statusCodeExpected: 204 })
+ await makePutBodyRequest({
+ url: server.url,
+ path: path + videoId,
+ token: server.accessToken,
+ fields,
+ statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ })
})
})
const res = await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: 200
+ statusCodeExpected: HttpStatusCode.OK_200
})
expect(res.body.data).to.be.an('array')
})
it('Should fail without a correct uuid', async function () {
- await getVideo(server.url, 'coucou', 400)
+ await getVideo(server.url, 'coucou', HttpStatusCode.BAD_REQUEST_400)
})
it('Should return 404 with an incorrect video', async function () {
- await getVideo(server.url, '4da6fde3-88f7-4d16-b119-108df5630b06', 404)
+ await getVideo(server.url, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404)
})
it('Should succeed with the correct parameters', async function () {
path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
token: server.accessToken,
fields,
- statusCodeExpected: 404
+ statusCodeExpected: HttpStatusCode.NOT_FOUND_404
})
})
path: path + videoId + '/rate',
token: server.accessToken,
fields,
- statusCodeExpected: 204
+ statusCodeExpected: HttpStatusCode.NO_CONTENT_204
})
})
})
await makeDeleteRequest({
url: server.url,
path,
- statusCodeExpected: 400
+ statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
})
})
it('Should fail without a correct uuid', async function () {
- await removeVideo(server.url, server.accessToken, 'hello', 400)
+ await removeVideo(server.url, server.accessToken, 'hello', HttpStatusCode.BAD_REQUEST_400)
})
it('Should fail with a video which does not exist', async function () {
- await removeVideo(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', 404)
+ await removeVideo(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404)
})
it('Should fail with a video of another user without the appropriate right', async function () {
- await removeVideo(server.url, userAccessToken, videoId, 403)
+ await removeVideo(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403)
})
it('Should fail with a video of another server')