diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-01 16:54:24 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-01 16:54:24 +0200 |
commit | 65af03a241aa83ab7ba71278b6c99acd26428b8a (patch) | |
tree | 0cc04c31cdf631d11a915ae40389e8fa141f136b /server/tests/api/videos | |
parent | a21e25ff641854c8b01664cb18655aa420620af6 (diff) | |
download | PeerTube-65af03a241aa83ab7ba71278b6c99acd26428b8a.tar.gz PeerTube-65af03a241aa83ab7ba71278b6c99acd26428b8a.tar.zst PeerTube-65af03a241aa83ab7ba71278b6c99acd26428b8a.zip |
Automatically update playlist thumbnails
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/index.ts | 1 | ||||
-rw-r--r-- | server/tests/api/videos/video-playlist-thumbnails.ts | 262 | ||||
-rw-r--r-- | server/tests/api/videos/video-playlists.ts | 1 |
3 files changed, 264 insertions, 0 deletions
diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts index 93e1f3e98..72e6061bb 100644 --- a/server/tests/api/videos/index.ts +++ b/server/tests/api/videos/index.ts | |||
@@ -12,6 +12,7 @@ import './video-hls' | |||
12 | import './video-imports' | 12 | import './video-imports' |
13 | import './video-nsfw' | 13 | import './video-nsfw' |
14 | import './video-playlists' | 14 | import './video-playlists' |
15 | import './video-playlist-thumbnails' | ||
15 | import './video-privacy' | 16 | import './video-privacy' |
16 | import './video-schedule-update' | 17 | import './video-schedule-update' |
17 | import './video-transcoder' | 18 | import './video-transcoder' |
diff --git a/server/tests/api/videos/video-playlist-thumbnails.ts b/server/tests/api/videos/video-playlist-thumbnails.ts new file mode 100644 index 000000000..73ab02c17 --- /dev/null +++ b/server/tests/api/videos/video-playlist-thumbnails.ts | |||
@@ -0,0 +1,262 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | ||
5 | import { | ||
6 | addVideoInPlaylist, | ||
7 | cleanupTests, | ||
8 | createVideoPlaylist, | ||
9 | doubleFollow, | ||
10 | flushAndRunMultipleServers, | ||
11 | getVideoPlaylistsList, removeVideoFromPlaylist, | ||
12 | ServerInfo, | ||
13 | setAccessTokensToServers, | ||
14 | setDefaultVideoChannel, | ||
15 | testImage, | ||
16 | uploadVideoAndGetId, | ||
17 | waitJobs, | ||
18 | reorderVideosPlaylist | ||
19 | } from '../../../../shared/extra-utils' | ||
20 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
21 | |||
22 | const expect = chai.expect | ||
23 | |||
24 | describe('Playlist thumbnail', function () { | ||
25 | let servers: ServerInfo[] = [] | ||
26 | |||
27 | let playlistWithoutThumbnail: number | ||
28 | let playlistWithThumbnail: number | ||
29 | |||
30 | let withThumbnailE1: number | ||
31 | let withThumbnailE2: number | ||
32 | let withoutThumbnailE1: number | ||
33 | let withoutThumbnailE2: number | ||
34 | |||
35 | let video1: number | ||
36 | let video2: number | ||
37 | |||
38 | async function getPlaylistWithoutThumbnail (server: ServerInfo) { | ||
39 | const res = await getVideoPlaylistsList(server.url, 0, 10) | ||
40 | |||
41 | return res.body.data.find(p => p.displayName === 'playlist without thumbnail') | ||
42 | } | ||
43 | |||
44 | async function getPlaylistWithThumbnail (server: ServerInfo) { | ||
45 | const res = await getVideoPlaylistsList(server.url, 0, 10) | ||
46 | |||
47 | return res.body.data.find(p => p.displayName === 'playlist with thumbnail') | ||
48 | } | ||
49 | |||
50 | before(async function () { | ||
51 | this.timeout(120000) | ||
52 | |||
53 | servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: false } }) | ||
54 | |||
55 | // Get the access tokens | ||
56 | await setAccessTokensToServers(servers) | ||
57 | await setDefaultVideoChannel(servers) | ||
58 | |||
59 | // Server 1 and server 2 follow each other | ||
60 | await doubleFollow(servers[0], servers[1]) | ||
61 | |||
62 | video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).id | ||
63 | video2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).id | ||
64 | |||
65 | await waitJobs(servers) | ||
66 | }) | ||
67 | |||
68 | it('Should automatically update the thumbnail when adding an element', async function () { | ||
69 | this.timeout(30000) | ||
70 | |||
71 | const res = await createVideoPlaylist({ | ||
72 | url: servers[ 1 ].url, | ||
73 | token: servers[ 1 ].accessToken, | ||
74 | playlistAttrs: { | ||
75 | displayName: 'playlist without thumbnail', | ||
76 | privacy: VideoPlaylistPrivacy.PUBLIC, | ||
77 | videoChannelId: servers[ 1 ].videoChannel.id | ||
78 | } | ||
79 | }) | ||
80 | playlistWithoutThumbnail = res.body.videoPlaylist.id | ||
81 | |||
82 | const res2 = await addVideoInPlaylist({ | ||
83 | url: servers[ 1 ].url, | ||
84 | token: servers[ 1 ].accessToken, | ||
85 | playlistId: playlistWithoutThumbnail, | ||
86 | elementAttrs: { videoId: video1 } | ||
87 | }) | ||
88 | withoutThumbnailE1 = res2.body.videoPlaylistElement.id | ||
89 | |||
90 | await waitJobs(servers) | ||
91 | |||
92 | for (const server of servers) { | ||
93 | const p = await getPlaylistWithoutThumbnail(server) | ||
94 | await testImage(server.url, 'thumbnail-playlist', p.thumbnailPath) | ||
95 | } | ||
96 | }) | ||
97 | |||
98 | it('Should not update the thumbnail if we explicitly uploaded a thumbnail', async function () { | ||
99 | this.timeout(30000) | ||
100 | |||
101 | const res = await createVideoPlaylist({ | ||
102 | url: servers[ 1 ].url, | ||
103 | token: servers[ 1 ].accessToken, | ||
104 | playlistAttrs: { | ||
105 | displayName: 'playlist with thumbnail', | ||
106 | privacy: VideoPlaylistPrivacy.PUBLIC, | ||
107 | videoChannelId: servers[ 1 ].videoChannel.id, | ||
108 | thumbnailfile: 'thumbnail.jpg' | ||
109 | } | ||
110 | }) | ||
111 | playlistWithThumbnail = res.body.videoPlaylist.id | ||
112 | |||
113 | const res2 = await addVideoInPlaylist({ | ||
114 | url: servers[ 1 ].url, | ||
115 | token: servers[ 1 ].accessToken, | ||
116 | playlistId: playlistWithThumbnail, | ||
117 | elementAttrs: { videoId: video1 } | ||
118 | }) | ||
119 | withThumbnailE1 = res2.body.videoPlaylistElement.id | ||
120 | |||
121 | await waitJobs(servers) | ||
122 | |||
123 | for (const server of servers) { | ||
124 | const p = await getPlaylistWithThumbnail(server) | ||
125 | await testImage(server.url, 'thumbnail', p.thumbnailPath) | ||
126 | } | ||
127 | }) | ||
128 | |||
129 | it('Should automatically update the thumbnail when moving the first element', async function () { | ||
130 | this.timeout(30000) | ||
131 | |||
132 | const res = await addVideoInPlaylist({ | ||
133 | url: servers[ 1 ].url, | ||
134 | token: servers[ 1 ].accessToken, | ||
135 | playlistId: playlistWithoutThumbnail, | ||
136 | elementAttrs: { videoId: video2 } | ||
137 | }) | ||
138 | withoutThumbnailE2 = res.body.videoPlaylistElement.id | ||
139 | |||
140 | await reorderVideosPlaylist({ | ||
141 | url: servers[1].url, | ||
142 | token: servers[1].accessToken, | ||
143 | playlistId: playlistWithoutThumbnail, | ||
144 | elementAttrs: { | ||
145 | startPosition: 1, | ||
146 | insertAfterPosition: 2 | ||
147 | } | ||
148 | }) | ||
149 | |||
150 | await waitJobs(servers) | ||
151 | |||
152 | for (const server of servers) { | ||
153 | const p = await getPlaylistWithoutThumbnail(server) | ||
154 | await testImage(server.url, 'thumbnail-playlist', p.thumbnailPath) | ||
155 | } | ||
156 | }) | ||
157 | |||
158 | it('Should not update the thumbnail when moving the first element if we explicitly uploaded a thumbnail', async function () { | ||
159 | this.timeout(30000) | ||
160 | |||
161 | const res = await addVideoInPlaylist({ | ||
162 | url: servers[ 1 ].url, | ||
163 | token: servers[ 1 ].accessToken, | ||
164 | playlistId: playlistWithThumbnail, | ||
165 | elementAttrs: { videoId: video2 } | ||
166 | }) | ||
167 | withThumbnailE2 = res.body.videoPlaylistElement.id | ||
168 | |||
169 | await reorderVideosPlaylist({ | ||
170 | url: servers[1].url, | ||
171 | token: servers[1].accessToken, | ||
172 | playlistId: playlistWithThumbnail, | ||
173 | elementAttrs: { | ||
174 | startPosition: 1, | ||
175 | insertAfterPosition: 2 | ||
176 | } | ||
177 | }) | ||
178 | |||
179 | await waitJobs(servers) | ||
180 | |||
181 | for (const server of servers) { | ||
182 | const p = await getPlaylistWithThumbnail(server) | ||
183 | await testImage(server.url, 'thumbnail', p.thumbnailPath) | ||
184 | } | ||
185 | }) | ||
186 | |||
187 | it('Should automatically update the thumbnail when deleting the first element', async function () { | ||
188 | this.timeout(30000) | ||
189 | |||
190 | await removeVideoFromPlaylist({ | ||
191 | url: servers[ 1 ].url, | ||
192 | token: servers[ 1 ].accessToken, | ||
193 | playlistId: playlistWithoutThumbnail, | ||
194 | playlistElementId: withoutThumbnailE1 | ||
195 | }) | ||
196 | |||
197 | await waitJobs(servers) | ||
198 | |||
199 | for (const server of servers) { | ||
200 | const p = await getPlaylistWithoutThumbnail(server) | ||
201 | await testImage(server.url, 'thumbnail-playlist', p.thumbnailPath) | ||
202 | } | ||
203 | }) | ||
204 | |||
205 | it('Should not update the thumbnail when deleting the first element if we explicitly uploaded a thumbnail', async function () { | ||
206 | this.timeout(30000) | ||
207 | |||
208 | await removeVideoFromPlaylist({ | ||
209 | url: servers[ 1 ].url, | ||
210 | token: servers[ 1 ].accessToken, | ||
211 | playlistId: playlistWithThumbnail, | ||
212 | playlistElementId: withThumbnailE1 | ||
213 | }) | ||
214 | |||
215 | await waitJobs(servers) | ||
216 | |||
217 | for (const server of servers) { | ||
218 | const p = await getPlaylistWithThumbnail(server) | ||
219 | await testImage(server.url, 'thumbnail', p.thumbnailPath) | ||
220 | } | ||
221 | }) | ||
222 | |||
223 | it('Should the thumbnail when we delete the last element', async function () { | ||
224 | this.timeout(30000) | ||
225 | |||
226 | await removeVideoFromPlaylist({ | ||
227 | url: servers[ 1 ].url, | ||
228 | token: servers[ 1 ].accessToken, | ||
229 | playlistId: playlistWithoutThumbnail, | ||
230 | playlistElementId: withoutThumbnailE2 | ||
231 | }) | ||
232 | |||
233 | await waitJobs(servers) | ||
234 | |||
235 | for (const server of servers) { | ||
236 | const p = await getPlaylistWithoutThumbnail(server) | ||
237 | expect(p.thumbnailPath).to.be.null | ||
238 | } | ||
239 | }) | ||
240 | |||
241 | it('Should not update the thumbnail when we delete the last element if we explicitly uploaded a thumbnail', async function () { | ||
242 | this.timeout(30000) | ||
243 | |||
244 | await removeVideoFromPlaylist({ | ||
245 | url: servers[ 1 ].url, | ||
246 | token: servers[ 1 ].accessToken, | ||
247 | playlistId: playlistWithThumbnail, | ||
248 | playlistElementId: withThumbnailE2 | ||
249 | }) | ||
250 | |||
251 | await waitJobs(servers) | ||
252 | |||
253 | for (const server of servers) { | ||
254 | const p = await getPlaylistWithThumbnail(server) | ||
255 | await testImage(server.url, 'thumbnail', p.thumbnailPath) | ||
256 | } | ||
257 | }) | ||
258 | |||
259 | after(async function () { | ||
260 | await cleanupTests(servers) | ||
261 | }) | ||
262 | }) | ||
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index 7d5e3914b..424b217fb 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts | |||
@@ -344,6 +344,7 @@ describe('Test video playlists', function () { | |||
344 | }) | 344 | }) |
345 | 345 | ||
346 | describe('List playlists', function () { | 346 | describe('List playlists', function () { |
347 | |||
347 | it('Should correctly list the playlists', async function () { | 348 | it('Should correctly list the playlists', async function () { |
348 | this.timeout(30000) | 349 | this.timeout(30000) |
349 | 350 | ||