]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/single-pod.js
Try to fix travis build
[github/Chocobozzz/PeerTube.git] / server / tests / api / single-pod.js
index 66b762f82a7766f7bbc2eadbfc29a5e098eb8a10..2ac83bbf415a8369515ab98fd3a3cb28d8fd04c4 100644 (file)
@@ -83,6 +83,7 @@ describe('Test a single pod', function () {
       expect(video.isLocal).to.be.true
       expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
       expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+      expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
 
       videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
         if (err) throw err
@@ -117,6 +118,7 @@ describe('Test a single pod', function () {
       expect(video.isLocal).to.be.true
       expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
       expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+      expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
 
       videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
         if (err) throw err
@@ -143,6 +145,7 @@ describe('Test a single pod', function () {
       expect(video.isLocal).to.be.true
       expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
       expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+      expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
 
       videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
         if (err) throw err
@@ -170,6 +173,7 @@ describe('Test a single pod', function () {
   //     expect(video.isLocal).to.be.true
   //     expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
   //     expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+  //     expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
 
   //     videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
   //       if (err) throw err
@@ -196,6 +200,7 @@ describe('Test a single pod', function () {
       expect(video.isLocal).to.be.true
       expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
       expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+      expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
 
       videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
         if (err) throw err
@@ -495,10 +500,104 @@ describe('Test a single pod', function () {
       expect(videos[2].name === 'video_short2.webm name')
       expect(videos[3].name === 'video_short3.webm name')
 
+      videoId = videos[3].id
+
       done()
     })
   })
 
+  it('Should update a video', function (done) {
+    const name = 'my super video updated'
+    const description = 'my super description updated'
+    const tags = [ 'tagup1', 'tagup2' ]
+
+    videosUtils.updateVideo(server.url, server.accessToken, videoId, name, description, tags, done)
+  })
+
+  it('Should have the video updated', function (done) {
+    this.timeout(60000)
+
+    videosUtils.getVideo(server.url, videoId, function (err, res) {
+      if (err) throw err
+
+      const video = res.body
+
+      expect(video.name).to.equal('my super video updated')
+      expect(video.description).to.equal('my super description updated')
+      expect(video.podHost).to.equal('localhost:9001')
+      expect(video.author).to.equal('root')
+      expect(video.isLocal).to.be.true
+      expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
+      expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+      expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
+
+      videosUtils.testVideoImage(server.url, 'video_short3.webm', video.thumbnailPath, function (err, test) {
+        if (err) throw err
+        expect(test).to.equal(true)
+
+        videoId = video.id
+
+        webtorrent.add(video.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('')
+
+          done()
+        })
+      })
+    })
+  })
+
+  it('Should update only the tags of a video', function (done) {
+    const tags = [ 'tag1', 'tag2', 'supertag' ]
+
+    videosUtils.updateVideo(server.url, server.accessToken, videoId, null, null, tags, function (err) {
+      if (err) throw err
+
+      videosUtils.getVideo(server.url, videoId, function (err, res) {
+        if (err) throw err
+
+        const video = res.body
+
+        expect(video.name).to.equal('my super video updated')
+        expect(video.description).to.equal('my super description updated')
+        expect(video.podHost).to.equal('localhost:9001')
+        expect(video.author).to.equal('root')
+        expect(video.isLocal).to.be.true
+        expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ])
+        expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+        expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
+
+        done()
+      })
+    })
+  })
+
+  it('Should update only the description of a video', function (done) {
+    const description = 'hello everybody'
+
+    videosUtils.updateVideo(server.url, server.accessToken, videoId, null, description, null, function (err) {
+      if (err) throw err
+
+      videosUtils.getVideo(server.url, videoId, function (err, res) {
+        if (err) throw err
+
+        const video = res.body
+
+        expect(video.name).to.equal('my super video updated')
+        expect(video.description).to.equal('hello everybody')
+        expect(video.podHost).to.equal('localhost:9001')
+        expect(video.author).to.equal('root')
+        expect(video.isLocal).to.be.true
+        expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ])
+        expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+        expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
+
+        done()
+      })
+    })
+  })
+
   after(function (done) {
     process.kill(-server.app.pid)