aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-nsfw.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-25 10:21:38 +0200
committerChocobozzz <me@florianbigard.com>2018-04-25 13:50:48 +0200
commit6b738c7a31591a83fdcd9c78b6b1f98e543c378b (patch)
treedb771d0e99e9ff27570885fe2a6f58a7c1948fbc /server/tests/api/videos/video-nsfw.ts
parent48dce1c90dff4e90a4bcffefaecf157336cf904b (diff)
downloadPeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.tar.gz
PeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.tar.zst
PeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.zip
Video channel API routes refractor
Diffstat (limited to 'server/tests/api/videos/video-nsfw.ts')
-rw-r--r--server/tests/api/videos/video-nsfw.ts55
1 files changed, 34 insertions, 21 deletions
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index 4e5ab11ce..8901f38f9 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -7,8 +7,9 @@ import { userLogin } from '../../utils/users/login'
7import { createUser } from '../../utils/users/users' 7import { createUser } from '../../utils/users/users'
8import { getMyVideos } from '../../utils/videos/videos' 8import { getMyVideos } from '../../utils/videos/videos'
9import { 9import {
10 getAccountVideos,
10 getConfig, getCustomConfig, 11 getConfig, getCustomConfig,
11 getMyUserInformation, 12 getMyUserInformation, getVideoChannelVideos,
12 getVideosListWithToken, 13 getVideosListWithToken,
13 runServer, 14 runServer,
14 searchVideo, 15 searchVideo,
@@ -17,6 +18,7 @@ import {
17} from '../../utils' 18} from '../../utils'
18import { ServerConfig } from '../../../../shared/models' 19import { ServerConfig } from '../../../../shared/models'
19import { CustomConfig } from '../../../../shared/models/server/custom-config.model' 20import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
21import { User } from '../../../../shared/models/users'
20 22
21const expect = chai.expect 23const expect = chai.expect
22 24
@@ -25,6 +27,31 @@ describe('Test video NSFW policy', function () {
25 let userAccessToken: string 27 let userAccessToken: string
26 let customConfig: CustomConfig 28 let customConfig: CustomConfig
27 29
30 function getVideosFunctions (token?: string) {
31 return getMyUserInformation(server.url, server.accessToken)
32 .then(res => {
33 const user: User = res.body
34 const videoChannelUUID = user.videoChannels[0].uuid
35 const accountUUID = user.account.uuid
36
37 if (token) {
38 return Promise.all([
39 getVideosListWithToken(server.url, token),
40 searchVideoWithToken(server.url, 'n', token),
41 getAccountVideos(server.url, token, accountUUID, 0, 5),
42 getVideoChannelVideos(server.url, token, accountUUID, videoChannelUUID, 0, 5)
43 ])
44 }
45
46 return Promise.all([
47 getVideosList(server.url),
48 searchVideo(server.url, 'n'),
49 getAccountVideos(server.url, undefined, accountUUID, 0, 5),
50 getVideoChannelVideos(server.url, undefined, accountUUID, videoChannelUUID, 0, 5)
51 ])
52 })
53 }
54
28 before(async function () { 55 before(async function () {
29 this.timeout(50000) 56 this.timeout(50000)
30 57
@@ -56,7 +83,7 @@ describe('Test video NSFW policy', function () {
56 const serverConfig: ServerConfig = resConfig.body 83 const serverConfig: ServerConfig = resConfig.body
57 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display') 84 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display')
58 85
59 for (const res of [ await getVideosList(server.url), await searchVideo(server.url, 'n') ]) { 86 for (const res of await getVideosFunctions()) {
60 expect(res.body.total).to.equal(2) 87 expect(res.body.total).to.equal(2)
61 88
62 const videos = res.body.data 89 const videos = res.body.data
@@ -74,7 +101,7 @@ describe('Test video NSFW policy', function () {
74 const serverConfig: ServerConfig = resConfig.body 101 const serverConfig: ServerConfig = resConfig.body
75 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('do_not_list') 102 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('do_not_list')
76 103
77 for (const res of [ await getVideosList(server.url), await searchVideo(server.url, 'n') ]) { 104 for (const res of await getVideosFunctions()) {
78 expect(res.body.total).to.equal(1) 105 expect(res.body.total).to.equal(1)
79 106
80 const videos = res.body.data 107 const videos = res.body.data
@@ -91,7 +118,7 @@ describe('Test video NSFW policy', function () {
91 const serverConfig: ServerConfig = resConfig.body 118 const serverConfig: ServerConfig = resConfig.body
92 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('blur') 119 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('blur')
93 120
94 for (const res of [ await getVideosList(server.url), await searchVideo(server.url, 'n') ]) { 121 for (const res of await getVideosFunctions()) {
95 expect(res.body.total).to.equal(2) 122 expect(res.body.total).to.equal(2)
96 123
97 const videos = res.body.data 124 const videos = res.body.data
@@ -118,12 +145,7 @@ describe('Test video NSFW policy', function () {
118 }) 145 })
119 146
120 it('Should display NSFW videos with blur user NSFW policy', async function () { 147 it('Should display NSFW videos with blur user NSFW policy', async function () {
121 const results = [ 148 for (const res of await getVideosFunctions(userAccessToken)) {
122 await getVideosListWithToken(server.url, userAccessToken),
123 await searchVideoWithToken(server.url, 'n', userAccessToken)
124 ]
125
126 for (const res of results) {
127 expect(res.body.total).to.equal(2) 149 expect(res.body.total).to.equal(2)
128 150
129 const videos = res.body.data 151 const videos = res.body.data
@@ -140,12 +162,7 @@ describe('Test video NSFW policy', function () {
140 nsfwPolicy: 'display' 162 nsfwPolicy: 'display'
141 }) 163 })
142 164
143 const results = [ 165 for (const res of await getVideosFunctions(server.accessToken)) {
144 await getVideosListWithToken(server.url, server.accessToken),
145 await searchVideoWithToken(server.url, 'n', server.accessToken)
146 ]
147
148 for (const res of results) {
149 expect(res.body.total).to.equal(2) 166 expect(res.body.total).to.equal(2)
150 167
151 const videos = res.body.data 168 const videos = res.body.data
@@ -162,11 +179,7 @@ describe('Test video NSFW policy', function () {
162 nsfwPolicy: 'do_not_list' 179 nsfwPolicy: 'do_not_list'
163 }) 180 })
164 181
165 const results = [ 182 for (const res of await getVideosFunctions(server.accessToken)) {
166 await getVideosListWithToken(server.url, server.accessToken),
167 await searchVideoWithToken(server.url, 'n', server.accessToken)
168 ]
169 for (const res of results) {
170 expect(res.body.total).to.equal(1) 183 expect(res.body.total).to.equal(1)
171 184
172 const videos = res.body.data 185 const videos = res.body.data