aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/multiple-pods.js60
-rw-r--r--server/tests/api/single-pod.js11
2 files changed, 70 insertions, 1 deletions
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js
index df12ba0e9..871db54be 100644
--- a/server/tests/api/multiple-pods.js
+++ b/server/tests/api/multiple-pods.js
@@ -3,6 +3,7 @@
3const chai = require('chai') 3const chai = require('chai')
4const each = require('async/each') 4const each = require('async/each')
5const expect = chai.expect 5const expect = chai.expect
6const parallel = require('async/parallel')
6const series = require('async/series') 7const series = require('async/series')
7const WebTorrent = require('webtorrent') 8const WebTorrent = require('webtorrent')
8const webtorrent = new WebTorrent() 9const webtorrent = new WebTorrent()
@@ -375,6 +376,63 @@ describe('Test multiple pods', function () {
375 }) 376 })
376 }) 377 })
377 378
379 describe('Should update video views', function () {
380 let videoId1
381 let videoId2
382
383 before(function (done) {
384 videosUtils.getVideosList(servers[2].url, function (err, res) {
385 if (err) throw err
386
387 const videos = res.body.data.filter(video => video.isLocal === true)
388 videoId1 = videos[0].id
389 videoId2 = videos[1].id
390
391 done()
392 })
393 })
394
395 it('Should views multiple videos on owned servers', function (done) {
396 this.timeout(30000)
397
398 parallel([
399 function (callback) {
400 videosUtils.getVideo(servers[2].url, videoId1, callback)
401 },
402
403 function (callback) {
404 videosUtils.getVideo(servers[2].url, videoId1, callback)
405 },
406
407 function (callback) {
408 videosUtils.getVideo(servers[2].url, videoId1, callback)
409 },
410
411 function (callback) {
412 videosUtils.getVideo(servers[2].url, videoId2, callback)
413 }
414 ], function (err) {
415 if (err) throw err
416
417 setTimeout(done, 22000)
418 })
419 })
420
421 it('Should have views updated on each pod', function (done) {
422 each(servers, function (server, callback) {
423 videosUtils.getVideosList(server.url, function (err, res) {
424 if (err) throw err
425
426 const videos = res.body.data
427 expect(videos.find(video => video.views === 3)).to.be.exist
428 expect(videos.find(video => video.views === 1)).to.be.exist
429
430 callback()
431 })
432 }, done)
433 })
434 })
435/*
378 describe('Should manipulate these videos', function () { 436 describe('Should manipulate these videos', function () {
379 it('Should update the video 3 by asking pod 3', function (done) { 437 it('Should update the video 3 by asking pod 3', function (done) {
380 this.timeout(15000) 438 this.timeout(15000)
@@ -462,7 +520,7 @@ describe('Test multiple pods', function () {
462 }, done) 520 }, done)
463 }) 521 })
464 }) 522 })
465 523*/
466 after(function (done) { 524 after(function (done) {
467 servers.forEach(function (server) { 525 servers.forEach(function (server) {
468 process.kill(-server.app.pid) 526 process.kill(-server.app.pid)
diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js
index 83a2b4411..40c33686f 100644
--- a/server/tests/api/single-pod.js
+++ b/server/tests/api/single-pod.js
@@ -129,6 +129,17 @@ describe('Test a single pod', function () {
129 }) 129 })
130 }) 130 })
131 131
132 it('Should have the views updated', function (done) {
133 videosUtils.getVideo(server.url, videoId, function (err, res) {
134 if (err) throw err
135
136 const video = res.body
137 expect(video.views).to.equal(1)
138
139 done()
140 })
141 })
142
132 it('Should search the video by name by default', function (done) { 143 it('Should search the video by name by default', function (done) {
133 videosUtils.searchVideo(server.url, 'my', function (err, res) { 144 videosUtils.searchVideo(server.url, 'my', function (err, res) {
134 if (err) throw err 145 if (err) throw err