X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideos.ts;h=2a83143e2d663e56e32b182da537e8138f20d1fb;hb=8d1f78044ca6eb9995001d3ab83be62460e043a6;hp=41064d2ffdc5aeb94a0731e09d36a8f818b725df;hpb=6ea9295b8f5dd7cc254202a79aad61c666cc4259;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 41064d2ff..2a83143e2 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts @@ -1,11 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import * as chai from 'chai' -import { omit } from 'lodash' +import { expect } from 'chai' import { join } from 'path' import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, checkUploadVideoParam } from '@server/tests/shared' -import { randomInt, root } from '@shared/core-utils' +import { omit, randomInt, root } from '@shared/core-utils' import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' import { cleanupTests, @@ -18,8 +16,6 @@ import { setAccessTokensToServers } from '@shared/server-commands' -const expect = chai.expect - describe('Test videos API validator', function () { const path = '/api/v1/videos/' let server: PeerTubeServer @@ -39,10 +35,7 @@ describe('Test videos API validator', function () { await setAccessTokensToServers([ server ]) - const username = 'user1' - const password = 'my super password' - await server.users.create({ username: username, password: password }) - userAccessToken = await server.login.getAccessToken({ username, password }) + userAccessToken = await server.users.generateUserAndToken('user1') { const body = await server.users.getMyInfo() @@ -208,7 +201,7 @@ describe('Test videos API validator', function () { support: 'my super support text', tags: [ 'tag1', 'tag2' ], privacy: VideoPrivacy.PUBLIC, - channelId: channelId, + channelId, originallyPublishedAt: new Date().toISOString() } }) @@ -222,7 +215,7 @@ describe('Test videos API validator', function () { }) it('Should fail without name', async function () { - const fields = omit(baseCorrectParams, 'name') + const fields = omit(baseCorrectParams, [ 'name' ]) const attaches = baseCorrectAttaches await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) @@ -271,7 +264,7 @@ describe('Test videos API validator', function () { }) it('Should fail without a channel', async function () { - const fields = omit(baseCorrectParams, 'channelId') + const fields = omit(baseCorrectParams, [ 'channelId' ]) const attaches = baseCorrectAttaches await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) @@ -428,9 +421,9 @@ describe('Test videos API validator', function () { const error = body as unknown as PeerTubeProblemDocument if (mode === 'legacy') { - expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy') + expect(error.docs).to.equal('https://docs.joinpeertube.org/api/rest-reference.html#operation/uploadLegacy') } else { - expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumableInit') + expect(error.docs).to.equal('https://docs.joinpeertube.org/api/rest-reference.html#operation/uploadResumableInit') } expect(error.type).to.equal('about:blank') @@ -687,7 +680,7 @@ describe('Test videos API validator', function () { const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) const error = res.body as PeerTubeProblemDocument - expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo') + expect(error.docs).to.equal('https://docs.joinpeertube.org/api/rest-reference.html#operation/putVideo') expect(error.type).to.equal('about:blank') expect(error.title).to.equal('Bad Request') @@ -736,7 +729,7 @@ describe('Test videos API validator', function () { const body = await server.videos.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) const error = body as unknown as PeerTubeProblemDocument - expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo') + expect(error.docs).to.equal('https://docs.joinpeertube.org/api/rest-reference.html#operation/getVideo') expect(error.type).to.equal('about:blank') expect(error.title).to.equal('Bad Request') @@ -842,7 +835,7 @@ describe('Test videos API validator', function () { const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) const error = body as PeerTubeProblemDocument - expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') + expect(error.docs).to.equal('https://docs.joinpeertube.org/api/rest-reference.html#operation/delVideo') expect(error.type).to.equal('about:blank') expect(error.title).to.equal('Bad Request')