aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-06 15:22:51 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commitaf971e06c620bd46a5aa64c8833364e7022b5e3d (patch)
tree4288b66b79fe4dd1ab9496e85a3abf7d747ad03a /server/tests/api/videos
parent23a3a8827cb8b862f5cc7ee2819f39918303beca (diff)
downloadPeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.tar.gz
PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.tar.zst
PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.zip
Introduce search command
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/video-nsfw.ts14
-rw-r--r--server/tests/api/videos/videos-history.ts15
2 files changed, 13 insertions, 16 deletions
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index 6c98c9f12..24a4c6152 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -14,8 +14,6 @@ import {
14 getVideoChannelVideos, 14 getVideoChannelVideos,
15 getVideosList, 15 getVideosList,
16 getVideosListWithToken, 16 getVideosListWithToken,
17 searchVideo,
18 searchVideoWithToken,
19 ServerInfo, 17 ServerInfo,
20 setAccessTokensToServers, 18 setAccessTokensToServers,
21 updateCustomConfig, 19 updateCustomConfig,
@@ -23,7 +21,7 @@ import {
23 uploadVideo, 21 uploadVideo,
24 userLogin 22 userLogin
25} from '@shared/extra-utils' 23} from '@shared/extra-utils'
26import { CustomConfig, ServerConfig, User, VideosOverview } from '@shared/models' 24import { BooleanBothQuery, CustomConfig, ServerConfig, User, VideosOverview } from '@shared/models'
27 25
28const expect = chai.expect 26const expect = chai.expect
29 27
@@ -37,7 +35,7 @@ describe('Test video NSFW policy', function () {
37 let userAccessToken: string 35 let userAccessToken: string
38 let customConfig: CustomConfig 36 let customConfig: CustomConfig
39 37
40 function getVideosFunctions (token?: string, query = {}) { 38 function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) {
41 return getMyUserInformation(server.url, server.accessToken) 39 return getMyUserInformation(server.url, server.accessToken)
42 .then(res => { 40 .then(res => {
43 const user: User = res.body 41 const user: User = res.body
@@ -49,7 +47,7 @@ describe('Test video NSFW policy', function () {
49 if (token) { 47 if (token) {
50 promises = [ 48 promises = [
51 getVideosListWithToken(server.url, token, query), 49 getVideosListWithToken(server.url, token, query),
52 searchVideoWithToken(server.url, 'n', token, query), 50 server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', ...query } }),
53 getAccountVideos(server.url, token, accountName, 0, 5, undefined, query), 51 getAccountVideos(server.url, token, accountName, 0, 5, undefined, query),
54 getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query) 52 getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query)
55 ] 53 ]
@@ -66,7 +64,7 @@ describe('Test video NSFW policy', function () {
66 64
67 promises = [ 65 promises = [
68 getVideosList(server.url), 66 getVideosList(server.url),
69 searchVideo(server.url, 'n'), 67 server.searchCommand.searchVideos({ search: 'n' }),
70 getAccountVideos(server.url, undefined, accountName, 0, 5), 68 getAccountVideos(server.url, undefined, accountName, 0, 5),
71 getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5) 69 getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5)
72 ] 70 ]
@@ -230,7 +228,7 @@ describe('Test video NSFW policy', function () {
230 }) 228 })
231 229
232 it('Should display NSFW videos when the nsfw param === true', async function () { 230 it('Should display NSFW videos when the nsfw param === true', async function () {
233 for (const res of await getVideosFunctions(server.accessToken, { nsfw: true })) { 231 for (const res of await getVideosFunctions(server.accessToken, { nsfw: 'true' })) {
234 expect(res.body.total).to.equal(1) 232 expect(res.body.total).to.equal(1)
235 233
236 const videos = res.body.data 234 const videos = res.body.data
@@ -240,7 +238,7 @@ describe('Test video NSFW policy', function () {
240 }) 238 })
241 239
242 it('Should hide NSFW videos when the nsfw param === true', async function () { 240 it('Should hide NSFW videos when the nsfw param === true', async function () {
243 for (const res of await getVideosFunctions(server.accessToken, { nsfw: false })) { 241 for (const res of await getVideosFunctions(server.accessToken, { nsfw: 'false' })) {
244 expect(res.body.total).to.equal(1) 242 expect(res.body.total).to.equal(1)
245 243
246 const videos = res.body.data 244 const videos = res.body.data
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index b25cff879..209b93014 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -1,7 +1,8 @@
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 * as chai from 'chai'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils'
5import { 6import {
6 cleanupTests, 7 cleanupTests,
7 createUser, 8 createUser,
@@ -10,17 +11,15 @@ import {
10 getVideoWithToken, 11 getVideoWithToken,
11 killallServers, 12 killallServers,
12 reRunServer, 13 reRunServer,
13 searchVideoWithToken,
14 ServerInfo, 14 ServerInfo,
15 setAccessTokensToServers, 15 setAccessTokensToServers,
16 updateMyUser, 16 updateMyUser,
17 uploadVideo, 17 uploadVideo,
18 userLogin, 18 userLogin,
19 wait 19 wait
20} from '../../../../shared/extra-utils' 20} from '@shared/extra-utils'
21import { Video, VideoDetails } from '../../../../shared/models/videos' 21import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '@shared/extra-utils/videos/video-history'
22import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '../../../../shared/extra-utils/videos/video-history' 22import { Video, VideoDetails } from '@shared/models'
23import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
24 23
25const expect = chai.expect 24const expect = chai.expect
26 25
@@ -89,8 +88,8 @@ describe('Test videos history', function () {
89 } 88 }
90 89
91 { 90 {
92 const res = await searchVideoWithToken(server.url, 'video', server.accessToken) 91 const body = await server.searchCommand.searchVideos({ token: server.accessToken, search: 'video' })
93 videosOfVideos.push(res.body.data) 92 videosOfVideos.push(body.data)
94 } 93 }
95 94
96 for (const videos of videosOfVideos) { 95 for (const videos of videosOfVideos) {