X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideos.ts;h=0d4665954cdc35ed3c27decffac7a89a2e99a5d8;hb=25ae21107c6b1fbb99773f11b88b877162f41afe;hp=bc321e91fc00398296524195ef16e6349cca28d4;hpb=210feb6cc484a6c5c63c98f770de34e223f944cb;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index bc321e91f..0d4665954 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts @@ -1,4 +1,4 @@ -/* 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' @@ -6,16 +6,28 @@ import 'mocha' import { join } from 'path' import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' import { - createUser, flushTests, getMyUserInformation, getVideo, getVideosList, immutableAssign, killallServers, makeDeleteRequest, - makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, uploadVideo, - flushAndRunServer, ServerInfo, setAccessTokensToServers, userLogin, updateCustomSubConfig + cleanupTests, + createUser, + flushAndRunServer, + getMyUserInformation, + getVideo, + getVideosList, + immutableAssign, + makeDeleteRequest, + makeGetRequest, + makePutBodyRequest, + makeUploadRequest, + removeVideo, + ServerInfo, + setAccessTokensToServers, + userLogin, + root } from '../../../../shared/extra-utils' import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../../../shared/extra-utils/requests/check-api-params' -import { getAccountsList } from '../../../../shared/extra-utils/users/accounts' const expect = chai.expect @@ -44,13 +56,13 @@ describe('Test videos API validator', function () { { 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) }) @@ -63,8 +75,12 @@ describe('Test videos API validator', function () { await checkBadSortPagination(server.url, path) }) + it('Should fail with a bad skipVideos query', async function () { + await makeGetRequest({ url: server.url, path, statusCodeExpected: 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: 200, query: { skipCount: false } }) }) }) @@ -166,7 +182,7 @@ describe('Test videos API validator', function () { describe('When adding a video', function () { let baseCorrectParams const baseCorrectAttaches = { - 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.webm') + videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm') } before(function () { @@ -314,7 +330,7 @@ describe('Test videos API validator', 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 }) @@ -326,15 +342,15 @@ describe('Test videos API validator', function () { await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) }) - it('Should fail without an incorrect input file', async function () { + it('Should fail with an incorrect input file', async function () { const fields = baseCorrectParams let attaches = { - 'videofile': join(__dirname, '..', '..', '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 }) attaches = { - 'videofile': join(__dirname, '..', '..', '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 }) }) @@ -342,8 +358,8 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'), - 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'avatar.png'), + videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') } await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) @@ -352,8 +368,8 @@ describe('Test videos API validator', function () { it('Should fail with a big thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'), - 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'), + videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') } await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) @@ -362,8 +378,8 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect preview file', async function () { const fields = baseCorrectParams const attaches = { - 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'), - 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + previewfile: join(root(), 'server', 'tests', 'fixtures', 'avatar.png'), + videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') } await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) @@ -372,8 +388,8 @@ describe('Test videos API validator', function () { it('Should fail with a big preview file', async function () { const fields = baseCorrectParams const attaches = { - 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'), - 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + previewfile: join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'), + videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') } await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) @@ -398,7 +414,7 @@ describe('Test videos API validator', function () { { const attaches = immutableAssign(baseCorrectAttaches, { - videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') }) await makeUploadRequest({ @@ -413,7 +429,7 @@ describe('Test videos API validator', function () { { const attaches = immutableAssign(baseCorrectAttaches, { - videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.ogv') + videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') }) await makeUploadRequest({ @@ -550,7 +566,7 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') + thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'avatar.png') } await makeUploadRequest({ @@ -566,7 +582,7 @@ describe('Test videos API validator', function () { it('Should fail with a big thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') + thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png') } await makeUploadRequest({ @@ -582,7 +598,7 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect preview file', async function () { const fields = baseCorrectParams const attaches = { - 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') + previewfile: join(root(), 'server', 'tests', 'fixtures', 'avatar.png') } await makeUploadRequest({ @@ -598,7 +614,7 @@ describe('Test videos API validator', function () { it('Should fail with a big preview file', async function () { const fields = baseCorrectParams const attaches = { - 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') + previewfile: join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png') } await makeUploadRequest({ @@ -728,7 +744,7 @@ describe('Test videos API validator', function () { }) }) - after(function () { - killallServers([ server ]) + after(async function () { + await cleanupTests([ server ]) }) })