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.ts52
1 files changed, 26 insertions, 26 deletions
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index b8fff096d..95395a582 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -18,7 +18,7 @@ describe('Test video NSFW policy', function () {
18 let customConfig: CustomConfig 18 let customConfig: CustomConfig
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.usersCommand.getMyInfo() 21 const user = await server.users.getMyInfo()
22 const videoChannelName = user.videoChannels[0].name 22 const videoChannelName = user.videoChannels[0].name
23 const accountName = user.account.name + '@' + user.account.host 23 const accountName = user.account.name + '@' + user.account.host
24 const hasQuery = Object.keys(query).length !== 0 24 const hasQuery = Object.keys(query).length !== 0
@@ -26,15 +26,15 @@ describe('Test video NSFW policy', function () {
26 26
27 if (token) { 27 if (token) {
28 promises = [ 28 promises = [
29 server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }), 29 server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }),
30 server.videosCommand.listWithToken({ token, ...query }), 30 server.videos.listWithToken({ token, ...query }),
31 server.videosCommand.listByAccount({ token, accountName, ...query }), 31 server.videos.listByAccount({ token, accountName, ...query }),
32 server.videosCommand.listByChannel({ token, videoChannelName, ...query }) 32 server.videos.listByChannel({ token, videoChannelName, ...query })
33 ] 33 ]
34 34
35 // Overviews do not support video filters 35 // Overviews do not support video filters
36 if (!hasQuery) { 36 if (!hasQuery) {
37 const p = server.overviewsCommand.getVideos({ page: 1, token }) 37 const p = server.overviews.getVideos({ page: 1, token })
38 .then(res => createOverviewRes(res)) 38 .then(res => createOverviewRes(res))
39 promises.push(p) 39 promises.push(p)
40 } 40 }
@@ -43,15 +43,15 @@ describe('Test video NSFW policy', function () {
43 } 43 }
44 44
45 promises = [ 45 promises = [
46 server.searchCommand.searchVideos({ search: 'n', sort: '-publishedAt' }), 46 server.search.searchVideos({ search: 'n', sort: '-publishedAt' }),
47 server.videosCommand.list(), 47 server.videos.list(),
48 server.videosCommand.listByAccount({ accountName }), 48 server.videos.listByAccount({ accountName }),
49 server.videosCommand.listByChannel({ videoChannelName }) 49 server.videos.listByChannel({ videoChannelName })
50 ] 50 ]
51 51
52 // Overviews do not support video filters 52 // Overviews do not support video filters
53 if (!hasQuery) { 53 if (!hasQuery) {
54 const p = server.overviewsCommand.getVideos({ page: 1 }) 54 const p = server.overviews.getVideos({ page: 1 })
55 .then(res => createOverviewRes(res)) 55 .then(res => createOverviewRes(res))
56 promises.push(p) 56 promises.push(p)
57 } 57 }
@@ -68,20 +68,20 @@ describe('Test video NSFW policy', function () {
68 68
69 { 69 {
70 const attributes = { name: 'nsfw', nsfw: true, category: 1 } 70 const attributes = { name: 'nsfw', nsfw: true, category: 1 }
71 await server.videosCommand.upload({ attributes }) 71 await server.videos.upload({ attributes })
72 } 72 }
73 73
74 { 74 {
75 const attributes = { name: 'normal', nsfw: false, category: 1 } 75 const attributes = { name: 'normal', nsfw: false, category: 1 }
76 await server.videosCommand.upload({ attributes }) 76 await server.videos.upload({ attributes })
77 } 77 }
78 78
79 customConfig = await server.configCommand.getCustomConfig() 79 customConfig = await server.config.getCustomConfig()
80 }) 80 })
81 81
82 describe('Instance default NSFW policy', function () { 82 describe('Instance default NSFW policy', function () {
83 it('Should display NSFW videos with display default NSFW policy', async function () { 83 it('Should display NSFW videos with display default NSFW policy', async function () {
84 const serverConfig = await server.configCommand.getConfig() 84 const serverConfig = await server.config.getConfig()
85 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display') 85 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display')
86 86
87 for (const body of await getVideosFunctions()) { 87 for (const body of await getVideosFunctions()) {
@@ -96,9 +96,9 @@ describe('Test video NSFW policy', function () {
96 96
97 it('Should not display NSFW videos with do_not_list default NSFW policy', async function () { 97 it('Should not display NSFW videos with do_not_list default NSFW policy', async function () {
98 customConfig.instance.defaultNSFWPolicy = 'do_not_list' 98 customConfig.instance.defaultNSFWPolicy = 'do_not_list'
99 await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig }) 99 await server.config.updateCustomConfig({ newCustomConfig: customConfig })
100 100
101 const serverConfig = await server.configCommand.getConfig() 101 const serverConfig = await server.config.getConfig()
102 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('do_not_list') 102 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('do_not_list')
103 103
104 for (const body of await getVideosFunctions()) { 104 for (const body of await getVideosFunctions()) {
@@ -112,9 +112,9 @@ describe('Test video NSFW policy', function () {
112 112
113 it('Should display NSFW videos with blur default NSFW policy', async function () { 113 it('Should display NSFW videos with blur default NSFW policy', async function () {
114 customConfig.instance.defaultNSFWPolicy = 'blur' 114 customConfig.instance.defaultNSFWPolicy = 'blur'
115 await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig }) 115 await server.config.updateCustomConfig({ newCustomConfig: customConfig })
116 116
117 const serverConfig = await server.configCommand.getConfig() 117 const serverConfig = await server.config.getConfig()
118 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('blur') 118 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('blur')
119 119
120 for (const body of await getVideosFunctions()) { 120 for (const body of await getVideosFunctions()) {
@@ -133,17 +133,17 @@ describe('Test video NSFW policy', function () {
133 it('Should create a user having the default nsfw policy', async function () { 133 it('Should create a user having the default nsfw policy', async function () {
134 const username = 'user1' 134 const username = 'user1'
135 const password = 'my super password' 135 const password = 'my super password'
136 await server.usersCommand.create({ username: username, password: password }) 136 await server.users.create({ username: username, password: password })
137 137
138 userAccessToken = await server.loginCommand.getAccessToken({ username, password }) 138 userAccessToken = await server.login.getAccessToken({ username, password })
139 139
140 const user = await server.usersCommand.getMyInfo({ token: userAccessToken }) 140 const user = await server.users.getMyInfo({ token: userAccessToken })
141 expect(user.nsfwPolicy).to.equal('blur') 141 expect(user.nsfwPolicy).to.equal('blur')
142 }) 142 })
143 143
144 it('Should display NSFW videos with blur user NSFW policy', async function () { 144 it('Should display NSFW videos with blur user NSFW policy', async function () {
145 customConfig.instance.defaultNSFWPolicy = 'do_not_list' 145 customConfig.instance.defaultNSFWPolicy = 'do_not_list'
146 await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig }) 146 await server.config.updateCustomConfig({ newCustomConfig: customConfig })
147 147
148 for (const body of await getVideosFunctions(userAccessToken)) { 148 for (const body of await getVideosFunctions(userAccessToken)) {
149 expect(body.total).to.equal(2) 149 expect(body.total).to.equal(2)
@@ -156,7 +156,7 @@ describe('Test video NSFW policy', function () {
156 }) 156 })
157 157
158 it('Should display NSFW videos with display user NSFW policy', async function () { 158 it('Should display NSFW videos with display user NSFW policy', async function () {
159 await server.usersCommand.updateMe({ nsfwPolicy: 'display' }) 159 await server.users.updateMe({ nsfwPolicy: 'display' })
160 160
161 for (const body of await getVideosFunctions(server.accessToken)) { 161 for (const body of await getVideosFunctions(server.accessToken)) {
162 expect(body.total).to.equal(2) 162 expect(body.total).to.equal(2)
@@ -169,7 +169,7 @@ describe('Test video NSFW policy', function () {
169 }) 169 })
170 170
171 it('Should not display NSFW videos with do_not_list user NSFW policy', async function () { 171 it('Should not display NSFW videos with do_not_list user NSFW policy', async function () {
172 await server.usersCommand.updateMe({ nsfwPolicy: 'do_not_list' }) 172 await server.users.updateMe({ nsfwPolicy: 'do_not_list' })
173 173
174 for (const body of await getVideosFunctions(server.accessToken)) { 174 for (const body of await getVideosFunctions(server.accessToken)) {
175 expect(body.total).to.equal(1) 175 expect(body.total).to.equal(1)
@@ -181,7 +181,7 @@ describe('Test video NSFW policy', function () {
181 }) 181 })
182 182
183 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 () {
184 const { total, data } = await server.videosCommand.listMyVideos() 184 const { total, data } = await server.videos.listMyVideos()
185 expect(total).to.equal(2) 185 expect(total).to.equal(2)
186 186
187 expect(data).to.have.lengthOf(2) 187 expect(data).to.have.lengthOf(2)