aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 10:42:24 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitc0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea (patch)
treebaf29753ac5d4598643e3bee719f8df0cc36c59d /server/tests/api/videos
parent08642a765ea514a00f159db898edf14c376fbe6c (diff)
downloadPeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.tar.gz
PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.tar.zst
PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.zip
Refactor requests
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/multiple-servers.ts2
-rw-r--r--server/tests/api/videos/resumable-upload.ts2
-rw-r--r--server/tests/api/videos/video-change-ownership.ts2
-rw-r--r--server/tests/api/videos/video-channels.ts6
-rw-r--r--server/tests/api/videos/video-hls.ts2
-rw-r--r--server/tests/api/videos/video-nsfw.ts12
-rw-r--r--server/tests/api/videos/video-playlists.ts2
-rw-r--r--server/tests/api/videos/video-privacy.ts2
-rw-r--r--server/tests/api/videos/video-transcoder.ts10
-rw-r--r--server/tests/api/videos/videos-filter.ts6
-rw-r--r--server/tests/api/videos/videos-history.ts2
11 files changed, 25 insertions, 23 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 562079a15..edf2773cd 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import * as request from 'supertest' 5import * as request from 'supertest'
6import { HttpStatusCode } from '@shared/core-utils' 6import { HttpStatusCode } from '@shared/models'
7import { 7import {
8 buildAbsoluteFixturePath, 8 buildAbsoluteFixturePath,
9 checkTmpIsEmpty, 9 checkTmpIsEmpty,
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index b4fc5ee09..0e62972c2 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -4,7 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { pathExists, readdir, stat } from 'fs-extra' 5import { pathExists, readdir, stat } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/models'
8import { 8import {
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
10 cleanupTests, 10 cleanupTests,
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index cefddb68e..792550101 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 ChangeOwnershipCommand, 7 ChangeOwnershipCommand,
8 cleanupTests, 8 cleanupTests,
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 140fee7fe..eeaec5ad2 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -324,7 +324,7 @@ describe('Test video channels', function () {
324 324
325 for (const server of servers) { 325 for (const server of servers) {
326 const channelURI = 'second_video_channel@localhost:' + servers[0].port 326 const channelURI = 'second_video_channel@localhost:' + servers[0].port
327 const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI }) 327 const { total, data } = await server.videos.listByChannel({ handle: channelURI })
328 328
329 expect(total).to.equal(1) 329 expect(total).to.equal(1)
330 expect(data).to.be.an('array') 330 expect(data).to.be.an('array')
@@ -347,13 +347,13 @@ describe('Test video channels', function () {
347 for (const server of servers) { 347 for (const server of servers) {
348 { 348 {
349 const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port 349 const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port
350 const { total } = await server.videos.listByChannel({ videoChannelName: secondChannelURI }) 350 const { total } = await server.videos.listByChannel({ handle: secondChannelURI })
351 expect(total).to.equal(0) 351 expect(total).to.equal(0)
352 } 352 }
353 353
354 { 354 {
355 const channelURI = 'root_channel@localhost:' + servers[0].port 355 const channelURI = 'root_channel@localhost:' + servers[0].port
356 const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI }) 356 const { total, data } = await server.videos.listByChannel({ handle: channelURI })
357 expect(total).to.equal(1) 357 expect(total).to.equal(1)
358 358
359 expect(data).to.be.an('array') 359 expect(data).to.be.an('array')
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index 4c4b18887..df030110b 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { HttpStatusCode } from '@shared/core-utils' 6import { HttpStatusCode } from '@shared/models'
7import { 7import {
8 checkDirectoryIsEmpty, 8 checkDirectoryIsEmpty,
9 checkResolutionsInMasterPlaylist, 9 checkResolutionsInMasterPlaylist,
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index b25dcda20..0a9e5ce3f 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -19,8 +19,10 @@ describe('Test video NSFW policy', function () {
19 19
20 async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) { 20 async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) {
21 const user = await server.users.getMyInfo() 21 const user = await server.users.getMyInfo()
22 const videoChannelName = user.videoChannels[0].name 22
23 const channelName = user.videoChannels[0].name
23 const accountName = user.account.name + '@' + user.account.host 24 const accountName = user.account.name + '@' + user.account.host
25
24 const hasQuery = Object.keys(query).length !== 0 26 const hasQuery = Object.keys(query).length !== 0
25 let promises: Promise<ResultList<Video>>[] 27 let promises: Promise<ResultList<Video>>[]
26 28
@@ -28,8 +30,8 @@ describe('Test video NSFW policy', function () {
28 promises = [ 30 promises = [
29 server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }), 31 server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }),
30 server.videos.listWithToken({ token, ...query }), 32 server.videos.listWithToken({ token, ...query }),
31 server.videos.listByAccount({ token, accountName, ...query }), 33 server.videos.listByAccount({ token, handle: channelName, ...query }),
32 server.videos.listByChannel({ token, videoChannelName, ...query }) 34 server.videos.listByChannel({ token, handle: accountName, ...query })
33 ] 35 ]
34 36
35 // Overviews do not support video filters 37 // Overviews do not support video filters
@@ -45,8 +47,8 @@ describe('Test video NSFW policy', function () {
45 promises = [ 47 promises = [
46 server.search.searchVideos({ search: 'n', sort: '-publishedAt' }), 48 server.search.searchVideos({ search: 'n', sort: '-publishedAt' }),
47 server.videos.list(), 49 server.videos.list(),
48 server.videos.listByAccount({ accountName }), 50 server.videos.listByAccount({ handle: channelName }),
49 server.videos.listByChannel({ videoChannelName }) 51 server.videos.listByChannel({ handle: accountName })
50 ] 52 ]
51 53
52 // Overviews do not support video filters 54 // Overviews do not support video filters
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 71ca3e63a..9a28a421a 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 checkPlaylistFilesWereRemoved, 7 checkPlaylistFilesWereRemoved,
8 cleanupTests, 8 cleanupTests,
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
index 5ec626155..06011082d 100644
--- a/server/tests/api/videos/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { cleanupTests, doubleFollow, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' 6import { cleanupTests, doubleFollow, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
7import { VideoCreateResult, VideoPrivacy } from '@shared/models' 7import { VideoCreateResult, VideoPrivacy } from '@shared/models'
8 8
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 2465d2d89..7510472e3 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -4,7 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { join } from 'path' 6import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/models'
8import { 8import {
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
10 cleanupTests, 10 cleanupTests,
@@ -384,8 +384,8 @@ describe('Test video transcoding', function () {
384 384
385 expect(videoDetails.files).to.have.lengthOf(1) 385 expect(videoDetails.files).to.have.lengthOf(1)
386 386
387 await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 }) 387 await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 })
388 await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 }) 388 await makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: HttpStatusCode.OK_200 })
389 389
390 const magnetUri = videoDetails.files[0].magnetUri 390 const magnetUri = videoDetails.files[0].magnetUri
391 expect(magnetUri).to.contain('.mp4') 391 expect(magnetUri).to.contain('.mp4')
@@ -408,8 +408,8 @@ describe('Test video transcoding', function () {
408 408
409 expect(videoDetails.files).to.have.lengthOf(1) 409 expect(videoDetails.files).to.have.lengthOf(1)
410 410
411 await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 }) 411 await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 })
412 await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 }) 412 await makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: HttpStatusCode.OK_200 })
413 413
414 const magnetUri = videoDetails.files[0].magnetUri 414 const magnetUri = videoDetails.files[0].magnetUri
415 expect(magnetUri).to.contain('.mp4') 415 expect(magnetUri).to.contain('.mp4')
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts
index db9150655..88dff3e7f 100644
--- a/server/tests/api/videos/videos-filter.ts
+++ b/server/tests/api/videos/videos-filter.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
@@ -13,7 +13,7 @@ import {
13} from '@shared/extra-utils' 13} from '@shared/extra-utils'
14import { UserRole, Video, VideoPrivacy } from '@shared/models' 14import { UserRole, Video, VideoPrivacy } from '@shared/models'
15 15
16async function getVideosNames (server: PeerTubeServer, token: string, filter: string, statusCodeExpected = HttpStatusCode.OK_200) { 16async function getVideosNames (server: PeerTubeServer, token: string, filter: string, expectedStatus = HttpStatusCode.OK_200) {
17 const paths = [ 17 const paths = [
18 '/api/v1/video-channels/root_channel/videos', 18 '/api/v1/video-channels/root_channel/videos',
19 '/api/v1/accounts/root/videos', 19 '/api/v1/accounts/root/videos',
@@ -32,7 +32,7 @@ async function getVideosNames (server: PeerTubeServer, token: string, filter: st
32 sort: 'createdAt', 32 sort: 'createdAt',
33 filter 33 filter
34 }, 34 },
35 statusCodeExpected 35 expectedStatus
36 }) 36 })
37 37
38 videosResults.push(res.body.data.map(v => v.name)) 38 videosResults.push(res.body.data.map(v => v.name))
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index 55e53cb94..acb9d1a46 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,