aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils
diff options
context:
space:
mode:
authorGreen-Star <Green-Star@users.noreply.github.com>2017-09-22 09:13:43 +0200
committerBigard Florian <florian.bigard@gmail.com>2017-09-22 09:13:43 +0200
commit792dbaf07f83fbe3f1d209cd9edf190442c7d2f3 (patch)
treef7edf9caf17baaaf95c219c3ac73d598e3fd3df8 /server/tests/utils
parentc9d6d155c397d0da0cb2d50064264fc1716f0501 (diff)
downloadPeerTube-792dbaf07f83fbe3f1d209cd9edf190442c7d2f3.tar.gz
PeerTube-792dbaf07f83fbe3f1d209cd9edf190442c7d2f3.tar.zst
PeerTube-792dbaf07f83fbe3f1d209cd9edf190442c7d2f3.zip
Handle blacklist (#84)
* Client: Add list blacklist feature * Server: Add list blacklist feature * Client: Add videoId column * Server: Add some video infos in the REST api * Client: Add video information in the blacklist list * Fix sortable columns :) * Client: Add removeFromBlacklist feature * Server: Add removeFromBlacklist feature * Move to TypeScript * Move to TypeScript and Promises * Server: Fix blacklist list sort * Server: Fetch videos informations * Use common shared interface for client and server * Add check-params remove blacklisted video tests * Add check-params list blacklisted videos tests * Add list blacklist tests * Add remove from blacklist tests * Add video blacklist management tests * Fix rebase onto develop issues * Server: Add sort on blacklist id column * Server: Add blacklists library * Add blacklist id sort test * Add check-params tests for blacklist list pagination, count and sort * Fix coding style * Increase Remote API tests timeout * Increase Request scheduler API tests timeout * Fix typo * Increase video transcoding API tests timeout * Move tests to Typescript * Use lodash orderBy method * Fix typos * Client: Remove optional tests in blacklist model attributes * Move blacklist routes from 'blacklists' to 'blacklist' * CLient: Remove blacklist-list.component.scss * Rename 'blacklists' files to 'blacklist' * Use only BlacklistedVideo interface * Server: Use getFormattedObjects method in listBlacklist method * Client: Use new coding style * Server: Use new sort validator methods * Server: Use new checkParams methods * Client: Fix sortable columns
Diffstat (limited to 'server/tests/utils')
-rw-r--r--server/tests/utils/index.ts2
-rw-r--r--server/tests/utils/video-blacklist.ts54
-rw-r--r--server/tests/utils/video-blacklists.ts17
3 files changed, 55 insertions, 18 deletions
diff --git a/server/tests/utils/index.ts b/server/tests/utils/index.ts
index 0fa28f2af..99c445887 100644
--- a/server/tests/utils/index.ts
+++ b/server/tests/utils/index.ts
@@ -9,5 +9,5 @@ export * from './requests'
9export * from './servers' 9export * from './servers'
10export * from './users' 10export * from './users'
11export * from './video-abuses' 11export * from './video-abuses'
12export * from './video-blacklists' 12export * from './video-blacklist'
13export * from './videos' 13export * from './videos'
diff --git a/server/tests/utils/video-blacklist.ts b/server/tests/utils/video-blacklist.ts
new file mode 100644
index 000000000..5729d13d8
--- /dev/null
+++ b/server/tests/utils/video-blacklist.ts
@@ -0,0 +1,54 @@
1import * as request from 'supertest'
2
3function addVideoToBlacklist (url: string, token: string, videoId: number, specialStatus = 204) {
4 const path = '/api/v1/videos/' + videoId + '/blacklist'
5
6 return request(url)
7 .post(path)
8 .set('Accept', 'application/json')
9 .set('Authorization', 'Bearer ' + token)
10 .expect(specialStatus)
11}
12
13function removeVideoFromBlacklist (url: string, token: string, videoId: number, specialStatus = 204) {
14 const path = '/api/v1/blacklist/' + videoId
15
16 return request(url)
17 .delete(path)
18 .set('Accept', 'application/json')
19 .set('Authorization', 'Bearer ' + token)
20 .expect(specialStatus)
21}
22
23function getBlacklistedVideosList (url: string, token: string, specialStatus = 200) {
24 const path = '/api/v1/blacklist/'
25
26 return request(url)
27 .get(path)
28 .query({ sort: 'createdAt' })
29 .set('Accept', 'application/json')
30 .set('Authorization', 'Bearer ' + token)
31 .expect(specialStatus)
32 .expect('Content-Type', /json/)
33}
34
35function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) {
36 const path = '/api/v1/blacklist/'
37
38 return request(url)
39 .get(path)
40 .query({ sort: sort })
41 .set('Accept', 'application/json')
42 .set('Authorization', 'Bearer ' + token)
43 .expect(specialStatus)
44 .expect('Content-Type', /json/)
45}
46
47// ---------------------------------------------------------------------------
48
49export {
50 addVideoToBlacklist,
51 removeVideoFromBlacklist,
52 getBlacklistedVideosList,
53 getSortedBlacklistedVideosList
54}
diff --git a/server/tests/utils/video-blacklists.ts b/server/tests/utils/video-blacklists.ts
deleted file mode 100644
index 6812d3ad4..000000000
--- a/server/tests/utils/video-blacklists.ts
+++ /dev/null
@@ -1,17 +0,0 @@
1import * as request from 'supertest'
2
3function addVideoToBlacklist (url: string, token: string, videoId: number, specialStatus = 204) {
4 const path = '/api/v1/videos/' + videoId + '/blacklist'
5
6 return request(url)
7 .post(path)
8 .set('Accept', 'application/json')
9 .set('Authorization', 'Bearer ' + token)
10 .expect(specialStatus)
11}
12
13// ---------------------------------------------------------------------------
14
15export {
16 addVideoToBlacklist
17}