From 3d470a530c4a48b2e4f4a9e7d4f223e14f32cea4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Jun 2021 16:52:22 +0200 Subject: Faster ci using compiled ts files --- server/tests/api/check-params/live.ts | 12 ++++++------ server/tests/api/check-params/users.ts | 10 +++++----- server/tests/api/check-params/video-captions.ts | 11 ++++++----- server/tests/api/check-params/video-channels.ts | 14 +++++++------- server/tests/api/check-params/video-imports.ts | 18 +++++++++--------- 5 files changed, 33 insertions(+), 32 deletions(-) (limited to 'server/tests/api/check-params') diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts index c171b1f81..32233c9da 100644 --- a/server/tests/api/check-params/live.ts +++ b/server/tests/api/check-params/live.ts @@ -2,9 +2,10 @@ import 'mocha' import { omit } from 'lodash' -import { join } from 'path' import { LiveVideo, VideoPrivacy } from '@shared/models' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { + buildAbsoluteFixturePath, cleanupTests, createUser, flushAndRunServer, @@ -24,7 +25,6 @@ import { userLogin, waitUntilLivePublished } from '../../../../shared/extra-utils' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' describe('Test video lives API validator', function () { const path = '/api/v1/videos/live' @@ -180,7 +180,7 @@ describe('Test video lives API validator', function () { it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + thumbnailfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -189,7 +189,7 @@ describe('Test video lives API validator', function () { it('Should fail with a big thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') + thumbnailfile: buildAbsoluteFixturePath('preview-big.png') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -198,7 +198,7 @@ describe('Test video lives API validator', function () { it('Should fail with an incorrect preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + previewfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -207,7 +207,7 @@ describe('Test video lives API validator', function () { it('Should fail with a big preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') + previewfile: buildAbsoluteFixturePath('preview-big.png') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index dcff0d52b..36482ee17 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -2,12 +2,12 @@ import 'mocha' import { omit } from 'lodash' -import { join } from 'path' import { User, UserRole } from '../../../../shared' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { addVideoChannel, blockUser, + buildAbsoluteFixturePath, cleanupTests, createUser, deleteMe, @@ -600,7 +600,7 @@ describe('Test users API validators', function () { it('Should fail without an incorrect input file', async function () { const fields = {} const attaches = { - avatarfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + avatarfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }) }) @@ -608,7 +608,7 @@ describe('Test users API validators', function () { it('Should fail with a big file', async function () { const fields = {} const attaches = { - avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') + avatarfile: buildAbsoluteFixturePath('avatar-big.png') } await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }) }) @@ -616,7 +616,7 @@ describe('Test users API validators', function () { it('Should fail with an unauthenticated user', async function () { const fields = {} const attaches = { - avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png') + avatarfile: buildAbsoluteFixturePath('avatar.png') } await makeUploadRequest({ url: server.url, @@ -630,7 +630,7 @@ describe('Test users API validators', function () { it('Should succeed with the correct params', async function () { const fields = {} const attaches = { - avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png') + avatarfile: buildAbsoluteFixturePath('avatar.png') } await makeUploadRequest({ url: server.url, diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 2f049c03d..1ce2202d2 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts @@ -1,7 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' + +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { + buildAbsoluteFixturePath, cleanupTests, createUser, flushAndRunServer, @@ -13,9 +16,7 @@ import { uploadVideo, userLogin } from '../../../../shared/extra-utils' -import { join } from 'path' import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' describe('Test video captions API validator', function () { const path = '/api/v1/videos/' @@ -51,7 +52,7 @@ describe('Test video captions API validator', function () { describe('When adding video caption', function () { const fields = { } const attaches = { - captionfile: join(__dirname, '..', '..', 'fixtures', 'subtitle-good1.vtt') + captionfile: buildAbsoluteFixturePath('subtitle-good1.vtt') } it('Should fail without a valid uuid', async function () { @@ -129,7 +130,7 @@ describe('Test video captions API validator', function () { // We accept any file now // it('Should fail with an invalid captionfile extension', async function () { // const attaches = { - // 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.txt') + // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.txt') // } // // const captionPath = path + videoUUID + '/captions/fr' @@ -171,7 +172,7 @@ describe('Test video captions API validator', function () { // We don't check the file validity yet // it('Should fail with an invalid captionfile srt', async function () { // const attaches = { - // 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.srt') + // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.srt') // } // // const captionPath = path + videoUUID + '/captions/fr' diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index bc2e6192e..5c02afd31 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts @@ -1,9 +1,11 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ +import 'mocha' import * as chai from 'chai' import { omit } from 'lodash' -import 'mocha' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { + buildAbsoluteFixturePath, cleanupTests, createUser, deleteVideoChannel, @@ -23,9 +25,7 @@ import { checkBadSortPagination, checkBadStartPagination } from '../../../../shared/extra-utils/requests/check-api-params' -import { join } from 'path' import { VideoChannelUpdate } from '../../../../shared/models/videos' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const expect = chai.expect @@ -246,7 +246,7 @@ describe('Test video channels API validator', function () { for (const type of types) { const fields = {} const attaches = { - [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + [type + 'file']: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches }) @@ -257,7 +257,7 @@ describe('Test video channels API validator', function () { for (const type of types) { const fields = {} const attaches = { - [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') + [type + 'file']: buildAbsoluteFixturePath('avatar-big.png') } await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches }) } @@ -267,7 +267,7 @@ describe('Test video channels API validator', function () { for (const type of types) { const fields = {} const attaches = { - [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar.png') + [type + 'file']: buildAbsoluteFixturePath('avatar.png') } await makeUploadRequest({ url: server.url, @@ -283,7 +283,7 @@ describe('Test video channels API validator', function () { for (const type of types) { const fields = {} const attaches = { - [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar.png') + [type + 'file']: buildAbsoluteFixturePath('avatar.png') } await makeUploadRequest({ url: server.url, diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 6de6b40c8..a27b624d0 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts @@ -2,8 +2,9 @@ import 'mocha' import { omit } from 'lodash' -import { join } from 'path' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { + buildAbsoluteFixturePath, cleanupTests, createUser, flushAndRunServer, @@ -22,9 +23,8 @@ import { checkBadSortPagination, checkBadStartPagination } from '../../../../shared/extra-utils/requests/check-api-params' -import { getMagnetURI, getGoodVideoUrl } from '../../../../shared/extra-utils/videos/video-imports' +import { getGoodVideoUrl, getMagnetURI } from '../../../../shared/extra-utils/videos/video-imports' import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' describe('Test video imports API validator', function () { const path = '/api/v1/videos/imports' @@ -201,7 +201,7 @@ describe('Test video imports API validator', function () { it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + thumbnailfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -210,7 +210,7 @@ describe('Test video imports API validator', function () { it('Should fail with a big thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') + thumbnailfile: buildAbsoluteFixturePath('preview-big.png') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -219,7 +219,7 @@ describe('Test video imports API validator', function () { it('Should fail with an incorrect preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + previewfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -228,7 +228,7 @@ describe('Test video imports API validator', function () { it('Should fail with a big preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') + previewfile: buildAbsoluteFixturePath('preview-big.png') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -237,7 +237,7 @@ describe('Test video imports API validator', function () { it('Should fail with an invalid torrent file', async function () { const fields = omit(baseCorrectParams, 'targetUrl') const attaches = { - torrentfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') + torrentfile: buildAbsoluteFixturePath('avatar-big.png') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -312,7 +312,7 @@ describe('Test video imports API validator', function () { fields = omit(fields, 'magnetUri') const attaches = { - torrentfile: join(__dirname, '..', '..', 'fixtures', 'video-720p.torrent') + torrentfile: buildAbsoluteFixturePath('video-720p.torrent') } await makeUploadRequest({ -- cgit v1.2.3