]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/utils/videos/video-blacklist.ts
Add blacklist reason field
[github/Chocobozzz/PeerTube.git] / server / tests / utils / videos / video-blacklist.ts
CommitLineData
792dbaf0
GS
1import * as request from 'supertest'
2
26b7305a 3function addVideoToBlacklist (url: string, token: string, videoId: number | string, reason?: string, specialStatus = 204) {
792dbaf0
GS
4 const path = '/api/v1/videos/' + videoId + '/blacklist'
5
6 return request(url)
7 .post(path)
26b7305a 8 .send({ reason })
792dbaf0
GS
9 .set('Accept', 'application/json')
10 .set('Authorization', 'Bearer ' + token)
11 .expect(specialStatus)
12}
13
26b7305a
C
14function updateVideoBlacklist (url: string, token: string, videoId: number, reason?: string, specialStatus = 204) {
15 const path = '/api/v1/videos/' + videoId + '/blacklist'
16
17 return request(url)
18 .put(path)
19 .send({ reason })
20 .set('Accept', 'application/json')
21 .set('Authorization', 'Bearer ' + token)
22 .expect(specialStatus)}
23
11ba2ab3 24function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = 204) {
35bf0c83 25 const path = '/api/v1/videos/' + videoId + '/blacklist'
792dbaf0
GS
26
27 return request(url)
28 .delete(path)
29 .set('Accept', 'application/json')
30 .set('Authorization', 'Bearer ' + token)
31 .expect(specialStatus)
32}
33
34function getBlacklistedVideosList (url: string, token: string, specialStatus = 200) {
35bf0c83 35 const path = '/api/v1/videos/blacklist/'
792dbaf0
GS
36
37 return request(url)
38 .get(path)
39 .query({ sort: 'createdAt' })
40 .set('Accept', 'application/json')
41 .set('Authorization', 'Bearer ' + token)
42 .expect(specialStatus)
43 .expect('Content-Type', /json/)
44}
45
46function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) {
35bf0c83 47 const path = '/api/v1/videos/blacklist/'
792dbaf0
GS
48
49 return request(url)
50 .get(path)
51 .query({ sort: sort })
52 .set('Accept', 'application/json')
53 .set('Authorization', 'Bearer ' + token)
54 .expect(specialStatus)
55 .expect('Content-Type', /json/)
56}
57
58// ---------------------------------------------------------------------------
59
60export {
61 addVideoToBlacklist,
62 removeVideoFromBlacklist,
63 getBlacklistedVideosList,
26b7305a
C
64 getSortedBlacklistedVideosList,
65 updateVideoBlacklist
792dbaf0 66}