aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/single-pod.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-09-04 21:21:47 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-09-04 21:30:18 +0200
commit0e1dc3e7c69995c691e1dd82e3c2bc68748661ca (patch)
treef2a4b5cffc72e33c902b67083bbaa35b6f22f0ca /server/tests/api/single-pod.ts
parentb0f9f39ed70299a208d1b388c72de8b7f3510cb7 (diff)
downloadPeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.tar.gz
PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.tar.zst
PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.zip
Convert tests to typescript
Diffstat (limited to 'server/tests/api/single-pod.ts')
-rw-r--r--server/tests/api/single-pod.ts683
1 files changed, 683 insertions, 0 deletions
diff --git a/server/tests/api/single-pod.ts b/server/tests/api/single-pod.ts
new file mode 100644
index 000000000..83c981f9b
--- /dev/null
+++ b/server/tests/api/single-pod.ts
@@ -0,0 +1,683 @@
1/* tslint:disable:no-unused-expression */
2
3import { keyBy } from 'lodash'
4import { join } from 'path'
5import 'mocha'
6import * as chai from 'chai'
7const expect = chai.expect
8
9import {
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
36describe('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
125 expect(video.files).to.have.lengthOf(1)
126
127 const file = video.files[0]
128 const magnetUri = file.magnetUri
129 expect(file.magnetUri).to.have.lengthOf.above(2)
130 expect(file.resolution).to.equal(0)
131 expect(file.resolutionLabel).to.equal('original')
132 expect(file.size).to.equal(218910)
133
134 const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath)
135 expect(test).to.equal(true)
136
137 videoId = video.id
138 videoUUID = video.uuid
139
140 const torrent = await webtorrentAdd(magnetUri)
141 expect(torrent.files).to.be.an('array')
142 expect(torrent.files.length).to.equal(1)
143 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
144 })
145
146 it('Should get the video', async function () {
147 // Yes, this could be long
148 this.timeout(60000)
149
150 const res = await getVideo(server.url, videoId)
151
152 const video = res.body
153 expect(video.name).to.equal('my super name')
154 expect(video.category).to.equal(2)
155 expect(video.categoryLabel).to.equal('Films')
156 expect(video.licence).to.equal(6)
157 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
158 expect(video.language).to.equal(3)
159 expect(video.languageLabel).to.equal('Mandarin')
160 expect(video.nsfw).to.be.ok
161 expect(video.description).to.equal('my super description')
162 expect(video.podHost).to.equal('localhost:9001')
163 expect(video.author).to.equal('root')
164 expect(video.isLocal).to.be.true
165 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
166 expect(dateIsValid(video.createdAt)).to.be.true
167 expect(dateIsValid(video.updatedAt)).to.be.true
168
169 expect(video.files).to.have.lengthOf(1)
170
171 const file = video.files[0]
172 expect(file.magnetUri).to.have.lengthOf.above(2)
173 expect(file.resolution).to.equal(0)
174 expect(file.resolutionLabel).to.equal('original')
175 expect(file.size).to.equal(218910)
176
177 const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath)
178 expect(test).to.equal(true)
179
180 // Wait the async views increment
181 await wait(500)
182 })
183
184 it('Should get the video by UUID', async function () {
185 // Yes, this could be long
186 this.timeout(60000)
187
188 const res = await getVideo(server.url, videoUUID)
189
190 const video = res.body
191 expect(video.name).to.equal('my super name')
192
193 // Wait the async views increment
194 await wait(500)
195 })
196
197 it('Should have the views updated', async function () {
198 const res = await getVideo(server.url, videoId)
199
200 const video = res.body
201 expect(video.views).to.equal(2)
202 })
203
204 it('Should search the video by name by default', async function () {
205 const res = await searchVideo(server.url, 'my')
206
207 expect(res.body.total).to.equal(1)
208 expect(res.body.data).to.be.an('array')
209 expect(res.body.data.length).to.equal(1)
210
211 const video = res.body.data[0]
212 expect(video.name).to.equal('my super name')
213 expect(video.category).to.equal(2)
214 expect(video.categoryLabel).to.equal('Films')
215 expect(video.licence).to.equal(6)
216 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
217 expect(video.language).to.equal(3)
218 expect(video.languageLabel).to.equal('Mandarin')
219 expect(video.nsfw).to.be.ok
220 expect(video.description).to.equal('my super description')
221 expect(video.podHost).to.equal('localhost:9001')
222 expect(video.author).to.equal('root')
223 expect(video.isLocal).to.be.true
224 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
225 expect(dateIsValid(video.createdAt)).to.be.true
226 expect(dateIsValid(video.updatedAt)).to.be.true
227
228 expect(video.files).to.have.lengthOf(1)
229
230 const file = video.files[0]
231 expect(file.magnetUri).to.have.lengthOf.above(2)
232 expect(file.resolution).to.equal(0)
233 expect(file.resolutionLabel).to.equal('original')
234 expect(file.size).to.equal(218910)
235
236 const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath)
237 expect(test).to.equal(true)
238 })
239
240 // Not implemented yet
241 // it('Should search the video by podHost', async function () {
242 // const res = await videosUtils.searchVideo(server.url, '9001', 'host')
243
244 // expect(res.body.total).to.equal(1)
245 // expect(res.body.data).to.be.an('array')
246 // expect(res.body.data.length).to.equal(1)
247
248 // const video = res.body.data[0]
249 // expect(video.name).to.equal('my super name')
250 // expect(video.description).to.equal('my super description')
251 // expect(video.podHost).to.equal('localhost:9001')
252 // expect(video.author).to.equal('root')
253 // expect(video.isLocal).to.be.true
254 // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
255 // expect(dateIsValid(video.createdAt)).to.be.true
256 // expect(dateIsValid(video.updatedAt)).to.be.true
257
258 // const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath)
259 // expect(test).to.equal(true)
260
261 // done()
262 // })
263 // })
264 // })
265
266 it('Should search the video by tag', async function () {
267 const res = await searchVideo(server.url, 'tag1', 'tags')
268
269 expect(res.body.total).to.equal(1)
270 expect(res.body.data).to.be.an('array')
271 expect(res.body.data.length).to.equal(1)
272
273 const video = res.body.data[0]
274 expect(video.name).to.equal('my super name')
275 expect(video.category).to.equal(2)
276 expect(video.categoryLabel).to.equal('Films')
277 expect(video.licence).to.equal(6)
278 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
279 expect(video.language).to.equal(3)
280 expect(video.languageLabel).to.equal('Mandarin')
281 expect(video.nsfw).to.be.ok
282 expect(video.description).to.equal('my super description')
283 expect(video.podHost).to.equal('localhost:9001')
284 expect(video.author).to.equal('root')
285 expect(video.isLocal).to.be.true
286 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
287 expect(dateIsValid(video.createdAt)).to.be.true
288 expect(dateIsValid(video.updatedAt)).to.be.true
289
290 expect(video.files).to.have.lengthOf(1)
291
292 const file = video.files[0]
293 expect(file.magnetUri).to.have.lengthOf.above(2)
294 expect(file.resolution).to.equal(0)
295 expect(file.resolutionLabel).to.equal('original')
296 expect(file.size).to.equal(218910)
297
298 const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath)
299 expect(test).to.equal(true)
300 })
301
302 it('Should not find a search by name by default', async function () {
303 const res = await searchVideo(server.url, 'hello')
304
305 expect(res.body.total).to.equal(0)
306 expect(res.body.data).to.be.an('array')
307 expect(res.body.data.length).to.equal(0)
308 })
309
310 it('Should not find a search by author', async function () {
311 const res = await searchVideo(server.url, 'hello', 'author')
312
313 expect(res.body.total).to.equal(0)
314 expect(res.body.data).to.be.an('array')
315 expect(res.body.data.length).to.equal(0)
316 })
317
318 it('Should not find a search by tag', async function () {
319 const res = await searchVideo(server.url, 'hello', 'tags')
320
321 expect(res.body.total).to.equal(0)
322 expect(res.body.data).to.be.an('array')
323 expect(res.body.data.length).to.equal(0)
324 })
325
326 it('Should remove the video', async function () {
327 await removeVideo(server.url, server.accessToken, videoId)
328
329 const files1 = await readdirPromise(join(__dirname, '..', '..', '..', 'test1/videos/'))
330 expect(files1).to.have.lengthOf(0)
331
332 const files2 = await readdirPromise(join(__dirname, '..', '..', '..', 'test1/thumbnails/'))
333 expect(files2).to.have.lengthOf(0)
334 })
335
336 it('Should not have videos', async function () {
337 const res = await getVideosList(server.url)
338
339 expect(res.body.total).to.equal(0)
340 expect(res.body.data).to.be.an('array')
341 expect(res.body.data).to.have.lengthOf(0)
342 })
343
344 it('Should upload 6 videos', async function () {
345 this.timeout(25000)
346
347 const videos = [
348 'video_short.mp4', 'video_short.ogv', 'video_short.webm',
349 'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
350 ]
351
352 const tasks: Promise<any>[] = []
353 for (const video of videos) {
354 const videoAttributes = {
355 name: video + ' name',
356 description: video + ' description',
357 category: 2,
358 licence: 1,
359 language: 1,
360 nsfw: true,
361 tags: [ 'tag1', 'tag2', 'tag3' ],
362 fixture: video
363 }
364
365 const p = uploadVideo(server.url, server.accessToken, videoAttributes)
366 tasks.push(p)
367 }
368
369 await Promise.all(tasks)
370 })
371
372 it('Should have the correct durations', async function () {
373 const res = await getVideosList(server.url)
374
375 expect(res.body.total).to.equal(6)
376 const videos = res.body.data
377 expect(videos).to.be.an('array')
378 expect(videos).to.have.lengthOf(6)
379
380 const videosByName = keyBy<{ duration: number }>(videos, 'name')
381 expect(videosByName['video_short.mp4 name'].duration).to.equal(5)
382 expect(videosByName['video_short.ogv name'].duration).to.equal(5)
383 expect(videosByName['video_short.webm name'].duration).to.equal(5)
384 expect(videosByName['video_short1.webm name'].duration).to.equal(10)
385 expect(videosByName['video_short2.webm name'].duration).to.equal(5)
386 expect(videosByName['video_short3.webm name'].duration).to.equal(5)
387 })
388
389 it('Should have the correct thumbnails', async function () {
390 const res = await getVideosList(server.url)
391
392 const videos = res.body.data
393 // For the next test
394 videosListBase = videos
395
396 for (const video of videos) {
397 const videoName = video.name.replace(' name', '')
398 const test = await testVideoImage(server.url, videoName, video.thumbnailPath)
399
400 expect(test).to.equal(true)
401 }
402 })
403
404 it('Should list only the two first videos', async function () {
405 const res = await getVideosListPagination(server.url, 0, 2, 'name')
406
407 const videos = res.body.data
408 expect(res.body.total).to.equal(6)
409 expect(videos.length).to.equal(2)
410 expect(videos[0].name).to.equal(videosListBase[0].name)
411 expect(videos[1].name).to.equal(videosListBase[1].name)
412 })
413
414 it('Should list only the next three videos', async function () {
415 const res = await getVideosListPagination(server.url, 2, 3, 'name')
416
417 const videos = res.body.data
418 expect(res.body.total).to.equal(6)
419 expect(videos.length).to.equal(3)
420 expect(videos[0].name).to.equal(videosListBase[2].name)
421 expect(videos[1].name).to.equal(videosListBase[3].name)
422 expect(videos[2].name).to.equal(videosListBase[4].name)
423 })
424
425 it('Should list the last video', async function () {
426 const res = await getVideosListPagination(server.url, 5, 6, 'name')
427
428 const videos = res.body.data
429 expect(res.body.total).to.equal(6)
430 expect(videos.length).to.equal(1)
431 expect(videos[0].name).to.equal(videosListBase[5].name)
432 })
433
434 it('Should search the first video', async function () {
435 const res = await searchVideoWithPagination(server.url, 'webm', 'name', 0, 1, 'name')
436
437 const videos = res.body.data
438 expect(res.body.total).to.equal(4)
439 expect(videos.length).to.equal(1)
440 expect(videos[0].name).to.equal('video_short1.webm name')
441 })
442
443 it('Should search the last two videos', async function () {
444 const res = await searchVideoWithPagination(server.url, 'webm', 'name', 2, 2, 'name')
445
446 const videos = res.body.data
447 expect(res.body.total).to.equal(4)
448 expect(videos.length).to.equal(2)
449 expect(videos[0].name).to.equal('video_short3.webm name')
450 expect(videos[1].name).to.equal('video_short.webm name')
451 })
452
453 it('Should search all the webm videos', async function () {
454 const res = await searchVideoWithPagination(server.url, 'webm', 'name', 0, 15)
455
456 const videos = res.body.data
457 expect(res.body.total).to.equal(4)
458 expect(videos.length).to.equal(4)
459 })
460
461 it('Should search all the root author videos', async function () {
462 const res = await searchVideoWithPagination(server.url, 'root', 'author', 0, 15)
463
464 const videos = res.body.data
465 expect(res.body.total).to.equal(6)
466 expect(videos.length).to.equal(6)
467 })
468
469 // Not implemented yet
470 // it('Should search all the 9001 port videos', async function () {
471 // const res = await videosUtils.searchVideoWithPagination(server.url, '9001', 'host', 0, 15)
472
473 // const videos = res.body.data
474 // expect(res.body.total).to.equal(6)
475 // expect(videos.length).to.equal(6)
476
477 // done()
478 // })
479 // })
480
481 // it('Should search all the localhost videos', async function () {
482 // const res = await videosUtils.searchVideoWithPagination(server.url, 'localhost', 'host', 0, 15)
483
484 // const videos = res.body.data
485 // expect(res.body.total).to.equal(6)
486 // expect(videos.length).to.equal(6)
487
488 // done()
489 // })
490 // })
491
492 it('Should search the right magnetUri video', async function () {
493 const video = videosListBase[0]
494 const res = await searchVideoWithPagination(server.url, encodeURIComponent(video.files[0].magnetUri), 'magnetUri', 0, 15)
495
496 const videos = res.body.data
497 expect(res.body.total).to.equal(1)
498 expect(videos.length).to.equal(1)
499 expect(videos[0].name).to.equal(video.name)
500 })
501
502 it('Should list and sort by name in descending order', async function () {
503 const res = await getVideosListSort(server.url, '-name')
504
505 const videos = res.body.data
506 expect(res.body.total).to.equal(6)
507 expect(videos.length).to.equal(6)
508 expect(videos[0].name).to.equal('video_short.webm name')
509 expect(videos[1].name).to.equal('video_short.ogv name')
510 expect(videos[2].name).to.equal('video_short.mp4 name')
511 expect(videos[3].name).to.equal('video_short3.webm name')
512 expect(videos[4].name).to.equal('video_short2.webm name')
513 expect(videos[5].name).to.equal('video_short1.webm name')
514 })
515
516 it('Should search and sort by name in ascending order', async function () {
517 const res = await searchVideoWithSort(server.url, 'webm', 'name')
518
519 const videos = res.body.data
520 expect(res.body.total).to.equal(4)
521 expect(videos.length).to.equal(4)
522
523 expect(videos[0].name).to.equal('video_short1.webm name')
524 expect(videos[1].name).to.equal('video_short2.webm name')
525 expect(videos[2].name).to.equal('video_short3.webm name')
526 expect(videos[3].name).to.equal('video_short.webm name')
527
528 videoId = videos[2].id
529 })
530
531 it('Should update a video', async function () {
532 const attributes = {
533 name: 'my super video updated',
534 category: 4,
535 licence: 2,
536 language: 5,
537 nsfw: false,
538 description: 'my super description updated',
539 tags: [ 'tagup1', 'tagup2' ]
540 }
541 await updateVideo(server.url, server.accessToken, videoId, attributes)
542 })
543
544 it('Should have the video updated', async function () {
545 this.timeout(60000)
546
547 const res = await getVideo(server.url, videoId)
548
549 const video = res.body
550
551 expect(video.name).to.equal('my super video updated')
552 expect(video.category).to.equal(4)
553 expect(video.categoryLabel).to.equal('Art')
554 expect(video.licence).to.equal(2)
555 expect(video.licenceLabel).to.equal('Attribution - Share Alike')
556 expect(video.language).to.equal(5)
557 expect(video.languageLabel).to.equal('Arabic')
558 expect(video.nsfw).to.be.ok
559 expect(video.description).to.equal('my super description updated')
560 expect(video.podHost).to.equal('localhost:9001')
561 expect(video.author).to.equal('root')
562 expect(video.isLocal).to.be.true
563 expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
564 expect(dateIsValid(video.createdAt)).to.be.true
565 expect(dateIsValid(video.updatedAt)).to.be.true
566
567 expect(video.files).to.have.lengthOf(1)
568
569 const file = video.files[0]
570 const magnetUri = file.magnetUri
571 expect(file.magnetUri).to.have.lengthOf.above(2)
572 expect(file.resolution).to.equal(0)
573 expect(file.resolutionLabel).to.equal('original')
574 expect(file.size).to.equal(292677)
575
576 const test = await testVideoImage(server.url, 'video_short3.webm', video.thumbnailPath)
577 expect(test).to.equal(true)
578
579 const torrent = await webtorrentAdd(magnetUri)
580 expect(torrent.files).to.be.an('array')
581 expect(torrent.files.length).to.equal(1)
582 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
583 })
584
585 it('Should update only the tags of a video', async function () {
586 const attributes = {
587 tags: [ 'tag1', 'tag2', 'supertag' ]
588 }
589
590 await updateVideo(server.url, server.accessToken, videoId, attributes)
591
592 const res = await getVideo(server.url, videoId)
593 const video = res.body
594
595 expect(video.name).to.equal('my super video updated')
596 expect(video.category).to.equal(4)
597 expect(video.categoryLabel).to.equal('Art')
598 expect(video.licence).to.equal(2)
599 expect(video.licenceLabel).to.equal('Attribution - Share Alike')
600 expect(video.language).to.equal(5)
601 expect(video.languageLabel).to.equal('Arabic')
602 expect(video.nsfw).to.be.ok
603 expect(video.description).to.equal('my super description updated')
604 expect(video.podHost).to.equal('localhost:9001')
605 expect(video.author).to.equal('root')
606 expect(video.isLocal).to.be.true
607 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ])
608 expect(dateIsValid(video.createdAt)).to.be.true
609 expect(dateIsValid(video.updatedAt)).to.be.true
610
611 expect(video.files).to.have.lengthOf(1)
612
613 const file = video.files[0]
614 expect(file.magnetUri).to.have.lengthOf.above(2)
615 expect(file.resolution).to.equal(0)
616 expect(file.resolutionLabel).to.equal('original')
617 expect(file.size).to.equal(292677)
618 })
619
620 it('Should update only the description of a video', async function () {
621 const attributes = {
622 description: 'hello everybody'
623 }
624
625 await updateVideo(server.url, server.accessToken, videoId, attributes)
626
627 const res = await getVideo(server.url, videoId)
628 const video = res.body
629
630 expect(video.name).to.equal('my super video updated')
631 expect(video.category).to.equal(4)
632 expect(video.categoryLabel).to.equal('Art')
633 expect(video.licence).to.equal(2)
634 expect(video.licenceLabel).to.equal('Attribution - Share Alike')
635 expect(video.language).to.equal(5)
636 expect(video.languageLabel).to.equal('Arabic')
637 expect(video.nsfw).to.be.ok
638 expect(video.description).to.equal('hello everybody')
639 expect(video.podHost).to.equal('localhost:9001')
640 expect(video.author).to.equal('root')
641 expect(video.isLocal).to.be.true
642 expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ])
643 expect(dateIsValid(video.createdAt)).to.be.true
644 expect(dateIsValid(video.updatedAt)).to.be.true
645
646 expect(video.files).to.have.lengthOf(1)
647
648 const file = video.files[0]
649 expect(file.magnetUri).to.have.lengthOf.above(2)
650 expect(file.resolution).to.equal(0)
651 expect(file.resolutionLabel).to.equal('original')
652 expect(file.size).to.equal(292677)
653 })
654
655 it('Should like a video', async function () {
656 await rateVideo(server.url, server.accessToken, videoId, 'like')
657
658 const res = await getVideo(server.url, videoId)
659 const video = res.body
660
661 expect(video.likes).to.equal(1)
662 expect(video.dislikes).to.equal(0)
663 })
664
665 it('Should dislike the same video', async function () {
666 await rateVideo(server.url, server.accessToken, videoId, 'dislike')
667
668 const res = await getVideo(server.url, videoId)
669 const video = res.body
670
671 expect(video.likes).to.equal(0)
672 expect(video.dislikes).to.equal(1)
673 })
674
675 after(async function () {
676 killallServers([ server ])
677
678 // Keep the logs if the test failed
679 if (this['ok']) {
680 await flushTests()
681 }
682 })
683})