]>
Commit | Line | Data |
---|---|---|
0e1dc3e7 C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import { keyBy } from 'lodash' | |
4 | import { join } from 'path' | |
5 | import 'mocha' | |
6 | import * as chai from 'chai' | |
7 | const expect = chai.expect | |
8 | ||
9 | import { | |
10 | ServerInfo, | |
11 | flushTests, | |
12 | runServer, | |
13 | uploadVideo, | |
14 | getVideosList, | |
15 | rateVideo, | |
16 | removeVideo, | |
17 | wait, | |
18 | setAccessTokensToServers, | |
19 | searchVideo, | |
20 | killallServers, | |
21 | dateIsValid, | |
22 | getVideoCategories, | |
23 | getVideoLicences, | |
24 | getVideoLanguages, | |
25 | testVideoImage, | |
26 | webtorrentAdd, | |
27 | getVideo, | |
28 | readdirPromise, | |
29 | getVideosListPagination, | |
30 | searchVideoWithPagination, | |
31 | getVideosListSort, | |
32 | searchVideoWithSort, | |
33 | updateVideo | |
34 | } from '../utils' | |
35 | ||
36 | describe('Test a single pod', function () { | |
37 | let server: ServerInfo = null | |
38 | let videoId = -1 | |
39 | let videoUUID = '' | |
40 | let videosListBase: any[] = null | |
41 | ||
42 | before(async function () { | |
43 | this.timeout(120000) | |
44 | ||
45 | await flushTests() | |
46 | ||
47 | server = await runServer(1) | |
48 | ||
49 | await setAccessTokensToServers([ server ]) | |
50 | }) | |
51 | ||
52 | it('Should list video categories', async function () { | |
53 | const res = await getVideoCategories(server.url) | |
54 | ||
55 | const categories = res.body | |
56 | expect(Object.keys(categories)).to.have.length.above(10) | |
57 | ||
58 | expect(categories[11]).to.equal('News') | |
59 | }) | |
60 | ||
61 | it('Should list video licences', async function () { | |
62 | const res = await getVideoLicences(server.url) | |
63 | ||
64 | const licences = res.body | |
65 | expect(Object.keys(licences)).to.have.length.above(5) | |
66 | ||
67 | expect(licences[3]).to.equal('Attribution - No Derivatives') | |
68 | }) | |
69 | ||
70 | it('Should list video languages', async function () { | |
71 | const res = await getVideoLanguages(server.url) | |
72 | ||
73 | const languages = res.body | |
74 | expect(Object.keys(languages)).to.have.length.above(5) | |
75 | ||
76 | expect(languages[3]).to.equal('Mandarin') | |
77 | }) | |
78 | ||
79 | it('Should not have videos', async function () { | |
80 | const res = await getVideosList(server.url) | |
81 | ||
82 | expect(res.body.total).to.equal(0) | |
83 | expect(res.body.data).to.be.an('array') | |
84 | expect(res.body.data.length).to.equal(0) | |
85 | }) | |
86 | ||
87 | it('Should upload the video', async function () { | |
88 | const videoAttributes = { | |
89 | name: 'my super name', | |
90 | category: 2, | |
91 | nsfw: true, | |
92 | licence: 6, | |
93 | tags: [ 'tag1', 'tag2', 'tag3' ] | |
94 | } | |
95 | await uploadVideo(server.url, server.accessToken, videoAttributes) | |
96 | }) | |
97 | ||
98 | it('Should seed the uploaded video', async function () { | |
99 | // Yes, this could be long | |
100 | this.timeout(60000) | |
101 | ||
102 | const res = await getVideosList(server.url) | |
103 | ||
104 | expect(res.body.total).to.equal(1) | |
105 | expect(res.body.data).to.be.an('array') | |
106 | expect(res.body.data.length).to.equal(1) | |
107 | ||
108 | const video = res.body.data[0] | |
109 | expect(video.name).to.equal('my super name') | |
110 | expect(video.category).to.equal(2) | |
111 | expect(video.categoryLabel).to.equal('Films') | |
112 | expect(video.licence).to.equal(6) | |
113 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | |
114 | expect(video.language).to.equal(3) | |
115 | expect(video.languageLabel).to.equal('Mandarin') | |
116 | expect(video.nsfw).to.be.ok | |
117 | expect(video.description).to.equal('my super description') | |
118 | expect(video.podHost).to.equal('localhost:9001') | |
119 | expect(video.author).to.equal('root') | |
120 | expect(video.isLocal).to.be.true | |
121 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | |
122 | expect(dateIsValid(video.createdAt)).to.be.true | |
123 | expect(dateIsValid(video.updatedAt)).to.be.true | |
124 | ||
5f04dd2f C |
125 | const res2 = await getVideo(server.url, res.body.data[0].id) |
126 | const videoDetails = res2.body | |
0e1dc3e7 | 127 | |
5f04dd2f C |
128 | expect(videoDetails.files).to.have.lengthOf(1) |
129 | ||
130 | const file = videoDetails.files[0] | |
0e1dc3e7 C |
131 | const magnetUri = file.magnetUri |
132 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
5f04dd2f C |
133 | expect(file.torrentUrl).to.equal(`${server.url}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`) |
134 | expect(file.fileUrl).to.equal(`${server.url}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`) | |
14d3270f C |
135 | expect(file.resolution).to.equal(720) |
136 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
137 | expect(file.size).to.equal(218910) |
138 | ||
5f04dd2f | 139 | const test = await testVideoImage(server.url, 'video_short.webm', videoDetails.thumbnailPath) |
0e1dc3e7 C |
140 | expect(test).to.equal(true) |
141 | ||
5f04dd2f C |
142 | videoId = videoDetails.id |
143 | videoUUID = videoDetails.uuid | |
0e1dc3e7 C |
144 | |
145 | const torrent = await webtorrentAdd(magnetUri) | |
146 | expect(torrent.files).to.be.an('array') | |
147 | expect(torrent.files.length).to.equal(1) | |
148 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
149 | }) | |
150 | ||
151 | it('Should get the video', async function () { | |
152 | // Yes, this could be long | |
153 | this.timeout(60000) | |
154 | ||
155 | const res = await getVideo(server.url, videoId) | |
156 | ||
157 | const video = res.body | |
158 | expect(video.name).to.equal('my super name') | |
159 | expect(video.category).to.equal(2) | |
160 | expect(video.categoryLabel).to.equal('Films') | |
161 | expect(video.licence).to.equal(6) | |
162 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | |
163 | expect(video.language).to.equal(3) | |
164 | expect(video.languageLabel).to.equal('Mandarin') | |
165 | expect(video.nsfw).to.be.ok | |
166 | expect(video.description).to.equal('my super description') | |
167 | expect(video.podHost).to.equal('localhost:9001') | |
168 | expect(video.author).to.equal('root') | |
169 | expect(video.isLocal).to.be.true | |
170 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | |
171 | expect(dateIsValid(video.createdAt)).to.be.true | |
172 | expect(dateIsValid(video.updatedAt)).to.be.true | |
5f04dd2f C |
173 | expect(video.channel.name).to.equal('Default root channel') |
174 | expect(video.channel.isLocal).to.be.true | |
175 | expect(dateIsValid(video.channel.createdAt)).to.be.true | |
176 | expect(dateIsValid(video.channel.updatedAt)).to.be.true | |
0e1dc3e7 C |
177 | |
178 | expect(video.files).to.have.lengthOf(1) | |
179 | ||
180 | const file = video.files[0] | |
181 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
182 | expect(file.resolution).to.equal(720) |
183 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
184 | expect(file.size).to.equal(218910) |
185 | ||
186 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | |
187 | expect(test).to.equal(true) | |
188 | ||
189 | // Wait the async views increment | |
190 | await wait(500) | |
191 | }) | |
192 | ||
193 | it('Should get the video by UUID', async function () { | |
194 | // Yes, this could be long | |
195 | this.timeout(60000) | |
196 | ||
197 | const res = await getVideo(server.url, videoUUID) | |
198 | ||
199 | const video = res.body | |
200 | expect(video.name).to.equal('my super name') | |
201 | ||
202 | // Wait the async views increment | |
203 | await wait(500) | |
204 | }) | |
205 | ||
206 | it('Should have the views updated', async function () { | |
207 | const res = await getVideo(server.url, videoId) | |
208 | ||
209 | const video = res.body | |
5f04dd2f | 210 | expect(video.views).to.equal(3) |
0e1dc3e7 C |
211 | }) |
212 | ||
213 | it('Should search the video by name by default', async function () { | |
214 | const res = await searchVideo(server.url, 'my') | |
215 | ||
216 | expect(res.body.total).to.equal(1) | |
217 | expect(res.body.data).to.be.an('array') | |
218 | expect(res.body.data.length).to.equal(1) | |
219 | ||
220 | const video = res.body.data[0] | |
221 | expect(video.name).to.equal('my super name') | |
222 | expect(video.category).to.equal(2) | |
223 | expect(video.categoryLabel).to.equal('Films') | |
224 | expect(video.licence).to.equal(6) | |
225 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | |
226 | expect(video.language).to.equal(3) | |
227 | expect(video.languageLabel).to.equal('Mandarin') | |
228 | expect(video.nsfw).to.be.ok | |
229 | expect(video.description).to.equal('my super description') | |
230 | expect(video.podHost).to.equal('localhost:9001') | |
231 | expect(video.author).to.equal('root') | |
232 | expect(video.isLocal).to.be.true | |
233 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | |
234 | expect(dateIsValid(video.createdAt)).to.be.true | |
235 | expect(dateIsValid(video.updatedAt)).to.be.true | |
236 | ||
0e1dc3e7 C |
237 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) |
238 | expect(test).to.equal(true) | |
239 | }) | |
240 | ||
241 | // Not implemented yet | |
242 | // it('Should search the video by podHost', async function () { | |
243 | // const res = await videosUtils.searchVideo(server.url, '9001', 'host') | |
244 | ||
245 | // expect(res.body.total).to.equal(1) | |
246 | // expect(res.body.data).to.be.an('array') | |
247 | // expect(res.body.data.length).to.equal(1) | |
248 | ||
249 | // const video = res.body.data[0] | |
250 | // expect(video.name).to.equal('my super name') | |
251 | // expect(video.description).to.equal('my super description') | |
252 | // expect(video.podHost).to.equal('localhost:9001') | |
253 | // expect(video.author).to.equal('root') | |
254 | // expect(video.isLocal).to.be.true | |
255 | // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | |
256 | // expect(dateIsValid(video.createdAt)).to.be.true | |
257 | // expect(dateIsValid(video.updatedAt)).to.be.true | |
258 | ||
259 | // const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) | |
260 | // expect(test).to.equal(true) | |
261 | ||
262 | // done() | |
263 | // }) | |
264 | // }) | |
265 | // }) | |
266 | ||
267 | it('Should search the video by tag', async function () { | |
268 | const res = await searchVideo(server.url, 'tag1', 'tags') | |
269 | ||
270 | expect(res.body.total).to.equal(1) | |
271 | expect(res.body.data).to.be.an('array') | |
272 | expect(res.body.data.length).to.equal(1) | |
273 | ||
274 | const video = res.body.data[0] | |
275 | expect(video.name).to.equal('my super name') | |
276 | expect(video.category).to.equal(2) | |
277 | expect(video.categoryLabel).to.equal('Films') | |
278 | expect(video.licence).to.equal(6) | |
279 | expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives') | |
280 | expect(video.language).to.equal(3) | |
281 | expect(video.languageLabel).to.equal('Mandarin') | |
282 | expect(video.nsfw).to.be.ok | |
283 | expect(video.description).to.equal('my super description') | |
284 | expect(video.podHost).to.equal('localhost:9001') | |
285 | expect(video.author).to.equal('root') | |
286 | expect(video.isLocal).to.be.true | |
287 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | |
288 | expect(dateIsValid(video.createdAt)).to.be.true | |
289 | expect(dateIsValid(video.updatedAt)).to.be.true | |
290 | ||
0e1dc3e7 C |
291 | const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath) |
292 | expect(test).to.equal(true) | |
293 | }) | |
294 | ||
295 | it('Should not find a search by name by default', async function () { | |
296 | const res = await searchVideo(server.url, 'hello') | |
297 | ||
298 | expect(res.body.total).to.equal(0) | |
299 | expect(res.body.data).to.be.an('array') | |
300 | expect(res.body.data.length).to.equal(0) | |
301 | }) | |
302 | ||
303 | it('Should not find a search by author', async function () { | |
304 | const res = await searchVideo(server.url, 'hello', 'author') | |
305 | ||
306 | expect(res.body.total).to.equal(0) | |
307 | expect(res.body.data).to.be.an('array') | |
308 | expect(res.body.data.length).to.equal(0) | |
309 | }) | |
310 | ||
311 | it('Should not find a search by tag', async function () { | |
312 | const res = await searchVideo(server.url, 'hello', 'tags') | |
313 | ||
314 | expect(res.body.total).to.equal(0) | |
315 | expect(res.body.data).to.be.an('array') | |
316 | expect(res.body.data.length).to.equal(0) | |
317 | }) | |
318 | ||
319 | it('Should remove the video', async function () { | |
320 | await removeVideo(server.url, server.accessToken, videoId) | |
321 | ||
322 | const files1 = await readdirPromise(join(__dirname, '..', '..', '..', 'test1/videos/')) | |
323 | expect(files1).to.have.lengthOf(0) | |
324 | ||
325 | const files2 = await readdirPromise(join(__dirname, '..', '..', '..', 'test1/thumbnails/')) | |
326 | expect(files2).to.have.lengthOf(0) | |
327 | }) | |
328 | ||
329 | it('Should not have videos', async function () { | |
330 | const res = await getVideosList(server.url) | |
331 | ||
332 | expect(res.body.total).to.equal(0) | |
333 | expect(res.body.data).to.be.an('array') | |
334 | expect(res.body.data).to.have.lengthOf(0) | |
335 | }) | |
336 | ||
337 | it('Should upload 6 videos', async function () { | |
338 | this.timeout(25000) | |
339 | ||
340 | const videos = [ | |
341 | 'video_short.mp4', 'video_short.ogv', 'video_short.webm', | |
342 | 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' | |
343 | ] | |
344 | ||
345 | const tasks: Promise<any>[] = [] | |
346 | for (const video of videos) { | |
347 | const videoAttributes = { | |
348 | name: video + ' name', | |
349 | description: video + ' description', | |
350 | category: 2, | |
351 | licence: 1, | |
352 | language: 1, | |
353 | nsfw: true, | |
354 | tags: [ 'tag1', 'tag2', 'tag3' ], | |
355 | fixture: video | |
356 | } | |
357 | ||
358 | const p = uploadVideo(server.url, server.accessToken, videoAttributes) | |
359 | tasks.push(p) | |
360 | } | |
361 | ||
362 | await Promise.all(tasks) | |
363 | }) | |
364 | ||
365 | it('Should have the correct durations', async function () { | |
366 | const res = await getVideosList(server.url) | |
367 | ||
368 | expect(res.body.total).to.equal(6) | |
369 | const videos = res.body.data | |
370 | expect(videos).to.be.an('array') | |
371 | expect(videos).to.have.lengthOf(6) | |
372 | ||
373 | const videosByName = keyBy<{ duration: number }>(videos, 'name') | |
374 | expect(videosByName['video_short.mp4 name'].duration).to.equal(5) | |
375 | expect(videosByName['video_short.ogv name'].duration).to.equal(5) | |
376 | expect(videosByName['video_short.webm name'].duration).to.equal(5) | |
377 | expect(videosByName['video_short1.webm name'].duration).to.equal(10) | |
378 | expect(videosByName['video_short2.webm name'].duration).to.equal(5) | |
379 | expect(videosByName['video_short3.webm name'].duration).to.equal(5) | |
380 | }) | |
381 | ||
382 | it('Should have the correct thumbnails', async function () { | |
383 | const res = await getVideosList(server.url) | |
384 | ||
385 | const videos = res.body.data | |
386 | // For the next test | |
387 | videosListBase = videos | |
388 | ||
389 | for (const video of videos) { | |
390 | const videoName = video.name.replace(' name', '') | |
391 | const test = await testVideoImage(server.url, videoName, video.thumbnailPath) | |
392 | ||
393 | expect(test).to.equal(true) | |
394 | } | |
395 | }) | |
396 | ||
397 | it('Should list only the two first videos', async function () { | |
398 | const res = await getVideosListPagination(server.url, 0, 2, 'name') | |
399 | ||
400 | const videos = res.body.data | |
401 | expect(res.body.total).to.equal(6) | |
402 | expect(videos.length).to.equal(2) | |
403 | expect(videos[0].name).to.equal(videosListBase[0].name) | |
404 | expect(videos[1].name).to.equal(videosListBase[1].name) | |
405 | }) | |
406 | ||
407 | it('Should list only the next three videos', async function () { | |
408 | const res = await getVideosListPagination(server.url, 2, 3, 'name') | |
409 | ||
410 | const videos = res.body.data | |
411 | expect(res.body.total).to.equal(6) | |
412 | expect(videos.length).to.equal(3) | |
413 | expect(videos[0].name).to.equal(videosListBase[2].name) | |
414 | expect(videos[1].name).to.equal(videosListBase[3].name) | |
415 | expect(videos[2].name).to.equal(videosListBase[4].name) | |
416 | }) | |
417 | ||
418 | it('Should list the last video', async function () { | |
419 | const res = await getVideosListPagination(server.url, 5, 6, 'name') | |
420 | ||
421 | const videos = res.body.data | |
422 | expect(res.body.total).to.equal(6) | |
423 | expect(videos.length).to.equal(1) | |
424 | expect(videos[0].name).to.equal(videosListBase[5].name) | |
425 | }) | |
426 | ||
427 | it('Should search the first video', async function () { | |
428 | const res = await searchVideoWithPagination(server.url, 'webm', 'name', 0, 1, 'name') | |
429 | ||
430 | const videos = res.body.data | |
431 | expect(res.body.total).to.equal(4) | |
432 | expect(videos.length).to.equal(1) | |
433 | expect(videos[0].name).to.equal('video_short1.webm name') | |
434 | }) | |
435 | ||
436 | it('Should search the last two videos', async function () { | |
437 | const res = await searchVideoWithPagination(server.url, 'webm', 'name', 2, 2, 'name') | |
438 | ||
439 | const videos = res.body.data | |
440 | expect(res.body.total).to.equal(4) | |
441 | expect(videos.length).to.equal(2) | |
442 | expect(videos[0].name).to.equal('video_short3.webm name') | |
443 | expect(videos[1].name).to.equal('video_short.webm name') | |
444 | }) | |
445 | ||
446 | it('Should search all the webm videos', async function () { | |
447 | const res = await searchVideoWithPagination(server.url, 'webm', 'name', 0, 15) | |
448 | ||
449 | const videos = res.body.data | |
450 | expect(res.body.total).to.equal(4) | |
451 | expect(videos.length).to.equal(4) | |
452 | }) | |
453 | ||
454 | it('Should search all the root author videos', async function () { | |
455 | const res = await searchVideoWithPagination(server.url, 'root', 'author', 0, 15) | |
456 | ||
457 | const videos = res.body.data | |
458 | expect(res.body.total).to.equal(6) | |
459 | expect(videos.length).to.equal(6) | |
460 | }) | |
461 | ||
462 | // Not implemented yet | |
463 | // it('Should search all the 9001 port videos', async function () { | |
464 | // const res = await videosUtils.searchVideoWithPagination(server.url, '9001', 'host', 0, 15) | |
465 | ||
466 | // const videos = res.body.data | |
467 | // expect(res.body.total).to.equal(6) | |
468 | // expect(videos.length).to.equal(6) | |
469 | ||
470 | // done() | |
471 | // }) | |
472 | // }) | |
473 | ||
474 | // it('Should search all the localhost videos', async function () { | |
475 | // const res = await videosUtils.searchVideoWithPagination(server.url, 'localhost', 'host', 0, 15) | |
476 | ||
477 | // const videos = res.body.data | |
478 | // expect(res.body.total).to.equal(6) | |
479 | // expect(videos.length).to.equal(6) | |
480 | ||
481 | // done() | |
482 | // }) | |
483 | // }) | |
484 | ||
485 | it('Should search the right magnetUri video', async function () { | |
486 | const video = videosListBase[0] | |
5f04dd2f C |
487 | const res = await getVideo(server.url, video.id) |
488 | const videoDetails = res.body | |
0e1dc3e7 | 489 | |
5f04dd2f C |
490 | const res2 = await searchVideoWithPagination(server.url, encodeURIComponent(videoDetails.files[0].magnetUri), 'magnetUri', 0, 15) |
491 | ||
492 | const videos = res2.body.data | |
493 | expect(res2.body.total).to.equal(1) | |
0e1dc3e7 C |
494 | expect(videos.length).to.equal(1) |
495 | expect(videos[0].name).to.equal(video.name) | |
496 | }) | |
497 | ||
498 | it('Should list and sort by name in descending order', async function () { | |
499 | const res = await getVideosListSort(server.url, '-name') | |
500 | ||
501 | const videos = res.body.data | |
502 | expect(res.body.total).to.equal(6) | |
503 | expect(videos.length).to.equal(6) | |
504 | expect(videos[0].name).to.equal('video_short.webm name') | |
505 | expect(videos[1].name).to.equal('video_short.ogv name') | |
506 | expect(videos[2].name).to.equal('video_short.mp4 name') | |
507 | expect(videos[3].name).to.equal('video_short3.webm name') | |
508 | expect(videos[4].name).to.equal('video_short2.webm name') | |
509 | expect(videos[5].name).to.equal('video_short1.webm name') | |
510 | }) | |
511 | ||
512 | it('Should search and sort by name in ascending order', async function () { | |
513 | const res = await searchVideoWithSort(server.url, 'webm', 'name') | |
514 | ||
515 | const videos = res.body.data | |
516 | expect(res.body.total).to.equal(4) | |
517 | expect(videos.length).to.equal(4) | |
518 | ||
519 | expect(videos[0].name).to.equal('video_short1.webm name') | |
520 | expect(videos[1].name).to.equal('video_short2.webm name') | |
521 | expect(videos[2].name).to.equal('video_short3.webm name') | |
522 | expect(videos[3].name).to.equal('video_short.webm name') | |
523 | ||
524 | videoId = videos[2].id | |
525 | }) | |
526 | ||
527 | it('Should update a video', async function () { | |
528 | const attributes = { | |
529 | name: 'my super video updated', | |
530 | category: 4, | |
531 | licence: 2, | |
532 | language: 5, | |
533 | nsfw: false, | |
534 | description: 'my super description updated', | |
535 | tags: [ 'tagup1', 'tagup2' ] | |
536 | } | |
537 | await updateVideo(server.url, server.accessToken, videoId, attributes) | |
538 | }) | |
539 | ||
540 | it('Should have the video updated', async function () { | |
541 | this.timeout(60000) | |
542 | ||
543 | const res = await getVideo(server.url, videoId) | |
544 | ||
545 | const video = res.body | |
546 | ||
547 | expect(video.name).to.equal('my super video updated') | |
548 | expect(video.category).to.equal(4) | |
549 | expect(video.categoryLabel).to.equal('Art') | |
550 | expect(video.licence).to.equal(2) | |
551 | expect(video.licenceLabel).to.equal('Attribution - Share Alike') | |
552 | expect(video.language).to.equal(5) | |
553 | expect(video.languageLabel).to.equal('Arabic') | |
554 | expect(video.nsfw).to.be.ok | |
555 | expect(video.description).to.equal('my super description updated') | |
556 | expect(video.podHost).to.equal('localhost:9001') | |
557 | expect(video.author).to.equal('root') | |
558 | expect(video.isLocal).to.be.true | |
559 | expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) | |
560 | expect(dateIsValid(video.createdAt)).to.be.true | |
561 | expect(dateIsValid(video.updatedAt)).to.be.true | |
562 | ||
5f04dd2f C |
563 | expect(video.channel.name).to.equal('Default root channel') |
564 | expect(video.channel.isLocal).to.be.true | |
565 | expect(dateIsValid(video.channel.createdAt)).to.be.true | |
566 | expect(dateIsValid(video.channel.updatedAt)).to.be.true | |
567 | ||
0e1dc3e7 C |
568 | expect(video.files).to.have.lengthOf(1) |
569 | ||
570 | const file = video.files[0] | |
571 | const magnetUri = file.magnetUri | |
572 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
573 | expect(file.resolution).to.equal(720) |
574 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
575 | expect(file.size).to.equal(292677) |
576 | ||
577 | const test = await testVideoImage(server.url, 'video_short3.webm', video.thumbnailPath) | |
578 | expect(test).to.equal(true) | |
579 | ||
580 | const torrent = await webtorrentAdd(magnetUri) | |
581 | expect(torrent.files).to.be.an('array') | |
582 | expect(torrent.files.length).to.equal(1) | |
583 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | |
584 | }) | |
585 | ||
586 | it('Should update only the tags of a video', async function () { | |
587 | const attributes = { | |
588 | tags: [ 'tag1', 'tag2', 'supertag' ] | |
589 | } | |
590 | ||
591 | await updateVideo(server.url, server.accessToken, videoId, attributes) | |
592 | ||
593 | const res = await getVideo(server.url, videoId) | |
594 | const video = res.body | |
595 | ||
596 | expect(video.name).to.equal('my super video updated') | |
597 | expect(video.category).to.equal(4) | |
598 | expect(video.categoryLabel).to.equal('Art') | |
599 | expect(video.licence).to.equal(2) | |
600 | expect(video.licenceLabel).to.equal('Attribution - Share Alike') | |
601 | expect(video.language).to.equal(5) | |
602 | expect(video.languageLabel).to.equal('Arabic') | |
603 | expect(video.nsfw).to.be.ok | |
604 | expect(video.description).to.equal('my super description updated') | |
605 | expect(video.podHost).to.equal('localhost:9001') | |
606 | expect(video.author).to.equal('root') | |
607 | expect(video.isLocal).to.be.true | |
608 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) | |
609 | expect(dateIsValid(video.createdAt)).to.be.true | |
610 | expect(dateIsValid(video.updatedAt)).to.be.true | |
611 | ||
5f04dd2f C |
612 | expect(video.channel.name).to.equal('Default root channel') |
613 | expect(video.channel.isLocal).to.be.true | |
614 | expect(dateIsValid(video.channel.createdAt)).to.be.true | |
615 | expect(dateIsValid(video.channel.updatedAt)).to.be.true | |
616 | ||
0e1dc3e7 C |
617 | expect(video.files).to.have.lengthOf(1) |
618 | ||
619 | const file = video.files[0] | |
620 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
621 | expect(file.resolution).to.equal(720) |
622 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
623 | expect(file.size).to.equal(292677) |
624 | }) | |
625 | ||
626 | it('Should update only the description of a video', async function () { | |
627 | const attributes = { | |
628 | description: 'hello everybody' | |
629 | } | |
630 | ||
631 | await updateVideo(server.url, server.accessToken, videoId, attributes) | |
632 | ||
633 | const res = await getVideo(server.url, videoId) | |
634 | const video = res.body | |
635 | ||
636 | expect(video.name).to.equal('my super video updated') | |
637 | expect(video.category).to.equal(4) | |
638 | expect(video.categoryLabel).to.equal('Art') | |
639 | expect(video.licence).to.equal(2) | |
640 | expect(video.licenceLabel).to.equal('Attribution - Share Alike') | |
641 | expect(video.language).to.equal(5) | |
642 | expect(video.languageLabel).to.equal('Arabic') | |
643 | expect(video.nsfw).to.be.ok | |
644 | expect(video.description).to.equal('hello everybody') | |
645 | expect(video.podHost).to.equal('localhost:9001') | |
646 | expect(video.author).to.equal('root') | |
647 | expect(video.isLocal).to.be.true | |
648 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) | |
649 | expect(dateIsValid(video.createdAt)).to.be.true | |
650 | expect(dateIsValid(video.updatedAt)).to.be.true | |
5f04dd2f C |
651 | |
652 | expect(video.channel.name).to.equal('Default root channel') | |
653 | expect(video.channel.isLocal).to.be.true | |
654 | expect(dateIsValid(video.channel.createdAt)).to.be.true | |
655 | expect(dateIsValid(video.channel.updatedAt)).to.be.true | |
0e1dc3e7 C |
656 | |
657 | expect(video.files).to.have.lengthOf(1) | |
658 | ||
659 | const file = video.files[0] | |
660 | expect(file.magnetUri).to.have.lengthOf.above(2) | |
14d3270f C |
661 | expect(file.resolution).to.equal(720) |
662 | expect(file.resolutionLabel).to.equal('720p') | |
0e1dc3e7 C |
663 | expect(file.size).to.equal(292677) |
664 | }) | |
665 | ||
666 | it('Should like a video', async function () { | |
667 | await rateVideo(server.url, server.accessToken, videoId, 'like') | |
668 | ||
669 | const res = await getVideo(server.url, videoId) | |
670 | const video = res.body | |
671 | ||
672 | expect(video.likes).to.equal(1) | |
673 | expect(video.dislikes).to.equal(0) | |
674 | }) | |
675 | ||
676 | it('Should dislike the same video', async function () { | |
677 | await rateVideo(server.url, server.accessToken, videoId, 'dislike') | |
678 | ||
679 | const res = await getVideo(server.url, videoId) | |
680 | const video = res.body | |
681 | ||
682 | expect(video.likes).to.equal(0) | |
683 | expect(video.dislikes).to.equal(1) | |
684 | }) | |
685 | ||
686 | after(async function () { | |
687 | killallServers([ server ]) | |
688 | ||
689 | // Keep the logs if the test failed | |
690 | if (this['ok']) { | |
691 | await flushTests() | |
692 | } | |
693 | }) | |
694 | }) |