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.ts26
1 files changed, 6 insertions, 20 deletions
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index a30b11ace..9dc26fca6 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -4,20 +4,17 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 createUser,
8 flushAndRunServer, 7 flushAndRunServer,
9 getAccountVideos, 8 getAccountVideos,
10 getMyUserInformation,
11 getMyVideos, 9 getMyVideos,
12 getVideoChannelVideos, 10 getVideoChannelVideos,
13 getVideosList, 11 getVideosList,
14 getVideosListWithToken, 12 getVideosListWithToken,
15 ServerInfo, 13 ServerInfo,
16 setAccessTokensToServers, 14 setAccessTokensToServers,
17 updateMyUser,
18 uploadVideo 15 uploadVideo
19} from '@shared/extra-utils' 16} from '@shared/extra-utils'
20import { BooleanBothQuery, CustomConfig, ResultList, User, Video, VideosOverview } from '@shared/models' 17import { BooleanBothQuery, CustomConfig, ResultList, Video, VideosOverview } from '@shared/models'
21 18
22const expect = chai.expect 19const expect = chai.expect
23 20
@@ -32,8 +29,7 @@ describe('Test video NSFW policy', function () {
32 let customConfig: CustomConfig 29 let customConfig: CustomConfig
33 30
34 async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) { 31 async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) {
35 const res = await getMyUserInformation(server.url, server.accessToken) 32 const user = await server.usersCommand.getMyInfo()
36 const user: User = res.body
37 const videoChannelName = user.videoChannels[0].name 33 const videoChannelName = user.videoChannels[0].name
38 const accountName = user.account.name + '@' + user.account.host 34 const accountName = user.account.name + '@' + user.account.host
39 const hasQuery = Object.keys(query).length !== 0 35 const hasQuery = Object.keys(query).length !== 0
@@ -148,13 +144,11 @@ describe('Test video NSFW policy', function () {
148 it('Should create a user having the default nsfw policy', async function () { 144 it('Should create a user having the default nsfw policy', async function () {
149 const username = 'user1' 145 const username = 'user1'
150 const password = 'my super password' 146 const password = 'my super password'
151 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) 147 await server.usersCommand.create({ username: username, password: password })
152 148
153 userAccessToken = await server.loginCommand.getAccessToken({ username, password }) 149 userAccessToken = await server.loginCommand.getAccessToken({ username, password })
154 150
155 const res = await getMyUserInformation(server.url, userAccessToken) 151 const user = await server.usersCommand.getMyInfo({ token: userAccessToken })
156 const user = res.body
157
158 expect(user.nsfwPolicy).to.equal('blur') 152 expect(user.nsfwPolicy).to.equal('blur')
159 }) 153 })
160 154
@@ -173,11 +167,7 @@ describe('Test video NSFW policy', function () {
173 }) 167 })
174 168
175 it('Should display NSFW videos with display user NSFW policy', async function () { 169 it('Should display NSFW videos with display user NSFW policy', async function () {
176 await updateMyUser({ 170 await server.usersCommand.updateMe({ nsfwPolicy: 'display' })
177 url: server.url,
178 accessToken: server.accessToken,
179 nsfwPolicy: 'display'
180 })
181 171
182 for (const body of await getVideosFunctions(server.accessToken)) { 172 for (const body of await getVideosFunctions(server.accessToken)) {
183 expect(body.total).to.equal(2) 173 expect(body.total).to.equal(2)
@@ -190,11 +180,7 @@ describe('Test video NSFW policy', function () {
190 }) 180 })
191 181
192 it('Should not display NSFW videos with do_not_list user NSFW policy', async function () { 182 it('Should not display NSFW videos with do_not_list user NSFW policy', async function () {
193 await updateMyUser({ 183 await server.usersCommand.updateMe({ nsfwPolicy: 'do_not_list' })
194 url: server.url,
195 accessToken: server.accessToken,
196 nsfwPolicy: 'do_not_list'
197 })
198 184
199 for (const body of await getVideosFunctions(server.accessToken)) { 185 for (const body of await getVideosFunctions(server.accessToken)) {
200 expect(body.total).to.equal(1) 186 expect(body.total).to.equal(1)