aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-nsfw.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-nsfw.ts')
-rw-r--r--server/tests/api/videos/video-nsfw.ts38
1 files changed, 31 insertions, 7 deletions
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index 7eba8d7d9..b16b484b9 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -19,12 +19,20 @@ import {
19 updateCustomConfig, 19 updateCustomConfig,
20 updateMyUser 20 updateMyUser
21} from '../../../../shared/extra-utils' 21} from '../../../../shared/extra-utils'
22import { ServerConfig } from '../../../../shared/models' 22import { ServerConfig, VideosOverview } from '../../../../shared/models'
23import { CustomConfig } from '../../../../shared/models/server/custom-config.model' 23import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
24import { User } from '../../../../shared/models/users' 24import { User } from '../../../../shared/models/users'
25import { getVideosOverview, getVideosOverviewWithToken } from '@shared/extra-utils/overviews/overviews'
25 26
26const expect = chai.expect 27const expect = chai.expect
27 28
29function createOverviewRes (res: any) {
30 const overview = res.body as VideosOverview
31
32 const videos = overview.categories[0].videos
33 return { body: { data: videos, total: videos.length } }
34}
35
28describe('Test video NSFW policy', function () { 36describe('Test video NSFW policy', function () {
29 let server: ServerInfo 37 let server: ServerInfo
30 let userAccessToken: string 38 let userAccessToken: string
@@ -36,22 +44,38 @@ describe('Test video NSFW policy', function () {
36 const user: User = res.body 44 const user: User = res.body
37 const videoChannelName = user.videoChannels[0].name 45 const videoChannelName = user.videoChannels[0].name
38 const accountName = user.account.name + '@' + user.account.host 46 const accountName = user.account.name + '@' + user.account.host
47 const hasQuery = Object.keys(query).length !== 0
48 let promises: Promise<any>[]
39 49
40 if (token) { 50 if (token) {
41 return Promise.all([ 51 promises = [
42 getVideosListWithToken(server.url, token, query), 52 getVideosListWithToken(server.url, token, query),
43 searchVideoWithToken(server.url, 'n', token, query), 53 searchVideoWithToken(server.url, 'n', token, query),
44 getAccountVideos(server.url, token, accountName, 0, 5, undefined, query), 54 getAccountVideos(server.url, token, accountName, 0, 5, undefined, query),
45 getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query) 55 getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query)
46 ]) 56 ]
57
58 // Overviews do not support video filters
59 if (!hasQuery) {
60 promises.push(getVideosOverviewWithToken(server.url, 1, token).then(res => createOverviewRes(res)))
61 }
62
63 return Promise.all(promises)
47 } 64 }
48 65
49 return Promise.all([ 66 promises = [
50 getVideosList(server.url), 67 getVideosList(server.url),
51 searchVideo(server.url, 'n'), 68 searchVideo(server.url, 'n'),
52 getAccountVideos(server.url, undefined, accountName, 0, 5), 69 getAccountVideos(server.url, undefined, accountName, 0, 5),
53 getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5) 70 getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5)
54 ]) 71 ]
72
73 // Overviews do not support video filters
74 if (!hasQuery) {
75 promises.push(getVideosOverview(server.url, 1).then(res => createOverviewRes(res)))
76 }
77
78 return Promise.all(promises)
55 }) 79 })
56 } 80 }
57 81
@@ -63,12 +87,12 @@ describe('Test video NSFW policy', function () {
63 await setAccessTokensToServers([ server ]) 87 await setAccessTokensToServers([ server ])
64 88
65 { 89 {
66 const attributes = { name: 'nsfw', nsfw: true } 90 const attributes = { name: 'nsfw', nsfw: true, category: 1 }
67 await uploadVideo(server.url, server.accessToken, attributes) 91 await uploadVideo(server.url, server.accessToken, attributes)
68 } 92 }
69 93
70 { 94 {
71 const attributes = { name: 'normal', nsfw: false } 95 const attributes = { name: 'normal', nsfw: false, category: 1 }
72 await uploadVideo(server.url, server.accessToken, attributes) 96 await uploadVideo(server.url, server.accessToken, attributes)
73 } 97 }
74 98