+ callback()
+ })
+ }, done)
+ })
+ })
+
+ it('Should like and dislikes videos on different services', function (done) {
+ this.timeout(30000)
+
+ parallel([
+ function (callback) {
+ videosUtils.rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'like', callback)
+ },
+
+ function (callback) {
+ videosUtils.rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'dislike', callback)
+ },
+
+ function (callback) {
+ videosUtils.rateVideo(servers[0].url, servers[0].accessToken, remoteVideosPod1[0], 'like', callback)
+ },
+
+ function (callback) {
+ videosUtils.rateVideo(servers[2].url, servers[2].accessToken, localVideosPod3[1], 'like', callback)
+ },
+
+ function (callback) {
+ videosUtils.rateVideo(servers[2].url, servers[2].accessToken, localVideosPod3[1], 'dislike', callback)
+ },
+
+ function (callback) {
+ videosUtils.rateVideo(servers[2].url, servers[2].accessToken, remoteVideosPod3[1], 'dislike', callback)
+ },
+
+ function (callback) {
+ videosUtils.rateVideo(servers[2].url, servers[2].accessToken, remoteVideosPod3[0], 'like', callback)
+ },
+
+ function (callback) {
+ setTimeout(callback, 22000)
+ }
+ ], function (err) {
+ if (err) throw err
+
+ let baseVideos = null
+ eachSeries(servers, function (server, callback) {
+ videosUtils.getVideosList(server.url, function (err, res) {
+ if (err) throw err
+
+ const videos = res.body.data
+
+ // Initialize base videos for future comparisons
+ if (baseVideos === null) {
+ baseVideos = videos
+ return callback()
+ }
+
+ baseVideos.forEach(baseVideo => {
+ const sameVideo = videos.find(video => video.name === baseVideo.name)
+ expect(baseVideo.likes).to.equal(sameVideo.likes)
+ expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
+ })
+
+ callback()
+ })
+ }, done)
+ })
+ })
+ })
+
+ describe('Should manipulate these videos', function () {
+ it('Should update the video 3 by asking pod 3', function (done) {
+ this.timeout(15000)
+
+ const attributes = {
+ name: 'my super video updated',
+ category: 10,
+ licence: 7,
+ language: 13,
+ nsfw: true,
+ description: 'my super description updated',
+ tags: [ 'tagup1', 'tagup2' ]
+ }
+ videosUtils.updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes, function (err) {
+ if (err) throw err
+
+ setTimeout(done, 11000)
+ })
+ })
+
+ it('Should have the video 3 updated on each pod', function (done) {
+ this.timeout(200000)
+
+ each(servers, function (server, callback) {
+ // Avoid "duplicate torrent" errors
+ const webtorrent = new WebTorrent()
+
+ videosUtils.getVideosList(server.url, function (err, res) {
+ if (err) throw err
+
+ const videos = res.body.data
+ const videoUpdated = videos.find(function (video) {
+ return video.name === 'my super video updated'
+ })
+
+ expect(!!videoUpdated).to.be.true
+ expect(videoUpdated.category).to.equal(10)
+ expect(videoUpdated.categoryLabel).to.equal('Entertainment')
+ expect(videoUpdated.licence).to.equal(7)
+ expect(videoUpdated.licenceLabel).to.equal('Public Domain Dedication')
+ expect(videoUpdated.language).to.equal(13)
+ expect(videoUpdated.languageLabel).to.equal('French')
+ expect(videoUpdated.nsfw).to.be.ok
+ expect(videoUpdated.description).to.equal('my super description updated')
+ expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
+ expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true
+
+ const file = videoUpdated.files[0]
+ const magnetUri = file.magnetUri
+ expect(file.magnetUri).to.exist
+ expect(file.resolution).to.equal(0)
+ expect(file.resolutionLabel).to.equal('original')
+ expect(file.size).to.equal(292677)
+
+ videosUtils.testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath, function (err, test) {
+ if (err) throw err
+ expect(test).to.equal(true)
+
+ webtorrent.add(videoUpdated.files[0].magnetUri, function (torrent) {
+ expect(torrent.files).to.exist
+ expect(torrent.files.length).to.equal(1)
+ expect(torrent.files[0].path).to.exist.and.to.not.equal('')
+
+ callback()
+ })
+ })
+ })
+ }, done)
+ })
+
+ it('Should remove the videos 3 and 3-2 by asking pod 3', function (done) {