aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-14 16:52:22 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-06-15 08:21:12 +0200
commit3d470a530c4a48b2e4f4a9e7d4f223e14f32cea4 (patch)
tree7305399caecbf7380319bd08e21c933de88096dc /server/tests/api/check-params
parent79db409a41bd28fd2773626c9a93b5d326a38bc0 (diff)
downloadPeerTube-3d470a530c4a48b2e4f4a9e7d4f223e14f32cea4.tar.gz
PeerTube-3d470a530c4a48b2e4f4a9e7d4f223e14f32cea4.tar.zst
PeerTube-3d470a530c4a48b2e4f4a9e7d4f223e14f32cea4.zip
Faster ci using compiled ts files
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/live.ts12
-rw-r--r--server/tests/api/check-params/users.ts10
-rw-r--r--server/tests/api/check-params/video-captions.ts11
-rw-r--r--server/tests/api/check-params/video-channels.ts14
-rw-r--r--server/tests/api/check-params/video-imports.ts18
5 files changed, 33 insertions, 32 deletions
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 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { join } from 'path'
6import { LiveVideo, VideoPrivacy } from '@shared/models' 5import { LiveVideo, VideoPrivacy } from '@shared/models'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
7import { 7import {
8 buildAbsoluteFixturePath,
8 cleanupTests, 9 cleanupTests,
9 createUser, 10 createUser,
10 flushAndRunServer, 11 flushAndRunServer,
@@ -24,7 +25,6 @@ import {
24 userLogin, 25 userLogin,
25 waitUntilLivePublished 26 waitUntilLivePublished
26} from '../../../../shared/extra-utils' 27} from '../../../../shared/extra-utils'
27import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
28 28
29describe('Test video lives API validator', function () { 29describe('Test video lives API validator', function () {
30 const path = '/api/v1/videos/live' 30 const path = '/api/v1/videos/live'
@@ -180,7 +180,7 @@ describe('Test video lives API validator', function () {
180 it('Should fail with an incorrect thumbnail file', async function () { 180 it('Should fail with an incorrect thumbnail file', async function () {
181 const fields = baseCorrectParams 181 const fields = baseCorrectParams
182 const attaches = { 182 const attaches = {
183 thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 183 thumbnailfile: buildAbsoluteFixturePath('video_short.mp4')
184 } 184 }
185 185
186 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) 186 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -189,7 +189,7 @@ describe('Test video lives API validator', function () {
189 it('Should fail with a big thumbnail file', async function () { 189 it('Should fail with a big thumbnail file', async function () {
190 const fields = baseCorrectParams 190 const fields = baseCorrectParams
191 const attaches = { 191 const attaches = {
192 thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') 192 thumbnailfile: buildAbsoluteFixturePath('preview-big.png')
193 } 193 }
194 194
195 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) 195 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -198,7 +198,7 @@ describe('Test video lives API validator', function () {
198 it('Should fail with an incorrect preview file', async function () { 198 it('Should fail with an incorrect preview file', async function () {
199 const fields = baseCorrectParams 199 const fields = baseCorrectParams
200 const attaches = { 200 const attaches = {
201 previewfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 201 previewfile: buildAbsoluteFixturePath('video_short.mp4')
202 } 202 }
203 203
204 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) 204 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -207,7 +207,7 @@ describe('Test video lives API validator', function () {
207 it('Should fail with a big preview file', async function () { 207 it('Should fail with a big preview file', async function () {
208 const fields = baseCorrectParams 208 const fields = baseCorrectParams
209 const attaches = { 209 const attaches = {
210 previewfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') 210 previewfile: buildAbsoluteFixturePath('preview-big.png')
211 } 211 }
212 212
213 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) 213 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 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { join } from 'path'
6import { User, UserRole } from '../../../../shared' 5import { User, UserRole } from '../../../../shared'
7import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
8import { 7import {
9 addVideoChannel, 8 addVideoChannel,
10 blockUser, 9 blockUser,
10 buildAbsoluteFixturePath,
11 cleanupTests, 11 cleanupTests,
12 createUser, 12 createUser,
13 deleteMe, 13 deleteMe,
@@ -600,7 +600,7 @@ describe('Test users API validators', function () {
600 it('Should fail without an incorrect input file', async function () { 600 it('Should fail without an incorrect input file', async function () {
601 const fields = {} 601 const fields = {}
602 const attaches = { 602 const attaches = {
603 avatarfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 603 avatarfile: buildAbsoluteFixturePath('video_short.mp4')
604 } 604 }
605 await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }) 605 await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
606 }) 606 })
@@ -608,7 +608,7 @@ describe('Test users API validators', function () {
608 it('Should fail with a big file', async function () { 608 it('Should fail with a big file', async function () {
609 const fields = {} 609 const fields = {}
610 const attaches = { 610 const attaches = {
611 avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') 611 avatarfile: buildAbsoluteFixturePath('avatar-big.png')
612 } 612 }
613 await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }) 613 await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
614 }) 614 })
@@ -616,7 +616,7 @@ describe('Test users API validators', function () {
616 it('Should fail with an unauthenticated user', async function () { 616 it('Should fail with an unauthenticated user', async function () {
617 const fields = {} 617 const fields = {}
618 const attaches = { 618 const attaches = {
619 avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png') 619 avatarfile: buildAbsoluteFixturePath('avatar.png')
620 } 620 }
621 await makeUploadRequest({ 621 await makeUploadRequest({
622 url: server.url, 622 url: server.url,
@@ -630,7 +630,7 @@ describe('Test users API validators', function () {
630 it('Should succeed with the correct params', async function () { 630 it('Should succeed with the correct params', async function () {
631 const fields = {} 631 const fields = {}
632 const attaches = { 632 const attaches = {
633 avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png') 633 avatarfile: buildAbsoluteFixturePath('avatar.png')
634 } 634 }
635 await makeUploadRequest({ 635 await makeUploadRequest({
636 url: server.url, 636 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 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
4import { 6import {
7 buildAbsoluteFixturePath,
5 cleanupTests, 8 cleanupTests,
6 createUser, 9 createUser,
7 flushAndRunServer, 10 flushAndRunServer,
@@ -13,9 +16,7 @@ import {
13 uploadVideo, 16 uploadVideo,
14 userLogin 17 userLogin
15} from '../../../../shared/extra-utils' 18} from '../../../../shared/extra-utils'
16import { join } from 'path'
17import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions' 19import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions'
18import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
19 20
20describe('Test video captions API validator', function () { 21describe('Test video captions API validator', function () {
21 const path = '/api/v1/videos/' 22 const path = '/api/v1/videos/'
@@ -51,7 +52,7 @@ describe('Test video captions API validator', function () {
51 describe('When adding video caption', function () { 52 describe('When adding video caption', function () {
52 const fields = { } 53 const fields = { }
53 const attaches = { 54 const attaches = {
54 captionfile: join(__dirname, '..', '..', 'fixtures', 'subtitle-good1.vtt') 55 captionfile: buildAbsoluteFixturePath('subtitle-good1.vtt')
55 } 56 }
56 57
57 it('Should fail without a valid uuid', async function () { 58 it('Should fail without a valid uuid', async function () {
@@ -129,7 +130,7 @@ describe('Test video captions API validator', function () {
129 // We accept any file now 130 // We accept any file now
130 // it('Should fail with an invalid captionfile extension', async function () { 131 // it('Should fail with an invalid captionfile extension', async function () {
131 // const attaches = { 132 // const attaches = {
132 // 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.txt') 133 // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.txt')
133 // } 134 // }
134 // 135 //
135 // const captionPath = path + videoUUID + '/captions/fr' 136 // const captionPath = path + videoUUID + '/captions/fr'
@@ -171,7 +172,7 @@ describe('Test video captions API validator', function () {
171 // We don't check the file validity yet 172 // We don't check the file validity yet
172 // it('Should fail with an invalid captionfile srt', async function () { 173 // it('Should fail with an invalid captionfile srt', async function () {
173 // const attaches = { 174 // const attaches = {
174 // 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.srt') 175 // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.srt')
175 // } 176 // }
176 // 177 //
177 // const captionPath = path + videoUUID + '/captions/fr' 178 // 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 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha'
3import * as chai from 'chai' 4import * as chai from 'chai'
4import { omit } from 'lodash' 5import { omit } from 'lodash'
5import 'mocha' 6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6import { 7import {
8 buildAbsoluteFixturePath,
7 cleanupTests, 9 cleanupTests,
8 createUser, 10 createUser,
9 deleteVideoChannel, 11 deleteVideoChannel,
@@ -23,9 +25,7 @@ import {
23 checkBadSortPagination, 25 checkBadSortPagination,
24 checkBadStartPagination 26 checkBadStartPagination
25} from '../../../../shared/extra-utils/requests/check-api-params' 27} from '../../../../shared/extra-utils/requests/check-api-params'
26import { join } from 'path'
27import { VideoChannelUpdate } from '../../../../shared/models/videos' 28import { VideoChannelUpdate } from '../../../../shared/models/videos'
28import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
29 29
30const expect = chai.expect 30const expect = chai.expect
31 31
@@ -246,7 +246,7 @@ describe('Test video channels API validator', function () {
246 for (const type of types) { 246 for (const type of types) {
247 const fields = {} 247 const fields = {}
248 const attaches = { 248 const attaches = {
249 [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 249 [type + 'file']: buildAbsoluteFixturePath('video_short.mp4')
250 } 250 }
251 251
252 await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches }) 252 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 () {
257 for (const type of types) { 257 for (const type of types) {
258 const fields = {} 258 const fields = {}
259 const attaches = { 259 const attaches = {
260 [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') 260 [type + 'file']: buildAbsoluteFixturePath('avatar-big.png')
261 } 261 }
262 await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches }) 262 await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches })
263 } 263 }
@@ -267,7 +267,7 @@ describe('Test video channels API validator', function () {
267 for (const type of types) { 267 for (const type of types) {
268 const fields = {} 268 const fields = {}
269 const attaches = { 269 const attaches = {
270 [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar.png') 270 [type + 'file']: buildAbsoluteFixturePath('avatar.png')
271 } 271 }
272 await makeUploadRequest({ 272 await makeUploadRequest({
273 url: server.url, 273 url: server.url,
@@ -283,7 +283,7 @@ describe('Test video channels API validator', function () {
283 for (const type of types) { 283 for (const type of types) {
284 const fields = {} 284 const fields = {}
285 const attaches = { 285 const attaches = {
286 [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar.png') 286 [type + 'file']: buildAbsoluteFixturePath('avatar.png')
287 } 287 }
288 await makeUploadRequest({ 288 await makeUploadRequest({
289 url: server.url, 289 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 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { join } from 'path' 5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6import { 6import {
7 buildAbsoluteFixturePath,
7 cleanupTests, 8 cleanupTests,
8 createUser, 9 createUser,
9 flushAndRunServer, 10 flushAndRunServer,
@@ -22,9 +23,8 @@ import {
22 checkBadSortPagination, 23 checkBadSortPagination,
23 checkBadStartPagination 24 checkBadStartPagination
24} from '../../../../shared/extra-utils/requests/check-api-params' 25} from '../../../../shared/extra-utils/requests/check-api-params'
25import { getMagnetURI, getGoodVideoUrl } from '../../../../shared/extra-utils/videos/video-imports' 26import { getGoodVideoUrl, getMagnetURI } from '../../../../shared/extra-utils/videos/video-imports'
26import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' 27import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
27import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
28 28
29describe('Test video imports API validator', function () { 29describe('Test video imports API validator', function () {
30 const path = '/api/v1/videos/imports' 30 const path = '/api/v1/videos/imports'
@@ -201,7 +201,7 @@ describe('Test video imports API validator', function () {
201 it('Should fail with an incorrect thumbnail file', async function () { 201 it('Should fail with an incorrect thumbnail file', async function () {
202 const fields = baseCorrectParams 202 const fields = baseCorrectParams
203 const attaches = { 203 const attaches = {
204 thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 204 thumbnailfile: buildAbsoluteFixturePath('video_short.mp4')
205 } 205 }
206 206
207 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) 207 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -210,7 +210,7 @@ describe('Test video imports API validator', function () {
210 it('Should fail with a big thumbnail file', async function () { 210 it('Should fail with a big thumbnail file', async function () {
211 const fields = baseCorrectParams 211 const fields = baseCorrectParams
212 const attaches = { 212 const attaches = {
213 thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') 213 thumbnailfile: buildAbsoluteFixturePath('preview-big.png')
214 } 214 }
215 215
216 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) 216 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -219,7 +219,7 @@ describe('Test video imports API validator', function () {
219 it('Should fail with an incorrect preview file', async function () { 219 it('Should fail with an incorrect preview file', async function () {
220 const fields = baseCorrectParams 220 const fields = baseCorrectParams
221 const attaches = { 221 const attaches = {
222 previewfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 222 previewfile: buildAbsoluteFixturePath('video_short.mp4')
223 } 223 }
224 224
225 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) 225 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -228,7 +228,7 @@ describe('Test video imports API validator', function () {
228 it('Should fail with a big preview file', async function () { 228 it('Should fail with a big preview file', async function () {
229 const fields = baseCorrectParams 229 const fields = baseCorrectParams
230 const attaches = { 230 const attaches = {
231 previewfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') 231 previewfile: buildAbsoluteFixturePath('preview-big.png')
232 } 232 }
233 233
234 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) 234 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -237,7 +237,7 @@ describe('Test video imports API validator', function () {
237 it('Should fail with an invalid torrent file', async function () { 237 it('Should fail with an invalid torrent file', async function () {
238 const fields = omit(baseCorrectParams, 'targetUrl') 238 const fields = omit(baseCorrectParams, 'targetUrl')
239 const attaches = { 239 const attaches = {
240 torrentfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') 240 torrentfile: buildAbsoluteFixturePath('avatar-big.png')
241 } 241 }
242 242
243 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) 243 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
@@ -312,7 +312,7 @@ describe('Test video imports API validator', function () {
312 312
313 fields = omit(fields, 'magnetUri') 313 fields = omit(fields, 'magnetUri')
314 const attaches = { 314 const attaches = {
315 torrentfile: join(__dirname, '..', '..', 'fixtures', 'video-720p.torrent') 315 torrentfile: buildAbsoluteFixturePath('video-720p.torrent')
316 } 316 }
317 317
318 await makeUploadRequest({ 318 await makeUploadRequest({