aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils')
-rw-r--r--server/tests/utils/users/users.ts5
-rw-r--r--server/tests/utils/videos/videos.ts30
2 files changed, 31 insertions, 4 deletions
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'
3import { makePostBodyRequest, makeUploadRequest, makePutBodyRequest } from '../' 3import { makePostBodyRequest, makeUploadRequest, makePutBodyRequest } from '../'
4 4
5import { UserRole } from '../../../../shared/index' 5import { UserRole } from '../../../../shared/index'
6import { NSFWPolicyType } from '../../../../shared/models/videos/nsfw-policy.type'
6 7
7function createUser ( 8function createUser (
8 url: string, 9 url: string,
@@ -128,7 +129,7 @@ function updateMyUser (options: {
128 url: string 129 url: string
129 accessToken: string, 130 accessToken: string,
130 newPassword?: string, 131 newPassword?: string,
131 displayNSFW?: boolean, 132 nsfwPolicy?: NSFWPolicyType,
132 email?: string, 133 email?: string,
133 autoPlayVideo?: boolean 134 autoPlayVideo?: boolean
134 description?: string 135 description?: string
@@ -137,7 +138,7 @@ function updateMyUser (options: {
137 138
138 const toSend = {} 139 const toSend = {}
139 if (options.newPassword !== undefined && options.newPassword !== null) toSend['password'] = options.newPassword 140 if (options.newPassword !== undefined && options.newPassword !== null) toSend['password'] = options.newPassword
140 if (options.displayNSFW !== undefined && options.displayNSFW !== null) toSend['displayNSFW'] = options.displayNSFW 141 if (options.nsfwPolicy !== undefined && options.nsfwPolicy !== null) toSend['nsfwPolicy'] = options.nsfwPolicy
141 if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend['autoPlayVideo'] = options.autoPlayVideo 142 if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend['autoPlayVideo'] = options.autoPlayVideo
142 if (options.email !== undefined && options.email !== null) toSend['email'] = options.email 143 if (options.email !== undefined && options.email !== null) toSend['email'] = options.email
143 if (options.description !== undefined && options.description !== null) toSend['description'] = options.description 144 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..5e186147e 100644
--- a/server/tests/utils/videos/videos.ts
+++ b/server/tests/utils/videos/videos.ts
@@ -128,6 +128,18 @@ function getVideosList (url: string) {
128 .expect('Content-Type', /json/) 128 .expect('Content-Type', /json/)
129} 129}
130 130
131function getVideosListWithToken (url: string, token: string) {
132 const path = '/api/v1/videos'
133
134 return request(url)
135 .get(path)
136 .set('Authorization', 'Bearer ' + token)
137 .query({ sort: 'name' })
138 .set('Accept', 'application/json')
139 .expect(200)
140 .expect('Content-Type', /json/)
141}
142
131function getLocalVideos (url: string) { 143function getLocalVideos (url: string) {
132 const path = '/api/v1/videos' 144 const path = '/api/v1/videos'
133 145
@@ -202,6 +214,18 @@ function searchVideo (url: string, search: string) {
202 .expect('Content-Type', /json/) 214 .expect('Content-Type', /json/)
203} 215}
204 216
217function searchVideoWithToken (url: string, search: string, token: string) {
218 const path = '/api/v1/videos'
219 const req = request(url)
220 .get(path + '/search')
221 .set('Authorization', 'Bearer ' + token)
222 .query({ search })
223 .set('Accept', 'application/json')
224
225 return req.expect(200)
226 .expect('Content-Type', /json/)
227}
228
205function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) { 229function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) {
206 const path = '/api/v1/videos' 230 const path = '/api/v1/videos'
207 231
@@ -418,6 +442,8 @@ async function completeVideoCheck (
418 expect(video.licence.label).to.equal(VIDEO_LICENCES[attributes.licence] || 'Unknown') 442 expect(video.licence.label).to.equal(VIDEO_LICENCES[attributes.licence] || 'Unknown')
419 expect(video.language.id).to.equal(attributes.language) 443 expect(video.language.id).to.equal(attributes.language)
420 expect(video.language.label).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown') 444 expect(video.language.label).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown')
445 expect(video.privacy.id).to.deep.equal(attributes.privacy)
446 expect(video.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy])
421 expect(video.nsfw).to.equal(attributes.nsfw) 447 expect(video.nsfw).to.equal(attributes.nsfw)
422 expect(video.description).to.equal(attributes.description) 448 expect(video.description).to.equal(attributes.description)
423 expect(video.account.host).to.equal(attributes.account.host) 449 expect(video.account.host).to.equal(attributes.account.host)
@@ -435,8 +461,6 @@ async function completeVideoCheck (
435 461
436 expect(videoDetails.files).to.have.lengthOf(attributes.files.length) 462 expect(videoDetails.files).to.have.lengthOf(attributes.files.length)
437 expect(videoDetails.tags).to.deep.equal(attributes.tags) 463 expect(videoDetails.tags).to.deep.equal(attributes.tags)
438 expect(videoDetails.privacy.id).to.deep.equal(attributes.privacy)
439 expect(videoDetails.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy])
440 expect(videoDetails.account.name).to.equal(attributes.account.name) 464 expect(videoDetails.account.name).to.equal(attributes.account.name)
441 expect(videoDetails.account.host).to.equal(attributes.account.host) 465 expect(videoDetails.account.host).to.equal(attributes.account.host)
442 expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled) 466 expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled)
@@ -490,6 +514,7 @@ export {
490 getVideoPrivacies, 514 getVideoPrivacies,
491 getVideoLanguages, 515 getVideoLanguages,
492 getMyVideos, 516 getMyVideos,
517 searchVideoWithToken,
493 getVideo, 518 getVideo,
494 getVideoWithToken, 519 getVideoWithToken,
495 getVideosList, 520 getVideosList,
@@ -499,6 +524,7 @@ export {
499 searchVideo, 524 searchVideo,
500 searchVideoWithPagination, 525 searchVideoWithPagination,
501 searchVideoWithSort, 526 searchVideoWithSort,
527 getVideosListWithToken,
502 uploadVideo, 528 uploadVideo,
503 updateVideo, 529 updateVideo,
504 rateVideo, 530 rateVideo,