From 0883b3245bf0deb9106c4041e9afbd3521b79280 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Apr 2018 11:01:34 +0200 Subject: Add ability to choose what policy we have for NSFW videos There is a global instance setting and a per user setting --- server/tests/utils/users/users.ts | 5 +++-- server/tests/utils/videos/videos.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'server/tests/utils') diff --git a/server/tests/utils/users/users.ts b/server/tests/utils/users/users.ts index daf731a14..fc6b26c50 100644 --- a/server/tests/utils/users/users.ts +++ b/server/tests/utils/users/users.ts @@ -3,6 +3,7 @@ import * as request from 'supertest' import { makePostBodyRequest, makeUploadRequest, makePutBodyRequest } from '../' import { UserRole } from '../../../../shared/index' +import { NSFWPolicyType } from '../../../../shared/models/videos/nsfw-policy.type' function createUser ( url: string, @@ -128,7 +129,7 @@ function updateMyUser (options: { url: string accessToken: string, newPassword?: string, - displayNSFW?: boolean, + nsfwPolicy?: NSFWPolicyType, email?: string, autoPlayVideo?: boolean description?: string @@ -137,7 +138,7 @@ function updateMyUser (options: { const toSend = {} if (options.newPassword !== undefined && options.newPassword !== null) toSend['password'] = options.newPassword - if (options.displayNSFW !== undefined && options.displayNSFW !== null) toSend['displayNSFW'] = options.displayNSFW + if (options.nsfwPolicy !== undefined && options.nsfwPolicy !== null) toSend['nsfwPolicy'] = options.nsfwPolicy if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend['autoPlayVideo'] = options.autoPlayVideo if (options.email !== undefined && options.email !== null) toSend['email'] = options.email if (options.description !== undefined && options.description !== null) toSend['description'] = options.description diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 01e7fa5a1..df9071c29 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts @@ -128,6 +128,18 @@ function getVideosList (url: string) { .expect('Content-Type', /json/) } +function getVideosListWithToken (url: string, token: string) { + const path = '/api/v1/videos' + + return request(url) + .get(path) + .set('Authorization', 'Bearer ' + token) + .query({ sort: 'name' }) + .set('Accept', 'application/json') + .expect(200) + .expect('Content-Type', /json/) +} + function getLocalVideos (url: string) { const path = '/api/v1/videos' @@ -202,6 +214,18 @@ function searchVideo (url: string, search: string) { .expect('Content-Type', /json/) } +function searchVideoWithToken (url: string, search: string, token: string) { + const path = '/api/v1/videos' + const req = request(url) + .get(path + '/search') + .set('Authorization', 'Bearer ' + token) + .query({ search }) + .set('Accept', 'application/json') + + return req.expect(200) + .expect('Content-Type', /json/) +} + function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) { const path = '/api/v1/videos' @@ -490,6 +514,7 @@ export { getVideoPrivacies, getVideoLanguages, getMyVideos, + searchVideoWithToken, getVideo, getVideoWithToken, getVideosList, @@ -499,6 +524,7 @@ export { searchVideo, searchVideoWithPagination, searchVideoWithSort, + getVideosListWithToken, uploadVideo, updateVideo, rateVideo, -- cgit v1.2.3 From 2243730c8edf210c0a3ffc161bac89785f6a52f0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Apr 2018 14:52:10 +0200 Subject: Add information concerning video privacy in my videos list --- server/tests/utils/videos/videos.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/tests/utils') diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index df9071c29..5e186147e 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts @@ -442,6 +442,8 @@ async function completeVideoCheck ( expect(video.licence.label).to.equal(VIDEO_LICENCES[attributes.licence] || 'Unknown') expect(video.language.id).to.equal(attributes.language) expect(video.language.label).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown') + expect(video.privacy.id).to.deep.equal(attributes.privacy) + expect(video.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy]) expect(video.nsfw).to.equal(attributes.nsfw) expect(video.description).to.equal(attributes.description) expect(video.account.host).to.equal(attributes.account.host) @@ -459,8 +461,6 @@ async function completeVideoCheck ( expect(videoDetails.files).to.have.lengthOf(attributes.files.length) expect(videoDetails.tags).to.deep.equal(attributes.tags) - expect(videoDetails.privacy.id).to.deep.equal(attributes.privacy) - expect(videoDetails.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy]) expect(videoDetails.account.name).to.equal(attributes.account.name) expect(videoDetails.account.host).to.equal(attributes.account.host) expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled) -- cgit v1.2.3