multiple-servers.ts 34.9 KB
Newer Older
Chocobozzz's avatar
Chocobozzz committed
1
2
3
/* tslint:disable:no-unused-expression */

import * as chai from 'chai'
Chocobozzz's avatar
Chocobozzz committed
4
import 'mocha'
Chocobozzz's avatar
Chocobozzz committed
5
import { join } from 'path'
Chocobozzz's avatar
Chocobozzz committed
6
import * as request from 'supertest'
Chocobozzz's avatar
Chocobozzz committed
7
import { VideoPrivacy } from '../../../../shared/models/videos'
Chocobozzz's avatar
Chocobozzz committed
8
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
Chocobozzz's avatar
Chocobozzz committed
9
import {
10
  addVideoChannel,
Chocobozzz's avatar
Chocobozzz committed
11
  checkTmpIsEmpty,
12
13
  checkVideoFilesWereRemoved,
  cleanupTests,
14
15
16
17
18
  completeVideoCheck,
  createUser,
  dateIsValid,
  doubleFollow,
  flushAndRunMultipleServers,
19
  getLocalVideos,
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  getVideo,
  getVideoChannelsList,
  getVideosList,
  rateVideo,
  removeVideo,
  ServerInfo,
  setAccessTokensToServers,
  testImage,
  updateVideo,
  uploadVideo,
  userLogin,
  viewVideo,
  wait,
  webtorrentAdd
Chocobozzz's avatar
Chocobozzz committed
34
} from '../../../../shared/extra-utils'
Chocobozzz's avatar
Chocobozzz committed
35
import {
36
37
38
39
  addVideoCommentReply,
  addVideoCommentThread,
  deleteVideoComment,
  getVideoCommentThreads,
Chocobozzz's avatar
Chocobozzz committed
40
  getVideoThreadComments
Chocobozzz's avatar
Chocobozzz committed
41
42
} from '../../../../shared/extra-utils/videos/video-comments'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
Chocobozzz's avatar
Chocobozzz committed
43
44
45

const expect = chai.expect

Chocobozzz's avatar
Chocobozzz committed
46
describe('Test multiple servers', function () {
Chocobozzz's avatar
Chocobozzz committed
47
48
49
  let servers: ServerInfo[] = []
  const toRemove = []
  let videoUUID = ''
Chocobozzz's avatar
Chocobozzz committed
50
  let videoChannelId: number
Chocobozzz's avatar
Chocobozzz committed
51
52
53
54
55
56
57
58
59

  before(async function () {
    this.timeout(120000)

    servers = await flushAndRunMultipleServers(3)

    // Get the access tokens
    await setAccessTokensToServers(servers)

Chocobozzz's avatar
Chocobozzz committed
60
61
    {
      const videoChannel = {
62
        name: 'super_channel_name',
Chocobozzz's avatar
Chocobozzz committed
63
        displayName: 'my channel',
Chocobozzz's avatar
Chocobozzz committed
64
65
        description: 'super channel'
      }
Chocobozzz's avatar
Chocobozzz committed
66
      await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel)
Chocobozzz's avatar
Chocobozzz committed
67
68
      const channelRes = await getVideoChannelsList(servers[ 0 ].url, 0, 1)
      videoChannelId = channelRes.body.data[ 0 ].id
Chocobozzz's avatar
Chocobozzz committed
69
70
    }

Chocobozzz's avatar
Chocobozzz committed
71
72
73
74
75
76
    // Server 1 and server 2 follow each other
    await doubleFollow(servers[0], servers[1])
    // Server 1 and server 3 follow each other
    await doubleFollow(servers[0], servers[2])
    // Server 2 and server 3 follow each other
    await doubleFollow(servers[1], servers[2])
Chocobozzz's avatar
Chocobozzz committed
77
78
  })

Chocobozzz's avatar
Chocobozzz committed
79
  it('Should not have videos for all servers', async function () {
Chocobozzz's avatar
Chocobozzz committed
80
81
82
83
84
85
86
87
    for (const server of servers) {
      const res = await getVideosList(server.url)
      const videos = res.body.data
      expect(videos).to.be.an('array')
      expect(videos.length).to.equal(0)
    }
  })

Chocobozzz's avatar
Chocobozzz committed
88
89
  describe('Should upload the video and propagate on each server', function () {
    it('Should upload the video on server 1 and propagate on each server', async function () {
Chocobozzz's avatar
Chocobozzz committed
90
      this.timeout(25000)
Chocobozzz's avatar
Chocobozzz committed
91
92

      const videoAttributes = {
Chocobozzz's avatar
Chocobozzz committed
93
        name: 'my super name for server 1',
Chocobozzz's avatar
Chocobozzz committed
94
95
        category: 5,
        licence: 4,
Chocobozzz's avatar
Chocobozzz committed
96
        language: 'ja',
Chocobozzz's avatar
Chocobozzz committed
97
        nsfw: true,
Chocobozzz's avatar
Chocobozzz committed
98
        description: 'my super description for server 1',
99
        support: 'my super support text for server 1',
100
        originallyPublishedAt: '2019-02-10T13:38:14.449Z',
Chocobozzz's avatar
Chocobozzz committed
101
        tags: [ 'tag1p1', 'tag2p1' ],
Chocobozzz's avatar
Chocobozzz committed
102
        channelId: videoChannelId,
Chocobozzz's avatar
Chocobozzz committed
103
104
105
106
        fixture: 'video_short1.webm'
      }
      await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)

107
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
108

Chocobozzz's avatar
Chocobozzz committed
109
      // All servers should have this video
110
      let publishedAt: string = null
Chocobozzz's avatar
Chocobozzz committed
111
      for (const server of servers) {
Chocobozzz's avatar
Chocobozzz committed
112
        const isLocal = server.port === servers[0].port
Chocobozzz's avatar
Chocobozzz committed
113
114
115
116
        const checkAttributes = {
          name: 'my super name for server 1',
          category: 5,
          licence: 4,
Chocobozzz's avatar
Chocobozzz committed
117
          language: 'ja',
Chocobozzz's avatar
Chocobozzz committed
118
119
          nsfw: true,
          description: 'my super description for server 1',
120
          support: 'my super support text for server 1',
121
          originallyPublishedAt: '2019-02-10T13:38:14.449Z',
122
123
          account: {
            name: 'root',
124
            host: 'localhost:' + servers[0].port
125
          },
Chocobozzz's avatar
Chocobozzz committed
126
          isLocal,
127
          publishedAt,
Chocobozzz's avatar
Chocobozzz committed
128
129
130
          duration: 10,
          tags: [ 'tag1p1', 'tag2p1' ],
          privacy: VideoPrivacy.PUBLIC,
131
          commentsEnabled: true,
132
          downloadEnabled: true,
Chocobozzz's avatar
Chocobozzz committed
133
          channel: {
134
135
            displayName: 'my channel',
            name: 'super_channel_name',
Chocobozzz's avatar
Chocobozzz committed
136
137
138
            description: 'super channel',
            isLocal
          },
Chocobozzz's avatar
Chocobozzz committed
139
          fixture: 'video_short1.webm',
Chocobozzz's avatar
Chocobozzz committed
140
141
142
143
144
145
146
          files: [
            {
              resolution: 720,
              size: 572456
            }
          ]
        }
Chocobozzz's avatar
Chocobozzz committed
147
148
149
150
151
152
153

        const res = await getVideosList(server.url)
        const videos = res.body.data
        expect(videos).to.be.an('array')
        expect(videos.length).to.equal(1)
        const video = videos[0]

Chocobozzz's avatar
Chocobozzz committed
154
        await completeVideoCheck(server.url, video, checkAttributes)
155
        publishedAt = video.publishedAt
Chocobozzz's avatar
Chocobozzz committed
156
157
158
      }
    })

Chocobozzz's avatar
Chocobozzz committed
159
    it('Should upload the video on server 2 and propagate on each server', async function () {
160
      this.timeout(50000)
Chocobozzz's avatar
Chocobozzz committed
161

Chocobozzz's avatar
Chocobozzz committed
162
163
164
165
      const user = {
        username: 'user1',
        password: 'super_password'
      }
Chocobozzz's avatar
Chocobozzz committed
166
      await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
Chocobozzz's avatar
Chocobozzz committed
167
      const userAccessToken = await userLogin(servers[1], user)
Chocobozzz's avatar
Chocobozzz committed
168

Chocobozzz's avatar
Chocobozzz committed
169
      const videoAttributes = {
Chocobozzz's avatar
Chocobozzz committed
170
        name: 'my super name for server 2',
Chocobozzz's avatar
Chocobozzz committed
171
172
        category: 4,
        licence: 3,
Chocobozzz's avatar
Chocobozzz committed
173
        language: 'de',
Chocobozzz's avatar
Chocobozzz committed
174
        nsfw: true,
Chocobozzz's avatar
Chocobozzz committed
175
        description: 'my super description for server 2',
176
        support: 'my super support text for server 2',
Chocobozzz's avatar
Chocobozzz committed
177
        tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
178
179
180
        fixture: 'video_short2.webm',
        thumbnailfile: 'thumbnail.jpg',
        previewfile: 'preview.jpg'
Chocobozzz's avatar
Chocobozzz committed
181
      }
Chocobozzz's avatar
Chocobozzz committed
182
      await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
Chocobozzz's avatar
Chocobozzz committed
183

184
      // Transcoding
185
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
186

Chocobozzz's avatar
Chocobozzz committed
187
      // All servers should have this video
Chocobozzz's avatar
Chocobozzz committed
188
      for (const server of servers) {
189
        const isLocal = server.url === 'http://localhost:' + servers[1].port
Chocobozzz's avatar
Chocobozzz committed
190
191
192
193
        const checkAttributes = {
          name: 'my super name for server 2',
          category: 4,
          licence: 3,
Chocobozzz's avatar
Chocobozzz committed
194
          language: 'de',
Chocobozzz's avatar
Chocobozzz committed
195
196
          nsfw: true,
          description: 'my super description for server 2',
197
          support: 'my super support text for server 2',
198
199
          account: {
            name: 'user1',
200
            host: 'localhost:' + servers[1].port
201
          },
Chocobozzz's avatar
Chocobozzz committed
202
          isLocal,
203
          commentsEnabled: true,
204
          downloadEnabled: true,
Chocobozzz's avatar
Chocobozzz committed
205
206
207
208
          duration: 5,
          tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
          privacy: VideoPrivacy.PUBLIC,
          channel: {
209
210
            displayName: 'Main user1 channel',
            name: 'user1_channel',
Chocobozzz's avatar
Chocobozzz committed
211
212
213
214
215
216
217
            description: 'super channel',
            isLocal
          },
          fixture: 'video_short2.webm',
          files: [
            {
              resolution: 240,
218
              size: 189000
Chocobozzz's avatar
Chocobozzz committed
219
220
221
            },
            {
              resolution: 360,
222
              size: 278000
Chocobozzz's avatar
Chocobozzz committed
223
224
225
            },
            {
              resolution: 480,
226
              size: 384000
Chocobozzz's avatar
Chocobozzz committed
227
228
229
            },
            {
              resolution: 720,
230
              size: 706000
Chocobozzz's avatar
Chocobozzz committed
231
            }
232
233
234
          ],
          thumbnailfile: 'thumbnail',
          previewfile: 'preview'
Chocobozzz's avatar
Chocobozzz committed
235
        }
Chocobozzz's avatar
Chocobozzz committed
236
237
238
239
240
241
242

        const res = await getVideosList(server.url)
        const videos = res.body.data
        expect(videos).to.be.an('array')
        expect(videos.length).to.equal(2)
        const video = videos[1]

Chocobozzz's avatar
Chocobozzz committed
243
        await completeVideoCheck(server.url, video, checkAttributes)
Chocobozzz's avatar
Chocobozzz committed
244
245
246
      }
    })

Chocobozzz's avatar
Chocobozzz committed
247
    it('Should upload two videos on server 3 and propagate on each server', async function () {
Chocobozzz's avatar
Chocobozzz committed
248
249
250
      this.timeout(45000)

      const videoAttributes1 = {
Chocobozzz's avatar
Chocobozzz committed
251
        name: 'my super name for server 3',
Chocobozzz's avatar
Chocobozzz committed
252
253
        category: 6,
        licence: 5,
Chocobozzz's avatar
Chocobozzz committed
254
        language: 'de',
Chocobozzz's avatar
Chocobozzz committed
255
        nsfw: true,
Chocobozzz's avatar
Chocobozzz committed
256
        description: 'my super description for server 3',
257
        support: 'my super support text for server 3',
Chocobozzz's avatar
Chocobozzz committed
258
259
260
261
262
263
        tags: [ 'tag1p3' ],
        fixture: 'video_short3.webm'
      }
      await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1)

      const videoAttributes2 = {
Chocobozzz's avatar
Chocobozzz committed
264
        name: 'my super name for server 3-2',
Chocobozzz's avatar
Chocobozzz committed
265
266
        category: 7,
        licence: 6,
Chocobozzz's avatar
Chocobozzz committed
267
        language: 'ko',
Chocobozzz's avatar
Chocobozzz committed
268
        nsfw: false,
Chocobozzz's avatar
Chocobozzz committed
269
        description: 'my super description for server 3-2',
270
        support: 'my super support text for server 3-2',
Chocobozzz's avatar
Chocobozzz committed
271
272
273
274
275
        tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
        fixture: 'video_short.webm'
      }
      await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)

276
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
277

Chocobozzz's avatar
Chocobozzz committed
278
      // All servers should have this video
Chocobozzz's avatar
Chocobozzz committed
279
      for (const server of servers) {
280
        const isLocal = server.url === 'http://localhost:' + servers[2].port
Chocobozzz's avatar
Chocobozzz committed
281
282
283
284
285
286
287
288
289
        const res = await getVideosList(server.url)

        const videos = res.body.data
        expect(videos).to.be.an('array')
        expect(videos.length).to.equal(4)

        // We not sure about the order of the two last uploads
        let video1 = null
        let video2 = null
Chocobozzz's avatar
Chocobozzz committed
290
        if (videos[2].name === 'my super name for server 3') {
Chocobozzz's avatar
Chocobozzz committed
291
292
293
294
295
296
297
          video1 = videos[2]
          video2 = videos[3]
        } else {
          video1 = videos[3]
          video2 = videos[2]
        }

Chocobozzz's avatar
Chocobozzz committed
298
299
300
301
        const checkAttributesVideo1 = {
          name: 'my super name for server 3',
          category: 6,
          licence: 5,
Chocobozzz's avatar
Chocobozzz committed
302
          language: 'de',
Chocobozzz's avatar
Chocobozzz committed
303
304
          nsfw: true,
          description: 'my super description for server 3',
305
          support: 'my super support text for server 3',
306
307
          account: {
            name: 'root',
308
            host: 'localhost:' + servers[2].port
309
          },
Chocobozzz's avatar
Chocobozzz committed
310
311
          isLocal,
          duration: 5,
312
          commentsEnabled: true,
313
          downloadEnabled: true,
Chocobozzz's avatar
Chocobozzz committed
314
315
316
          tags: [ 'tag1p3' ],
          privacy: VideoPrivacy.PUBLIC,
          channel: {
317
318
            displayName: 'Main root channel',
            name: 'root_channel',
Chocobozzz's avatar
Chocobozzz committed
319
320
321
322
323
324
325
326
327
328
            description: '',
            isLocal
          },
          fixture: 'video_short3.webm',
          files: [
            {
              resolution: 720,
              size: 292677
            }
          ]
Chocobozzz's avatar
Chocobozzz committed
329
        }
Chocobozzz's avatar
Chocobozzz committed
330
331
332
333
334
335
        await completeVideoCheck(server.url, video1, checkAttributesVideo1)

        const checkAttributesVideo2 = {
          name: 'my super name for server 3-2',
          category: 7,
          licence: 6,
Chocobozzz's avatar
Chocobozzz committed
336
          language: 'ko',
Chocobozzz's avatar
Chocobozzz committed
337
338
          nsfw: false,
          description: 'my super description for server 3-2',
339
          support: 'my super support text for server 3-2',
340
341
          account: {
            name: 'root',
342
            host: 'localhost:' + servers[2].port
343
          },
344
          commentsEnabled: true,
345
          downloadEnabled: true,
Chocobozzz's avatar
Chocobozzz committed
346
347
348
349
350
          isLocal,
          duration: 5,
          tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
          privacy: VideoPrivacy.PUBLIC,
          channel: {
351
352
            displayName: 'Main root channel',
            name: 'root_channel',
Chocobozzz's avatar
Chocobozzz committed
353
354
355
            description: '',
            isLocal
          },
Chocobozzz's avatar
Chocobozzz committed
356
          fixture: 'video_short.webm',
Chocobozzz's avatar
Chocobozzz committed
357
358
359
360
361
362
          files: [
            {
              resolution: 720,
              size: 218910
            }
          ]
Chocobozzz's avatar
Chocobozzz committed
363
        }
Chocobozzz's avatar
Chocobozzz committed
364
        await completeVideoCheck(server.url, video2, checkAttributesVideo2)
Chocobozzz's avatar
Chocobozzz committed
365
366
367
368
      }
    })
  })

Chocobozzz's avatar
Chocobozzz committed
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
  describe('It should list local videos', function () {
    it('Should list only local videos on server 1', async function () {
      const { body } = await getLocalVideos(servers[0].url)

      expect(body.total).to.equal(1)
      expect(body.data).to.be.an('array')
      expect(body.data.length).to.equal(1)
      expect(body.data[0].name).to.equal('my super name for server 1')
    })

    it('Should list only local videos on server 2', async function () {
      const { body } = await getLocalVideos(servers[1].url)

      expect(body.total).to.equal(1)
      expect(body.data).to.be.an('array')
      expect(body.data.length).to.equal(1)
      expect(body.data[0].name).to.equal('my super name for server 2')
    })

    it('Should list only local videos on server 3', async function () {
      const { body } = await getLocalVideos(servers[2].url)

      expect(body.total).to.equal(2)
      expect(body.data).to.be.an('array')
      expect(body.data.length).to.equal(2)
      expect(body.data[0].name).to.equal('my super name for server 3')
      expect(body.data[1].name).to.equal('my super name for server 3-2')
    })
  })

Chocobozzz's avatar
Chocobozzz committed
399
  describe('Should seed the uploaded video', function () {
Chocobozzz's avatar
Chocobozzz committed
400
    it('Should add the file 1 by asking server 3', async function () {
401
      this.timeout(10000)
Chocobozzz's avatar
Chocobozzz committed
402
403
404
405
406
407
408

      const res = await getVideosList(servers[2].url)

      const video = res.body.data[0]
      toRemove.push(res.body.data[2])
      toRemove.push(res.body.data[3])

Chocobozzz's avatar
Chocobozzz committed
409
410
411
      const res2 = await getVideo(servers[2].url, video.id)
      const videoDetails = res2.body

Chocobozzz's avatar
Chocobozzz committed
412
      const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
Chocobozzz's avatar
Chocobozzz committed
413
414
415
416
417
      expect(torrent.files).to.be.an('array')
      expect(torrent.files.length).to.equal(1)
      expect(torrent.files[0].path).to.exist.and.to.not.equal('')
    })

Chocobozzz's avatar
Chocobozzz committed
418
    it('Should add the file 2 by asking server 1', async function () {
419
      this.timeout(10000)
Chocobozzz's avatar
Chocobozzz committed
420
421
422
423

      const res = await getVideosList(servers[0].url)

      const video = res.body.data[1]
Chocobozzz's avatar
Chocobozzz committed
424
425
      const res2 = await getVideo(servers[0].url, video.id)
      const videoDetails = res2.body
Chocobozzz's avatar
Chocobozzz committed
426

Chocobozzz's avatar
Chocobozzz committed
427
      const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
Chocobozzz's avatar
Chocobozzz committed
428
429
430
431
432
      expect(torrent.files).to.be.an('array')
      expect(torrent.files.length).to.equal(1)
      expect(torrent.files[0].path).to.exist.and.to.not.equal('')
    })

Chocobozzz's avatar
Chocobozzz committed
433
    it('Should add the file 3 by asking server 2', async function () {
434
      this.timeout(10000)
Chocobozzz's avatar
Chocobozzz committed
435
436
437
438

      const res = await getVideosList(servers[1].url)

      const video = res.body.data[2]
Chocobozzz's avatar
Chocobozzz committed
439
440
      const res2 = await getVideo(servers[1].url, video.id)
      const videoDetails = res2.body
Chocobozzz's avatar
Chocobozzz committed
441

Chocobozzz's avatar
Chocobozzz committed
442
      const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
Chocobozzz's avatar
Chocobozzz committed
443
444
445
446
447
      expect(torrent.files).to.be.an('array')
      expect(torrent.files.length).to.equal(1)
      expect(torrent.files[0].path).to.exist.and.to.not.equal('')
    })

Chocobozzz's avatar
Chocobozzz committed
448
    it('Should add the file 3-2 by asking server 1', async function () {
449
      this.timeout(10000)
Chocobozzz's avatar
Chocobozzz committed
450
451
452
453

      const res = await getVideosList(servers[0].url)

      const video = res.body.data[3]
Chocobozzz's avatar
Chocobozzz committed
454
455
      const res2 = await getVideo(servers[0].url, video.id)
      const videoDetails = res2.body
Chocobozzz's avatar
Chocobozzz committed
456

Chocobozzz's avatar
Chocobozzz committed
457
      const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
Chocobozzz's avatar
Chocobozzz committed
458
459
460
461
      expect(torrent.files).to.be.an('array')
      expect(torrent.files.length).to.equal(1)
      expect(torrent.files[0].path).to.exist.and.to.not.equal('')
    })
Chocobozzz's avatar
Chocobozzz committed
462

Chocobozzz's avatar
Chocobozzz committed
463
    it('Should add the file 2 in 360p by asking server 1', async function () {
464
      this.timeout(10000)
Chocobozzz's avatar
Chocobozzz committed
465
466
467

      const res = await getVideosList(servers[0].url)

Chocobozzz's avatar
Chocobozzz committed
468
      const video = res.body.data.find(v => v.name === 'my super name for server 2')
Chocobozzz's avatar
Chocobozzz committed
469
470
471
      const res2 = await getVideo(servers[0].url, video.id)
      const videoDetails = res2.body

Chocobozzz's avatar
Chocobozzz committed
472
      const file = videoDetails.files.find(f => f.resolution.id === 360)
Chocobozzz's avatar
Chocobozzz committed
473
474
475
476
477
478
479
      expect(file).not.to.be.undefined

      const torrent = await webtorrentAdd(file.magnetUri)
      expect(torrent.files).to.be.an('array')
      expect(torrent.files.length).to.equal(1)
      expect(torrent.files[0].path).to.exist.and.to.not.equal('')
    })
Chocobozzz's avatar
Chocobozzz committed
480
481
482
  })

  describe('Should update video views, likes and dislikes', function () {
Chocobozzz's avatar
Chocobozzz committed
483
484
485
486
    let localVideosServer3 = []
    let remoteVideosServer1 = []
    let remoteVideosServer2 = []
    let remoteVideosServer3 = []
Chocobozzz's avatar
Chocobozzz committed
487
488
489

    before(async function () {
      const res1 = await getVideosList(servers[0].url)
Chocobozzz's avatar
Chocobozzz committed
490
      remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
Chocobozzz's avatar
Chocobozzz committed
491
492

      const res2 = await getVideosList(servers[1].url)
Chocobozzz's avatar
Chocobozzz committed
493
      remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
Chocobozzz's avatar
Chocobozzz committed
494
495

      const res3 = await getVideosList(servers[2].url)
Chocobozzz's avatar
Chocobozzz committed
496
497
      localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
      remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
Chocobozzz's avatar
Chocobozzz committed
498
499
500
    })

    it('Should view multiple videos on owned servers', async function () {
Chocobozzz's avatar
Chocobozzz committed
501
      this.timeout(30000)
Chocobozzz's avatar
Chocobozzz committed
502

503
      await viewVideo(servers[2].url, localVideosServer3[0])
504
      await wait(1000)
505
506

      await viewVideo(servers[2].url, localVideosServer3[0])
507
      await viewVideo(servers[2].url, localVideosServer3[1])
508

509
      await wait(1000)
510

511
512
513
514
      await Promise.all([
        viewVideo(servers[2].url, localVideosServer3[0]),
        viewVideo(servers[2].url, localVideosServer3[0])
      ])
Chocobozzz's avatar
Chocobozzz committed
515

516
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
517

Chocobozzz's avatar
Chocobozzz committed
518
519
520
      // Wait the repeatable job
      await wait(6000)

Chocobozzz's avatar
Chocobozzz committed
521
522
523
524
      for (const server of servers) {
        const res = await getVideosList(server.url)

        const videos = res.body.data
Chocobozzz's avatar
Chocobozzz committed
525
526
        const video0 = videos.find(v => v.uuid === localVideosServer3[0])
        const video1 = videos.find(v => v.uuid === localVideosServer3[1])
Chocobozzz's avatar
Chocobozzz committed
527

Chocobozzz's avatar
Chocobozzz committed
528
529
        expect(video0.views).to.equal(3)
        expect(video1.views).to.equal(1)
Chocobozzz's avatar
Chocobozzz committed
530
531
532
533
      }
    })

    it('Should view multiple videos on each servers', async function () {
Chocobozzz's avatar
Chocobozzz committed
534
      this.timeout(45000)
Chocobozzz's avatar
Chocobozzz committed
535
536

      const tasks: Promise<any>[] = []
Chocobozzz's avatar
Chocobozzz committed
537
538
539
540
541
542
543
544
545
546
      tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
      tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
      tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
      tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
      tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
      tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
      tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
      tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
      tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
      tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
Chocobozzz's avatar
Chocobozzz committed
547
548
549

      await Promise.all(tasks)

550
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
551

Chocobozzz's avatar
Chocobozzz committed
552
      // Wait the repeatable job
Chocobozzz's avatar
Chocobozzz committed
553
      await wait(16000)
Chocobozzz's avatar
Chocobozzz committed
554

Chocobozzz's avatar
Chocobozzz committed
555
556
557
558
559
560
561
562
563
564
      let baseVideos = null

      for (const server of servers) {
        const res = await getVideosList(server.url)

        const videos = res.body.data

        // Initialize base videos for future comparisons
        if (baseVideos === null) {
          baseVideos = videos
Chocobozzz's avatar
Chocobozzz committed
565
          continue
Chocobozzz's avatar
Chocobozzz committed
566
567
568
569
570
571
572
573
574
575
        }

        for (const baseVideo of baseVideos) {
          const sameVideo = videos.find(video => video.name === baseVideo.name)
          expect(baseVideo.views).to.equal(sameVideo.views)
        }
      }
    })

    it('Should like and dislikes videos on different services', async function () {
576
      this.timeout(20000)
Chocobozzz's avatar
Chocobozzz committed
577

Chocobozzz's avatar
Chocobozzz committed
578
      await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
579
      await wait(500)
Chocobozzz's avatar
Chocobozzz committed
580
      await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
581
      await wait(500)
Chocobozzz's avatar
Chocobozzz committed
582
583
      await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
      await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
584
      await wait(500)
Chocobozzz's avatar
Chocobozzz committed
585
586
      await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
      await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
587
      await wait(500)
Chocobozzz's avatar
Chocobozzz committed
588
      await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
Chocobozzz's avatar
Chocobozzz committed
589

590
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
591
592
593
594
595
596
597
598
599
600

      let baseVideos = null
      for (const server of servers) {
        const res = await getVideosList(server.url)

        const videos = res.body.data

        // Initialize base videos for future comparisons
        if (baseVideos === null) {
          baseVideos = videos
Chocobozzz's avatar
Chocobozzz committed
601
          continue
Chocobozzz's avatar
Chocobozzz committed
602
603
        }

Chocobozzz's avatar
Chocobozzz committed
604
        for (const baseVideo of baseVideos) {
Chocobozzz's avatar
Chocobozzz committed
605
606
607
          const sameVideo = videos.find(video => video.name === baseVideo.name)
          expect(baseVideo.likes).to.equal(sameVideo.likes)
          expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
Chocobozzz's avatar
Chocobozzz committed
608
        }
Chocobozzz's avatar
Chocobozzz committed
609
610
611
612
613
      }
    })
  })

  describe('Should manipulate these videos', function () {
Chocobozzz's avatar
Chocobozzz committed
614
    it('Should update the video 3 by asking server 3', async function () {
615
      this.timeout(10000)
Chocobozzz's avatar
Chocobozzz committed
616
617
618
619
620

      const attributes = {
        name: 'my super video updated',
        category: 10,
        licence: 7,
Chocobozzz's avatar
Chocobozzz committed
621
        language: 'fr',
Chocobozzz's avatar
Chocobozzz committed
622
623
        nsfw: true,
        description: 'my super description updated',
624
        support: 'my super support text updated',
625
626
        tags: [ 'tag_up_1', 'tag_up_2' ],
        thumbnailfile: 'thumbnail.jpg',
627
        originallyPublishedAt: '2019-02-11T13:38:14.449Z',
628
        previewfile: 'preview.jpg'
Chocobozzz's avatar
Chocobozzz committed
629
630
631
632
      }

      await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)

633
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
634
635
    })

Chocobozzz's avatar
Chocobozzz committed
636
    it('Should have the video 3 updated on each server', async function () {
637
      this.timeout(10000)
Chocobozzz's avatar
Chocobozzz committed
638
639
640
641
642
643
644
645

      for (const server of servers) {
        const res = await getVideosList(server.url)

        const videos = res.body.data
        const videoUpdated = videos.find(video => video.name === 'my super video updated')
        expect(!!videoUpdated).to.be.true

646
        const isLocal = server.url === 'http://localhost:' + servers[2].port
Chocobozzz's avatar
Chocobozzz committed
647
648
649
650
        const checkAttributes = {
          name: 'my super video updated',
          category: 10,
          licence: 7,
Chocobozzz's avatar
Chocobozzz committed
651
          language: 'fr',
Chocobozzz's avatar
Chocobozzz committed
652
653
          nsfw: true,
          description: 'my super description updated',
654
          support: 'my super support text updated',
655
          originallyPublishedAt: '2019-02-11T13:38:14.449Z',
656
657
          account: {
            name: 'root',
658
            host: 'localhost:' + servers[2].port
659
          },
Chocobozzz's avatar
Chocobozzz committed
660
661
          isLocal,
          duration: 5,
662
          commentsEnabled: true,
663
          downloadEnabled: true,
Chocobozzz's avatar
Chocobozzz committed
664
665
666
          tags: [ 'tag_up_1', 'tag_up_2' ],
          privacy: VideoPrivacy.PUBLIC,
          channel: {
667
668
            displayName: 'Main root channel',
            name: 'root_channel',
Chocobozzz's avatar
Chocobozzz committed
669
670
671
672
673
674
675
676
677
            description: '',
            isLocal
          },
          fixture: 'video_short3.webm',
          files: [
            {
              resolution: 720,
              size: 292677
            }
678
679
680
          ],
          thumbnailfile: 'thumbnail',
          previewfile: 'preview'
Chocobozzz's avatar
Chocobozzz committed
681
682
        }
        await completeVideoCheck(server.url, videoUpdated, checkAttributes)
Chocobozzz's avatar
Chocobozzz committed
683
684
685
      }
    })

Chocobozzz's avatar
Chocobozzz committed
686
    it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
687
      this.timeout(10000)
Chocobozzz's avatar
Chocobozzz committed
688
689
690
691

      await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
      await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)

692
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
693
694
    })

695
696
697
698
699
700
701
    it('Should not have files of videos 3 and 3-2 on each server', async function () {
      for (const server of servers) {
        await checkVideoFilesWereRemoved(toRemove[0].uuid, server.serverNumber)
        await checkVideoFilesWereRemoved(toRemove[1].uuid, server.serverNumber)
      }
    })

Chocobozzz's avatar
Chocobozzz committed
702
    it('Should have videos 1 and 3 on each server', async function () {
Chocobozzz's avatar
Chocobozzz committed
703
704
705
706
707
708
709
710
711
712
713
714
      for (const server of servers) {
        const res = await getVideosList(server.url)

        const videos = res.body.data
        expect(videos).to.be.an('array')
        expect(videos.length).to.equal(2)
        expect(videos[0].name).not.to.equal(videos[1].name)
        expect(videos[0].name).not.to.equal(toRemove[0].name)
        expect(videos[1].name).not.to.equal(toRemove[0].name)
        expect(videos[0].name).not.to.equal(toRemove[1].name)
        expect(videos[1].name).not.to.equal(toRemove[1].name)

Chocobozzz's avatar
Chocobozzz committed
715
        videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
Chocobozzz's avatar
Chocobozzz committed
716
717
718
      }
    })

Chocobozzz's avatar
Chocobozzz committed
719
    it('Should get the same video by UUID on each server', async function () {
Chocobozzz's avatar
Chocobozzz committed
720
721
722
723
724
725
726
727
      let baseVideo = null
      for (const server of servers) {
        const res = await getVideo(server.url, videoUUID)

        const video = res.body

        if (baseVideo === null) {
          baseVideo = video
Chocobozzz's avatar
Chocobozzz committed
728
          continue
Chocobozzz's avatar
Chocobozzz committed
729
730
731
732
        }

        expect(baseVideo.name).to.equal(video.name)
        expect(baseVideo.uuid).to.equal(video.uuid)
Chocobozzz's avatar
Chocobozzz committed
733
734
735
        expect(baseVideo.category.id).to.equal(video.category.id)
        expect(baseVideo.language.id).to.equal(video.language.id)
        expect(baseVideo.licence.id).to.equal(video.licence.id)
Chocobozzz's avatar
Chocobozzz committed
736
        expect(baseVideo.nsfw).to.equal(video.nsfw)
737
738
739
740
        expect(baseVideo.account.name).to.equal(video.account.name)
        expect(baseVideo.account.displayName).to.equal(video.account.displayName)
        expect(baseVideo.account.url).to.equal(video.account.url)
        expect(baseVideo.account.host).to.equal(video.account.host)
Chocobozzz's avatar
Chocobozzz committed
741
742
743
744
        expect(baseVideo.tags).to.deep.equal(video.tags)
      }
    })

Chocobozzz's avatar
Chocobozzz committed
745
    it('Should get the preview from each server', async function () {
Chocobozzz's avatar
Chocobozzz committed
746
747
748
749
      for (const server of servers) {
        const res = await getVideo(server.url, videoUUID)
        const video = res.body

Chocobozzz's avatar
Chocobozzz committed
750
        await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
Chocobozzz's avatar
Chocobozzz committed
751
752
753
754
      }
    })
  })

Chocobozzz's avatar
Chocobozzz committed
755
  describe('Should comment these videos', function () {
Chocobozzz's avatar
Chocobozzz committed
756
757
    let childOfFirstChild: VideoCommentThreadTree

Chocobozzz's avatar
Chocobozzz committed
758
759
760
761
762
763
764
765
766
767
768
769
770
    it('Should add comment (threads and replies)', async function () {
      this.timeout(25000)

      {
        const text = 'my super first comment'
        await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, text)
      }

      {
        const text = 'my super second comment'
        await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text)
      }

771
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
772
773
774
775
776
777
778
779
780

      {
        const res = await getVideoCommentThreads(servers[1].url, videoUUID, 0, 5)
        const threadId = res.body.data.find(c => c.text === 'my super first comment').id

        const text = 'my super answer to thread 1'
        await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text)
      }

781
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796

      {
        const res1 = await getVideoCommentThreads(servers[2].url, videoUUID, 0, 5)
        const threadId = res1.body.data.find(c => c.text === 'my super first comment').id

        const res2 = await getVideoThreadComments(servers[2].url, videoUUID, threadId)
        const childCommentId = res2.body.children[0].comment.id

        const text3 = 'my second answer to thread 1'
        await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, threadId, text3)

        const text2 = 'my super answer to answer of thread 1'
        await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2)
      }

797
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
    })

    it('Should have these threads', async function () {
      for (const server of servers) {
        const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)

        expect(res.body.total).to.equal(2)
        expect(res.body.data).to.be.an('array')
        expect(res.body.data).to.have.lengthOf(2)

        {
          const comment: VideoComment = res.body.data.find(c => c.text === 'my super first comment')
          expect(comment).to.not.be.undefined
          expect(comment.inReplyToCommentId).to.be.null
          expect(comment.account.name).to.equal('root')
813
          expect(comment.account.host).to.equal('localhost:' + servers[0].port)
Chocobozzz's avatar
Chocobozzz committed
814
815
816
817
818
819
820
821
822
823
          expect(comment.totalReplies).to.equal(3)
          expect(dateIsValid(comment.createdAt as string)).to.be.true
          expect(dateIsValid(comment.updatedAt as string)).to.be.true
        }

        {
          const comment: VideoComment = res.body.data.find(c => c.text === 'my super second comment')
          expect(comment).to.not.be.undefined
          expect(comment.inReplyToCommentId).to.be.null
          expect(comment.account.name).to.equal('root')
824
          expect(comment.account.host).to.equal('localhost:' + servers[2].port)
Chocobozzz's avatar
Chocobozzz committed
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
          expect(comment.totalReplies).to.equal(0)
          expect(dateIsValid(comment.createdAt as string)).to.be.true
          expect(dateIsValid(comment.updatedAt as string)).to.be.true
        }
      }
    })

    it('Should have these comments', async function () {
      for (const server of servers) {
        const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
        const threadId = res1.body.data.find(c => c.text === 'my super first comment').id

        const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)

        const tree: VideoCommentThreadTree = res2.body
        expect(tree.comment.text).equal('my super first comment')
        expect(tree.comment.account.name).equal('root')
842
        expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
Chocobozzz's avatar
Chocobozzz committed
843
844
845
846
847
        expect(tree.children).to.have.lengthOf(2)

        const firstChild = tree.children[0]
        expect(firstChild.comment.text).to.equal('my super answer to thread 1')
        expect(firstChild.comment.account.name).equal('root')
848
        expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
Chocobozzz's avatar
Chocobozzz committed
849
850
        expect(firstChild.children).to.have.lengthOf(1)

Chocobozzz's avatar
Chocobozzz committed
851
        childOfFirstChild = firstChild.children[0]
Chocobozzz's avatar
Chocobozzz committed
852
853
        expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
        expect(childOfFirstChild.comment.account.name).equal('root')
854
        expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
Chocobozzz's avatar
Chocobozzz committed
855
856
857
858
859
        expect(childOfFirstChild.children).to.have.lengthOf(0)

        const secondChild = tree.children[1]
        expect(secondChild.comment.text).to.equal('my second answer to thread 1')
        expect(secondChild.comment.account.name).equal('root')
860
        expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
Chocobozzz's avatar
Chocobozzz committed
861
862
863
        expect(secondChild.children).to.have.lengthOf(0)
      }
    })
864

Chocobozzz's avatar
Chocobozzz committed
865
866
867
868
869
    it('Should delete a reply', async function () {
      this.timeout(10000)

      await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id)

870
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
    })

    it('Should not have this comment anymore', async function () {
      for (const server of servers) {
        const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
        const threadId = res1.body.data.find(c => c.text === 'my super first comment').id

        const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)

        const tree: VideoCommentThreadTree = res2.body
        expect(tree.comment.text).equal('my super first comment')

        const firstChild = tree.children[0]
        expect(firstChild.comment.text).to.equal('my super answer to thread 1')
        expect(firstChild.children).to.have.lengthOf(0)

        const secondChild = tree.children[1]
        expect(secondChild.comment.text).to.equal('my second answer to thread 1')
      }
    })

Chocobozzz's avatar
Chocobozzz committed
892
893
894
    it('Should delete the thread comments', async function () {
      this.timeout(10000)

895
896
897
      const res = await getVideoCommentThreads(servers[ 0 ].url, videoUUID, 0, 5)
      const threadId = res.body.data.find(c => c.text === 'my super first comment').id
      await deleteVideoComment(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, threadId)
Chocobozzz's avatar
Chocobozzz committed
898

899
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
900
901
    })

902
    it('Should have the threads deleted on other servers too', async function () {
Chocobozzz's avatar
Chocobozzz committed
903
904
905
906
907
908
909
910
911
912
913
914
      for (const server of servers) {
        const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)

        expect(res.body.total).to.equal(1)
        expect(res.body.data).to.be.an('array')
        expect(res.body.data).to.have.lengthOf(1)

        {
          const comment: VideoComment = res.body.data[0]
          expect(comment).to.not.be.undefined
          expect(comment.inReplyToCommentId).to.be.null
          expect(comment.account.name).to.equal('root')
915
          expect(comment.account.host).to.equal('localhost:' + servers[2].port)
Chocobozzz's avatar
Chocobozzz committed
916
917
918
919
920
921
922
          expect(comment.totalReplies).to.equal(0)
          expect(dateIsValid(comment.createdAt as string)).to.be.true
          expect(dateIsValid(comment.updatedAt as string)).to.be.true
        }
      }
    })

923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
    it('Should delete a remote thread by the origin server', async function () {
      const res = await getVideoCommentThreads(servers[ 0 ].url, videoUUID, 0, 5)
      const threadId = res.body.data.find(c => c.text === 'my super second comment').id
      await deleteVideoComment(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, threadId)

      await waitJobs(servers)
    })

    it('Should have the threads deleted on other servers too', async function () {
      for (const server of servers) {
        const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)

        expect(res.body.total).to.equal(0)
        expect(res.body.data).to.have.lengthOf(0)
      }
    })

940
    it('Should disable comments and download', async function () {
941
942
943
      this.timeout(20000)

      const attributes = {
944
945
        commentsEnabled: false,
        downloadEnabled: false
946
947
948
949
      }

      await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)

950
      await waitJobs(servers)
951
952
953
954

      for (const server of servers) {
        const res = await getVideo(server.url, videoUUID)
        expect(res.body.commentsEnabled).to.be.false
955
        expect(res.body.downloadEnabled).to.be.false
956
957
958
959
960

        const text = 'my super forbidden comment'
        await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, 409)
      }
    })
Chocobozzz's avatar
Chocobozzz committed
961
962
  })

Chocobozzz's avatar
Chocobozzz committed
963
964
  describe('With minimum parameters', function () {
    it('Should upload and propagate the video', async function () {
965
      this.timeout(60000)
Chocobozzz's avatar
Chocobozzz committed
966
967
968
969
970
971
972
973
974
975
976

      const path = '/api/v1/videos/upload'

      const req = request(servers[1].url)
        .post(path)
        .set('Accept', 'application/json')
        .set('Authorization', 'Bearer ' + servers[1].accessToken)
        .field('name', 'minimum parameters')
        .field('privacy', '1')
        .field('channelId', '1')

Chocobozzz's avatar
Chocobozzz committed
977
      const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
Chocobozzz's avatar
Chocobozzz committed
978
979
980
981

      await req.attach('videofile', filePath)
        .expect(200)

982
      await waitJobs(servers)
Chocobozzz's avatar
Chocobozzz committed
983
984
985
986
987

      for (const server of servers) {
        const res = await getVideosList(server.url)
        const video = res.body.data.find(v => v.name === 'minimum parameters')

988
        const isLocal = server.url === 'http://localhost:' + servers[1].port
Chocobozzz's avatar
Chocobozzz committed
989
990
991
992
993
994
995
        const checkAttributes = {
          name: 'minimum parameters',
          category: null,
          licence: null,
          language: null,
          nsfw: false,
          description: null,
996
          support: null,
997
998
          account: {
            name: 'root',
999
            host: 'localhost:' + servers[1].port
1000
          },
Chocobozzz's avatar
Chocobozzz committed
1001
1002
          isLocal,
          duration: 5,
1003
          commentsEnabled: false,
1004
          downloadEnabled: true,
Chocobozzz's avatar
Chocobozzz committed
1005
1006
1007
          tags: [ ],
          privacy: VideoPrivacy.PUBLIC,
          channel: {
1008
1009
            displayName: 'Main root channel',
            name: 'root_channel',
Chocobozzz's avatar
Chocobozzz committed
1010
1011
1012
1013
1014
1015
1016
            description: '',
            isLocal
          },
          fixture: 'video_short.webm',
          files: [
            {
              resolution: 720,
Chocobozzz's avatar
Chocobozzz committed
1017
              size: 72000
Chocobozzz's avatar
Chocobozzz committed
1018
1019
1020
            },
            {
              resolution: 480,