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