aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-nsfw.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-15 10:02:54 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitd23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch)
treeda82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/api/videos/video-nsfw.ts
parent7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff)
downloadPeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip
Introduce videos command
Diffstat (limited to 'server/tests/api/videos/video-nsfw.ts')
-rw-r--r--server/tests/api/videos/video-nsfw.ts40
1 files changed, 14 insertions, 26 deletions
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index 9dc26fca6..b8fff096d 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -2,18 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils'
6 cleanupTests,
7 flushAndRunServer,
8 getAccountVideos,
9 getMyVideos,
10 getVideoChannelVideos,
11 getVideosList,
12 getVideosListWithToken,
13 ServerInfo,
14 setAccessTokensToServers,
15 uploadVideo
16} from '@shared/extra-utils'
17import { BooleanBothQuery, CustomConfig, ResultList, Video, VideosOverview } from '@shared/models' 6import { BooleanBothQuery, CustomConfig, ResultList, Video, VideosOverview } from '@shared/models'
18 7
19const expect = chai.expect 8const expect = chai.expect
@@ -37,10 +26,10 @@ describe('Test video NSFW policy', function () {
37 26
38 if (token) { 27 if (token) {
39 promises = [ 28 promises = [
40 getVideosListWithToken(server.url, token, query).then(res => res.body),
41 server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }), 29 server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }),
42 getAccountVideos(server.url, token, accountName, 0, 5, undefined, query).then(res => res.body), 30 server.videosCommand.listWithToken({ token, ...query }),
43 getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query).then(res => res.body) 31 server.videosCommand.listByAccount({ token, accountName, ...query }),
32 server.videosCommand.listByChannel({ token, videoChannelName, ...query })
44 ] 33 ]
45 34
46 // Overviews do not support video filters 35 // Overviews do not support video filters
@@ -54,10 +43,10 @@ describe('Test video NSFW policy', function () {
54 } 43 }
55 44
56 promises = [ 45 promises = [
57 getVideosList(server.url).then(res => res.body),
58 server.searchCommand.searchVideos({ search: 'n', sort: '-publishedAt' }), 46 server.searchCommand.searchVideos({ search: 'n', sort: '-publishedAt' }),
59 getAccountVideos(server.url, undefined, accountName, 0, 5).then(res => res.body), 47 server.videosCommand.list(),
60 getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5).then(res => res.body) 48 server.videosCommand.listByAccount({ accountName }),
49 server.videosCommand.listByChannel({ videoChannelName })
61 ] 50 ]
62 51
63 // Overviews do not support video filters 52 // Overviews do not support video filters
@@ -79,12 +68,12 @@ describe('Test video NSFW policy', function () {
79 68
80 { 69 {
81 const attributes = { name: 'nsfw', nsfw: true, category: 1 } 70 const attributes = { name: 'nsfw', nsfw: true, category: 1 }
82 await uploadVideo(server.url, server.accessToken, attributes) 71 await server.videosCommand.upload({ attributes })
83 } 72 }
84 73
85 { 74 {
86 const attributes = { name: 'normal', nsfw: false, category: 1 } 75 const attributes = { name: 'normal', nsfw: false, category: 1 }
87 await uploadVideo(server.url, server.accessToken, attributes) 76 await server.videosCommand.upload({ attributes })
88 } 77 }
89 78
90 customConfig = await server.configCommand.getCustomConfig() 79 customConfig = await server.configCommand.getCustomConfig()
@@ -192,13 +181,12 @@ describe('Test video NSFW policy', function () {
192 }) 181 })
193 182
194 it('Should be able to see my NSFW videos even with do_not_list user NSFW policy', async function () { 183 it('Should be able to see my NSFW videos even with do_not_list user NSFW policy', async function () {
195 const res = await getMyVideos(server.url, server.accessToken, 0, 5) 184 const { total, data } = await server.videosCommand.listMyVideos()
196 expect(res.body.total).to.equal(2) 185 expect(total).to.equal(2)
197 186
198 const videos = res.body.data 187 expect(data).to.have.lengthOf(2)
199 expect(videos).to.have.lengthOf(2) 188 expect(data[0].name).to.equal('normal')
200 expect(videos[0].name).to.equal('normal') 189 expect(data[1].name).to.equal('nsfw')
201 expect(videos[1].name).to.equal('nsfw')
202 }) 190 })
203 191
204 it('Should display NSFW videos when the nsfw param === true', async function () { 192 it('Should display NSFW videos when the nsfw param === true', async function () {