X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideo-imports.ts;h=7f19b9ee9b1f84ae0d6e3c76298ba78d719150e1;hb=8d1f78044ca6eb9995001d3ab83be62460e043a6;hp=da9d0826a1729b1475a168fdc38031c0717472aa;hpb=8d57e728756fe4de70d720775675e961fc3f30d3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index da9d0826a..7f19b9ee9 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts @@ -1,9 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import { omit } from 'lodash' import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, FIXTURE_URLS } from '@server/tests/shared' -import { buildAbsoluteFixturePath } from '@shared/core-utils' +import { buildAbsoluteFixturePath, omit } from '@shared/core-utils' import { HttpStatusCode, VideoPrivacy } from '@shared/models' import { cleanupTests, @@ -35,7 +33,7 @@ describe('Test video imports API validator', function () { const username = 'user1' const password = 'my super password' - await server.users.create({ username: username, password: password }) + await server.users.create({ username, password }) userAccessToken = await server.login.getAccessToken({ username, password }) { @@ -59,6 +57,15 @@ describe('Test video imports API validator', function () { await checkBadSortPagination(server.url, myPath, server.accessToken) }) + it('Should fail with a bad videoChannelSyncId param', async function () { + await makeGetRequest({ + url: server.url, + path: myPath, + query: { videoChannelSyncId: 'toto' }, + token: server.accessToken + }) + }) + it('Should success with the correct parameters', async function () { await makeGetRequest({ url: server.url, path: myPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken }) }) @@ -88,11 +95,17 @@ describe('Test video imports API validator', function () { it('Should fail with nothing', async function () { const fields = {} - await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) + await makePostBodyRequest({ + url: server.url, + path, + token: server.accessToken, + fields, + expectedStatus: HttpStatusCode.BAD_REQUEST_400 + }) }) it('Should fail without a target url', async function () { - const fields = omit(baseCorrectParams, 'targetUrl') + const fields = omit(baseCorrectParams, [ 'targetUrl' ]) await makePostBodyRequest({ url: server.url, path, @@ -174,7 +187,7 @@ describe('Test video imports API validator', function () { }) it('Should fail without a channel', async function () { - const fields = omit(baseCorrectParams, 'channelId') + const fields = omit(baseCorrectParams, [ 'channelId' ]) await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) }) @@ -256,7 +269,7 @@ describe('Test video imports API validator', function () { }) it('Should fail with an invalid torrent file', async function () { - const fields = omit(baseCorrectParams, 'targetUrl') + const fields = omit(baseCorrectParams, [ 'targetUrl' ]) const attaches = { torrentfile: buildAbsoluteFixturePath('avatar-big.png') } @@ -265,7 +278,7 @@ describe('Test video imports API validator', function () { }) it('Should fail with an invalid magnet URI', async function () { - let fields = omit(baseCorrectParams, 'targetUrl') + let fields = omit(baseCorrectParams, [ 'targetUrl' ]) fields = { ...fields, magnetUri: 'blabla' } await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) @@ -324,7 +337,7 @@ describe('Test video imports API validator', function () { } }) - let fields = omit(baseCorrectParams, 'targetUrl') + let fields = omit(baseCorrectParams, [ 'targetUrl' ]) fields = { ...fields, magnetUri: FIXTURE_URLS.magnet } await makePostBodyRequest({ @@ -335,7 +348,7 @@ describe('Test video imports API validator', function () { expectedStatus: HttpStatusCode.CONFLICT_409 }) - fields = omit(fields, 'magnetUri') + fields = omit(fields, [ 'magnetUri' ]) const attaches = { torrentfile: buildAbsoluteFixturePath('video-720p.torrent') }