]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/videos/multiple-servers.ts
Refractor check video tests
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / multiple-servers.ts
1 /* tslint:disable:no-unused-expression */
2
3 import * as chai from 'chai'
4 import 'mocha'
5 import { join } from 'path'
6 import * as request from 'supertest'
7 import { VideoPrivacy } from '../../../../shared/models/videos'
8 import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
9
10 import {
11 addVideoChannel, completeVideoCheck, createUser, dateIsValid, doubleFollow, flushAndRunMultipleServers, flushTests, getVideo,
12 getVideoChannelsList, getVideosList, killallServers, rateVideo, removeVideo, ServerInfo, setAccessTokensToServers, testVideoImage,
13 updateVideo, uploadVideo, userLogin, viewVideo, wait, webtorrentAdd
14 } from '../../utils'
15 import {
16 addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
17 getVideoThreadComments
18 } from '../../utils/videos/video-comments'
19
20 const expect = chai.expect
21
22 describe('Test multiple servers', function () {
23 let servers: ServerInfo[] = []
24 const toRemove = []
25 let videoUUID = ''
26 let videoChannelId: number
27
28 before(async function () {
29 this.timeout(120000)
30
31 servers = await flushAndRunMultipleServers(3)
32
33 // Get the access tokens
34 await setAccessTokensToServers(servers)
35
36 const videoChannel = {
37 name: 'my channel',
38 description: 'super channel'
39 }
40 await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
41 const channelRes = await getVideoChannelsList(servers[0].url, 0, 1)
42 videoChannelId = channelRes.body.data[0].id
43
44 // Server 1 and server 2 follow each other
45 await doubleFollow(servers[0], servers[1])
46 // Server 1 and server 3 follow each other
47 await doubleFollow(servers[0], servers[2])
48 // Server 2 and server 3 follow each other
49 await doubleFollow(servers[1], servers[2])
50 })
51
52 it('Should not have videos for all servers', async function () {
53 for (const server of servers) {
54 const res = await getVideosList(server.url)
55 const videos = res.body.data
56 expect(videos).to.be.an('array')
57 expect(videos.length).to.equal(0)
58 }
59 })
60
61 describe('Should upload the video and propagate on each server', function () {
62 it('Should upload the video on server 1 and propagate on each server', async function () {
63 this.timeout(25000)
64
65 const videoAttributes = {
66 name: 'my super name for server 1',
67 category: 5,
68 licence: 4,
69 language: 9,
70 nsfw: true,
71 description: 'my super description for server 1',
72 tags: [ 'tag1p1', 'tag2p1' ],
73 channelId: videoChannelId,
74 fixture: 'video_short1.webm'
75 }
76 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
77
78 await wait(10000)
79
80 // All servers should have this video
81 for (const server of servers) {
82 const isLocal = server.url === 'http://localhost:9001'
83 const checkAttributes = {
84 name: 'my super name for server 1',
85 category: 5,
86 licence: 4,
87 language: 9,
88 nsfw: true,
89 description: 'my super description for server 1',
90 host: 'localhost:9001',
91 account: 'root',
92 isLocal,
93 duration: 10,
94 tags: [ 'tag1p1', 'tag2p1' ],
95 privacy: VideoPrivacy.PUBLIC,
96 channel: {
97 name: 'my channel',
98 description: 'super channel',
99 isLocal
100 },
101 fixture: 'video_short.webm',
102 files: [
103 {
104 resolution: 720,
105 size: 572456
106 }
107 ]
108 }
109
110 const res = await getVideosList(server.url)
111 const videos = res.body.data
112 expect(videos).to.be.an('array')
113 expect(videos.length).to.equal(1)
114 const video = videos[0]
115
116 await completeVideoCheck(server.url, video, checkAttributes)
117 }
118 })
119
120 it('Should upload the video on server 2 and propagate on each server', async function () {
121 this.timeout(50000)
122
123 const user = {
124 username: 'user1',
125 password: 'super_password'
126 }
127 await createUser(servers[1].url, servers[1].accessToken, user.username, user.password)
128 const userAccessToken = await userLogin(servers[1], user)
129
130 const videoAttributes = {
131 name: 'my super name for server 2',
132 category: 4,
133 licence: 3,
134 language: 11,
135 nsfw: true,
136 description: 'my super description for server 2',
137 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
138 fixture: 'video_short2.webm'
139 }
140 await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
141
142 // Transcoding
143 await wait(30000)
144
145 // All servers should have this video
146 for (const server of servers) {
147 const isLocal = server.url === 'http://localhost:9002'
148 const checkAttributes = {
149 name: 'my super name for server 2',
150 category: 4,
151 licence: 3,
152 language: 11,
153 nsfw: true,
154 description: 'my super description for server 2',
155 host: 'localhost:9002',
156 account: 'user1',
157 isLocal,
158 duration: 5,
159 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
160 privacy: VideoPrivacy.PUBLIC,
161 channel: {
162 name: 'Default user1 channel',
163 description: 'super channel',
164 isLocal
165 },
166 fixture: 'video_short2.webm',
167 files: [
168 {
169 resolution: 240,
170 size: 190000
171 },
172 {
173 resolution: 360,
174 size: 280000
175 },
176 {
177 resolution: 480,
178 size: 390000
179 },
180 {
181 resolution: 720,
182 size: 710000
183 }
184 ]
185 }
186
187 const res = await getVideosList(server.url)
188 const videos = res.body.data
189 expect(videos).to.be.an('array')
190 expect(videos.length).to.equal(2)
191 const video = videos[1]
192
193 await completeVideoCheck(server.url, video, checkAttributes)
194 }
195 })
196
197 it('Should upload two videos on server 3 and propagate on each server', async function () {
198 this.timeout(45000)
199
200 const videoAttributes1 = {
201 name: 'my super name for server 3',
202 category: 6,
203 licence: 5,
204 language: 11,
205 nsfw: true,
206 description: 'my super description for server 3',
207 tags: [ 'tag1p3' ],
208 fixture: 'video_short3.webm'
209 }
210 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1)
211
212 const videoAttributes2 = {
213 name: 'my super name for server 3-2',
214 category: 7,
215 licence: 6,
216 language: 12,
217 nsfw: false,
218 description: 'my super description for server 3-2',
219 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
220 fixture: 'video_short.webm'
221 }
222 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
223
224 await wait(10000)
225
226 // All servers should have this video
227 for (const server of servers) {
228 const isLocal = server.url === 'http://localhost:9003'
229 const res = await getVideosList(server.url)
230
231 const videos = res.body.data
232 expect(videos).to.be.an('array')
233 expect(videos.length).to.equal(4)
234
235 // We not sure about the order of the two last uploads
236 let video1 = null
237 let video2 = null
238 if (videos[2].name === 'my super name for server 3') {
239 video1 = videos[2]
240 video2 = videos[3]
241 } else {
242 video1 = videos[3]
243 video2 = videos[2]
244 }
245
246 const checkAttributesVideo1 = {
247 name: 'my super name for server 3',
248 category: 6,
249 licence: 5,
250 language: 11,
251 nsfw: true,
252 description: 'my super description for server 3',
253 host: 'localhost:9003',
254 account: 'root',
255 isLocal,
256 duration: 5,
257 tags: [ 'tag1p3' ],
258 privacy: VideoPrivacy.PUBLIC,
259 channel: {
260 name: 'Default root channel',
261 description: '',
262 isLocal
263 },
264 fixture: 'video_short3.webm',
265 files: [
266 {
267 resolution: 720,
268 size: 292677
269 }
270 ]
271 }
272 await completeVideoCheck(server.url, video1, checkAttributesVideo1)
273
274 const checkAttributesVideo2 = {
275 name: 'my super name for server 3-2',
276 category: 7,
277 licence: 6,
278 language: 12,
279 nsfw: false,
280 description: 'my super description for server 3-2',
281 host: 'localhost:9003',
282 account: 'root',
283 isLocal,
284 duration: 5,
285 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
286 privacy: VideoPrivacy.PUBLIC,
287 channel: {
288 name: 'Default root channel',
289 description: '',
290 isLocal
291 },
292 fixture: 'video_short3.webm',
293 files: [
294 {
295 resolution: 720,
296 size: 218910
297 }
298 ]
299 }
300 await completeVideoCheck(server.url, video2, checkAttributesVideo2)
301 }
302 })
303 })
304
305 describe('Should seed the uploaded video', function () {
306 it('Should add the file 1 by asking server 3', async function () {
307 this.timeout(10000)
308
309 const res = await getVideosList(servers[2].url)
310
311 const video = res.body.data[0]
312 toRemove.push(res.body.data[2])
313 toRemove.push(res.body.data[3])
314
315 const res2 = await getVideo(servers[2].url, video.id)
316 const videoDetails = res2.body
317
318 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
319 expect(torrent.files).to.be.an('array')
320 expect(torrent.files.length).to.equal(1)
321 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
322 })
323
324 it('Should add the file 2 by asking server 1', async function () {
325 this.timeout(10000)
326
327 const res = await getVideosList(servers[0].url)
328
329 const video = res.body.data[1]
330 const res2 = await getVideo(servers[0].url, video.id)
331 const videoDetails = res2.body
332
333 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
334 expect(torrent.files).to.be.an('array')
335 expect(torrent.files.length).to.equal(1)
336 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
337 })
338
339 it('Should add the file 3 by asking server 2', async function () {
340 this.timeout(10000)
341
342 const res = await getVideosList(servers[1].url)
343
344 const video = res.body.data[2]
345 const res2 = await getVideo(servers[1].url, video.id)
346 const videoDetails = res2.body
347
348 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
349 expect(torrent.files).to.be.an('array')
350 expect(torrent.files.length).to.equal(1)
351 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
352 })
353
354 it('Should add the file 3-2 by asking server 1', async function () {
355 this.timeout(10000)
356
357 const res = await getVideosList(servers[0].url)
358
359 const video = res.body.data[3]
360 const res2 = await getVideo(servers[0].url, video.id)
361 const videoDetails = res2.body
362
363 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
364 expect(torrent.files).to.be.an('array')
365 expect(torrent.files.length).to.equal(1)
366 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
367 })
368
369 it('Should add the file 2 in 360p by asking server 1', async function () {
370 this.timeout(10000)
371
372 const res = await getVideosList(servers[0].url)
373
374 const video = res.body.data.find(v => v.name === 'my super name for server 2')
375 const res2 = await getVideo(servers[0].url, video.id)
376 const videoDetails = res2.body
377
378 const file = videoDetails.files.find(f => f.resolution === 360)
379 expect(file).not.to.be.undefined
380
381 const torrent = await webtorrentAdd(file.magnetUri)
382 expect(torrent.files).to.be.an('array')
383 expect(torrent.files.length).to.equal(1)
384 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
385 })
386 })
387
388 describe('Should update video views, likes and dislikes', function () {
389 let localVideosServer3 = []
390 let remoteVideosServer1 = []
391 let remoteVideosServer2 = []
392 let remoteVideosServer3 = []
393
394 before(async function () {
395 const res1 = await getVideosList(servers[0].url)
396 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
397
398 const res2 = await getVideosList(servers[1].url)
399 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
400
401 const res3 = await getVideosList(servers[2].url)
402 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
403 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
404 })
405
406 it('Should view multiple videos on owned servers', async function () {
407 this.timeout(10000)
408
409 const tasks: Promise<any>[] = []
410 tasks.push(viewVideo(servers[2].url, localVideosServer3[0]))
411 tasks.push(viewVideo(servers[2].url, localVideosServer3[0]))
412 tasks.push(viewVideo(servers[2].url, localVideosServer3[0]))
413 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
414
415 await Promise.all(tasks)
416
417 await wait(5000)
418
419 for (const server of servers) {
420 const res = await getVideosList(server.url)
421
422 const videos = res.body.data
423 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
424 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
425
426 expect(video0.views).to.equal(3)
427 expect(video1.views).to.equal(1)
428 }
429 })
430
431 it('Should view multiple videos on each servers', async function () {
432 this.timeout(15000)
433
434 const tasks: Promise<any>[] = []
435 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
436 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
437 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
438 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
439 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
440 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
441 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
442 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
443 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
444 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
445
446 await Promise.all(tasks)
447
448 await wait(10000)
449
450 let baseVideos = null
451
452 for (const server of servers) {
453 const res = await getVideosList(server.url)
454
455 const videos = res.body.data
456
457 // Initialize base videos for future comparisons
458 if (baseVideos === null) {
459 baseVideos = videos
460 continue
461 }
462
463 for (const baseVideo of baseVideos) {
464 const sameVideo = videos.find(video => video.name === baseVideo.name)
465 expect(baseVideo.views).to.equal(sameVideo.views)
466 }
467 }
468 })
469
470 it('Should like and dislikes videos on different services', async function () {
471 this.timeout(20000)
472
473 const tasks: Promise<any>[] = []
474 tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like'))
475 tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike'))
476 tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like'))
477 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like'))
478 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike'))
479 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike'))
480 tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like'))
481
482 await Promise.all(tasks)
483
484 await wait(10000)
485
486 let baseVideos = null
487 for (const server of servers) {
488 const res = await getVideosList(server.url)
489
490 const videos = res.body.data
491
492 // Initialize base videos for future comparisons
493 if (baseVideos === null) {
494 baseVideos = videos
495 continue
496 }
497
498 for (const baseVideo of baseVideos) {
499 const sameVideo = videos.find(video => video.name === baseVideo.name)
500 expect(baseVideo.likes).to.equal(sameVideo.likes)
501 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
502 }
503 }
504 })
505 })
506
507 describe('Should manipulate these videos', function () {
508 it('Should update the video 3 by asking server 3', async function () {
509 this.timeout(10000)
510
511 const attributes = {
512 name: 'my super video updated',
513 category: 10,
514 licence: 7,
515 language: 13,
516 nsfw: true,
517 description: 'my super description updated',
518 tags: [ 'tag_up_1', 'tag_up_2' ]
519 }
520
521 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
522
523 await wait(5000)
524 })
525
526 it('Should have the video 3 updated on each server', async function () {
527 this.timeout(10000)
528
529 for (const server of servers) {
530 const res = await getVideosList(server.url)
531
532 const videos = res.body.data
533 const videoUpdated = videos.find(video => video.name === 'my super video updated')
534 expect(!!videoUpdated).to.be.true
535
536 const isLocal = server.url === 'http://localhost:9003'
537 const checkAttributes = {
538 name: 'my super video updated',
539 category: 10,
540 licence: 7,
541 language: 13,
542 nsfw: true,
543 description: 'my super description updated',
544 host: 'localhost:9003',
545 account: 'root',
546 isLocal,
547 duration: 5,
548 tags: [ 'tag_up_1', 'tag_up_2' ],
549 privacy: VideoPrivacy.PUBLIC,
550 channel: {
551 name: 'Default root channel',
552 description: '',
553 isLocal
554 },
555 fixture: 'video_short3.webm',
556 files: [
557 {
558 resolution: 720,
559 size: 292677
560 }
561 ]
562 }
563 await completeVideoCheck(server.url, videoUpdated, checkAttributes)
564 }
565 })
566
567 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
568 this.timeout(10000)
569
570 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
571 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
572
573 await wait(5000)
574 })
575
576 it('Should have videos 1 and 3 on each server', async function () {
577 for (const server of servers) {
578 const res = await getVideosList(server.url)
579
580 const videos = res.body.data
581 expect(videos).to.be.an('array')
582 expect(videos.length).to.equal(2)
583 expect(videos[0].name).not.to.equal(videos[1].name)
584 expect(videos[0].name).not.to.equal(toRemove[0].name)
585 expect(videos[1].name).not.to.equal(toRemove[0].name)
586 expect(videos[0].name).not.to.equal(toRemove[1].name)
587 expect(videos[1].name).not.to.equal(toRemove[1].name)
588
589 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
590 }
591 })
592
593 it('Should get the same video by UUID on each server', async function () {
594 let baseVideo = null
595 for (const server of servers) {
596 const res = await getVideo(server.url, videoUUID)
597
598 const video = res.body
599
600 if (baseVideo === null) {
601 baseVideo = video
602 continue
603 }
604
605 expect(baseVideo.name).to.equal(video.name)
606 expect(baseVideo.uuid).to.equal(video.uuid)
607 expect(baseVideo.category).to.equal(video.category)
608 expect(baseVideo.language).to.equal(video.language)
609 expect(baseVideo.licence).to.equal(video.licence)
610 expect(baseVideo.category).to.equal(video.category)
611 expect(baseVideo.nsfw).to.equal(video.nsfw)
612 expect(baseVideo.accountName).to.equal(video.accountName)
613 expect(baseVideo.tags).to.deep.equal(video.tags)
614 }
615 })
616
617 it('Should get the preview from each server', async function () {
618 for (const server of servers) {
619 const res = await getVideo(server.url, videoUUID)
620 const video = res.body
621
622 const test = await testVideoImage(server.url, 'video_short1-preview.webm', video.previewPath)
623 expect(test).to.equal(true)
624 }
625 })
626 })
627
628 describe('Should comment these videos', function () {
629 it('Should add comment (threads and replies)', async function () {
630 this.timeout(25000)
631
632 {
633 const text = 'my super first comment'
634 await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, text)
635 }
636
637 {
638 const text = 'my super second comment'
639 await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text)
640 }
641
642 await wait(5000)
643
644 {
645 const res = await getVideoCommentThreads(servers[1].url, videoUUID, 0, 5)
646 const threadId = res.body.data.find(c => c.text === 'my super first comment').id
647
648 const text = 'my super answer to thread 1'
649 await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text)
650 }
651
652 await wait(5000)
653
654 {
655 const res1 = await getVideoCommentThreads(servers[2].url, videoUUID, 0, 5)
656 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
657
658 const res2 = await getVideoThreadComments(servers[2].url, videoUUID, threadId)
659 const childCommentId = res2.body.children[0].comment.id
660
661 const text3 = 'my second answer to thread 1'
662 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, threadId, text3)
663
664 const text2 = 'my super answer to answer of thread 1'
665 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2)
666 }
667
668 await wait(5000)
669 })
670
671 it('Should have these threads', async function () {
672 for (const server of servers) {
673 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
674
675 expect(res.body.total).to.equal(2)
676 expect(res.body.data).to.be.an('array')
677 expect(res.body.data).to.have.lengthOf(2)
678
679 {
680 const comment: VideoComment = res.body.data.find(c => c.text === 'my super first comment')
681 expect(comment).to.not.be.undefined
682 expect(comment.inReplyToCommentId).to.be.null
683 expect(comment.account.name).to.equal('root')
684 expect(comment.account.host).to.equal('localhost:9001')
685 expect(comment.totalReplies).to.equal(3)
686 expect(dateIsValid(comment.createdAt as string)).to.be.true
687 expect(dateIsValid(comment.updatedAt as string)).to.be.true
688 }
689
690 {
691 const comment: VideoComment = res.body.data.find(c => c.text === 'my super second comment')
692 expect(comment).to.not.be.undefined
693 expect(comment.inReplyToCommentId).to.be.null
694 expect(comment.account.name).to.equal('root')
695 expect(comment.account.host).to.equal('localhost:9003')
696 expect(comment.totalReplies).to.equal(0)
697 expect(dateIsValid(comment.createdAt as string)).to.be.true
698 expect(dateIsValid(comment.updatedAt as string)).to.be.true
699 }
700 }
701 })
702
703 it('Should have these comments', async function () {
704 for (const server of servers) {
705 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
706 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
707
708 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
709
710 const tree: VideoCommentThreadTree = res2.body
711 expect(tree.comment.text).equal('my super first comment')
712 expect(tree.comment.account.name).equal('root')
713 expect(tree.comment.account.host).equal('localhost:9001')
714 expect(tree.children).to.have.lengthOf(2)
715
716 const firstChild = tree.children[0]
717 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
718 expect(firstChild.comment.account.name).equal('root')
719 expect(firstChild.comment.account.host).equal('localhost:9002')
720 expect(firstChild.children).to.have.lengthOf(1)
721
722 const childOfFirstChild = firstChild.children[0]
723 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
724 expect(childOfFirstChild.comment.account.name).equal('root')
725 expect(childOfFirstChild.comment.account.host).equal('localhost:9003')
726 expect(childOfFirstChild.children).to.have.lengthOf(0)
727
728 const secondChild = tree.children[1]
729 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
730 expect(secondChild.comment.account.name).equal('root')
731 expect(secondChild.comment.account.host).equal('localhost:9003')
732 expect(secondChild.children).to.have.lengthOf(0)
733 }
734 })
735 })
736
737 describe('With minimum parameters', function () {
738 it('Should upload and propagate the video', async function () {
739 this.timeout(50000)
740
741 const path = '/api/v1/videos/upload'
742
743 const req = request(servers[1].url)
744 .post(path)
745 .set('Accept', 'application/json')
746 .set('Authorization', 'Bearer ' + servers[1].accessToken)
747 .field('name', 'minimum parameters')
748 .field('privacy', '1')
749 .field('nsfw', 'false')
750 .field('channelId', '1')
751
752 const filePath = join(__dirname, '..', '..', 'api', 'fixtures', 'video_short.webm')
753
754 await req.attach('videofile', filePath)
755 .expect(200)
756
757 await wait(25000)
758
759 for (const server of servers) {
760 const res = await getVideosList(server.url)
761 const video = res.body.data.find(v => v.name === 'minimum parameters')
762
763 const isLocal = server.url === 'http://localhost:9002'
764 const checkAttributes = {
765 name: 'minimum parameters',
766 category: null,
767 licence: null,
768 language: null,
769 nsfw: false,
770 description: null,
771 host: 'localhost:9002',
772 account: 'root',
773 isLocal,
774 duration: 5,
775 tags: [ ],
776 privacy: VideoPrivacy.PUBLIC,
777 channel: {
778 name: 'Default root channel',
779 description: '',
780 isLocal
781 },
782 fixture: 'video_short.webm',
783 files: [
784 {
785 resolution: 720,
786 size: 40315
787 },
788 {
789 resolution: 480,
790 size: 22808
791 },
792 {
793 resolution: 360,
794 size: 18617
795 },
796 {
797 resolution: 240,
798 size: 15217
799 }
800 ]
801 }
802 await completeVideoCheck(server.url, video, checkAttributes)
803 }
804 })
805 })
806
807 after(async function () {
808 killallServers(servers)
809
810 // Keep the logs if the test failed
811 if (this['ok']) {
812 await flushTests()
813 }
814 })
815 })