]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/utils/videos/video-blacklist.ts
Add blacklist reason field
[github/Chocobozzz/PeerTube.git] / server / tests / utils / videos / video-blacklist.ts
1 import * as request from 'supertest'
2
3 function addVideoToBlacklist (url: string, token: string, videoId: number | string, reason?: string, specialStatus = 204) {
4 const path = '/api/v1/videos/' + videoId + '/blacklist'
5
6 return request(url)
7 .post(path)
8 .send({ reason })
9 .set('Accept', 'application/json')
10 .set('Authorization', 'Bearer ' + token)
11 .expect(specialStatus)
12 }
13
14 function 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
24 function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = 204) {
25 const path = '/api/v1/videos/' + videoId + '/blacklist'
26
27 return request(url)
28 .delete(path)
29 .set('Accept', 'application/json')
30 .set('Authorization', 'Bearer ' + token)
31 .expect(specialStatus)
32 }
33
34 function getBlacklistedVideosList (url: string, token: string, specialStatus = 200) {
35 const path = '/api/v1/videos/blacklist/'
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
46 function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) {
47 const path = '/api/v1/videos/blacklist/'
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
60 export {
61 addVideoToBlacklist,
62 removeVideoFromBlacklist,
63 getBlacklistedVideosList,
64 getSortedBlacklistedVideosList,
65 updateVideoBlacklist
66 }