aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-26 10:55:40 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-03-18 11:17:59 +0100
commit418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 (patch)
tree5e9bc5604fd5d66a006cfebb7acdbdd5486e5d1e /server/tests/api
parentb427febb4d5cebf03b815bca2c59af6e82491569 (diff)
downloadPeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.tar.gz
PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.tar.zst
PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.zip
Playlist server API
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/video-playlists.ts117
-rw-r--r--server/tests/api/videos/video-playlists.ts161
2 files changed, 278 insertions, 0 deletions
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
new file mode 100644
index 000000000..7004badac
--- /dev/null
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -0,0 +1,117 @@
1/* tslint:disable:no-unused-expression */
2
3import { omit } from 'lodash'
4import 'mocha'
5import { join } from 'path'
6import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
7import {
8 createUser,
9 flushTests,
10 getMyUserInformation,
11 immutableAssign,
12 killallServers,
13 makeGetRequest,
14 makePostBodyRequest,
15 makeUploadRequest,
16 runServer,
17 ServerInfo,
18 setAccessTokensToServers,
19 updateCustomSubConfig,
20 userLogin
21} from '../../../../shared/utils'
22import {
23 checkBadCountPagination,
24 checkBadSortPagination,
25 checkBadStartPagination
26} from '../../../../shared/utils/requests/check-api-params'
27import { getMagnetURI, getYoutubeVideoUrl } from '../../../../shared/utils/videos/video-imports'
28
29describe('Test video playlists API validator', function () {
30 const path = '/api/v1/videos/video-playlists'
31 let server: ServerInfo
32 let userAccessToken = ''
33
34 // ---------------------------------------------------------------
35
36 before(async function () {
37 this.timeout(30000)
38
39 await flushTests()
40
41 server = await runServer(1)
42
43 await setAccessTokensToServers([ server ])
44
45 const username = 'user1'
46 const password = 'my super password'
47 await createUser(server.url, server.accessToken, username, password)
48 userAccessToken = await userLogin(server, { username, password })
49 })
50
51 describe('When listing video playlists', function () {
52 const globalPath = '/api/v1/video-playlists'
53 const accountPath = '/api/v1/accounts/root/video-playlists'
54 const videoChannelPath = '/api/v1/video-channels/root_channel/video-playlists'
55
56 it('Should fail with a bad start pagination', async function () {
57 await checkBadStartPagination(server.url, globalPath, server.accessToken)
58 await checkBadStartPagination(server.url, accountPath, server.accessToken)
59 await checkBadStartPagination(server.url, videoChannelPath, server.accessToken)
60 })
61
62 it('Should fail with a bad count pagination', async function () {
63 await checkBadCountPagination(server.url, globalPath, server.accessToken)
64 await checkBadCountPagination(server.url, accountPath, server.accessToken)
65 await checkBadCountPagination(server.url, videoChannelPath, server.accessToken)
66 })
67
68 it('Should fail with an incorrect sort', async function () {
69 await checkBadSortPagination(server.url, globalPath, server.accessToken)
70 await checkBadSortPagination(server.url, accountPath, server.accessToken)
71 await checkBadSortPagination(server.url, videoChannelPath, server.accessToken)
72 })
73
74 it('Should fail with a bad account parameter', async function () {
75 const accountPath = '/api/v1/accounts/root2/video-playlists'
76
77 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 404, token: server.accessToken })
78 })
79
80 it('Should fail with a bad video channel parameter', async function () {
81 const accountPath = '/api/v1/video-channels/bad_channel/video-playlists'
82
83 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 404, token: server.accessToken })
84 })
85
86 it('Should success with the correct parameters', async function () {
87 await makeGetRequest({ url: server.url, path: globalPath, statusCodeExpected: 200, token: server.accessToken })
88 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: 200, token: server.accessToken })
89 await makeGetRequest({ url: server.url, path: videoChannelPath, statusCodeExpected: 200, token: server.accessToken })
90 })
91 })
92
93 describe('When listing videos of a playlist', async function () {
94 const path = '/api/v1/video-playlists'
95
96 it('Should fail with a bad start pagination', async function () {
97 await checkBadStartPagination(server.url, path, server.accessToken)
98 })
99
100 it('Should fail with a bad count pagination', async function () {
101 await checkBadCountPagination(server.url, path, server.accessToken)
102 })
103
104 it('Should fail with an incorrect sort', async function () {
105 await checkBadSortPagination(server.url, path, server.accessToken)
106 })
107 })
108
109 after(async function () {
110 killallServers([ server ])
111
112 // Keep the logs if the test failed
113 if (this['ok']) {
114 await flushTests()
115 }
116 })
117})
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
new file mode 100644
index 000000000..cb23239da
--- /dev/null
+++ b/server/tests/api/videos/video-playlists.ts
@@ -0,0 +1,161 @@
1/* tslint:disable:no-unused-expression */
2
3import * as chai from 'chai'
4import 'mocha'
5import { join } from 'path'
6import * as request from 'supertest'
7import { VideoPrivacy } from '../../../../shared/models/videos'
8import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
9import {
10 addVideoChannel,
11 checkTmpIsEmpty,
12 checkVideoFilesWereRemoved,
13 completeVideoCheck,
14 createUser,
15 dateIsValid,
16 doubleFollow,
17 flushAndRunMultipleServers,
18 flushTests,
19 getLocalVideos,
20 getVideo,
21 getVideoChannelsList,
22 getVideosList,
23 killallServers,
24 rateVideo,
25 removeVideo,
26 ServerInfo,
27 setAccessTokensToServers,
28 testImage,
29 updateVideo,
30 uploadVideo,
31 userLogin,
32 viewVideo,
33 wait,
34 webtorrentAdd
35} from '../../../../shared/utils'
36import {
37 addVideoCommentReply,
38 addVideoCommentThread,
39 deleteVideoComment,
40 getVideoCommentThreads,
41 getVideoThreadComments
42} from '../../../../shared/utils/videos/video-comments'
43import { waitJobs } from '../../../../shared/utils/server/jobs'
44
45const expect = chai.expect
46
47describe('Test video playlists', function () {
48 let servers: ServerInfo[] = []
49
50 before(async function () {
51 this.timeout(120000)
52
53 servers = await flushAndRunMultipleServers(3)
54
55 // Get the access tokens
56 await setAccessTokensToServers(servers)
57
58 // Server 1 and server 2 follow each other
59 await doubleFollow(servers[0], servers[1])
60 // Server 1 and server 3 follow each other
61 await doubleFollow(servers[0], servers[2])
62 })
63
64 it('Should create a playlist on server 1 and have the playlist on server 2 and 3', async function () {
65
66 })
67
68 it('Should create a playlist on server 2 and have the playlist on server 1 but not on server 3', async function () {
69 // create 2 playlists (with videos and no videos)
70 // With thumbnail and no thumbnail
71 })
72
73 it('Should have the playlist on server 3 after a new follow', async function () {
74 // Server 2 and server 3 follow each other
75 await doubleFollow(servers[1], servers[2])
76 })
77
78 it('Should create some playlists and list them correctly', async function () {
79 // create 3 playlists with some videos in it
80 // check pagination
81 // check sort
82 // check empty
83 })
84
85 it('Should list video channel playlists', async function () {
86 // check pagination
87 // check sort
88 // check empty
89 })
90
91 it('Should list account playlists', async function () {
92 // check pagination
93 // check sort
94 // check empty
95 })
96
97 it('Should get a playlist', async function () {
98 // get empty playlist
99 // get non empty playlist
100 })
101
102 it('Should update a playlist', async function () {
103 // update thumbnail
104
105 // update other details
106 })
107
108 it('Should create a playlist containing different startTimestamp/endTimestamp videos', async function () {
109
110 })
111
112 it('Should correctly list playlist videos', async function () {
113 // empty
114 // some filters?
115 })
116
117 it('Should reorder the playlist', async function () {
118 // reorder 1 element
119 // reorder 3 elements
120 // reorder at the beginning
121 // reorder at the end
122 // reorder before/after
123 })
124
125 it('Should update startTimestamp/endTimestamp of some elements', async function () {
126
127 })
128
129 it('Should delete some elements', async function () {
130
131 })
132
133 it('Should delete the playlist on server 1 and delete on server 2 and 3', async function () {
134
135 })
136
137 it('Should have deleted the thumbnail on server 1, 2 and 3', async function () {
138
139 })
140
141 it('Should unfollow servers 1 and 2 and hide their playlists', async function () {
142
143 })
144
145 it('Should delete a channel and remove the associated playlist', async function () {
146
147 })
148
149 it('Should delete an account and delete its playlists', async function () {
150
151 })
152
153 after(async function () {
154 killallServers(servers)
155
156 // Keep the logs if the test failed
157 if (this['ok']) {
158 await flushTests()
159 }
160 })
161})