]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-comments.ts
Merge remote-tracking branch 'weblate/develop' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-comments.ts
index 141a80690a184cd7d9a376b235f1f8f24b104a37..615e0ea45a5fe1658d62ef9627233d3d0fe754a6 100644 (file)
@@ -67,6 +67,7 @@ describe('Test video comments', function () {
       const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
 
       expect(res.body.total).to.equal(0)
+      expect(res.body.totalNotDeletedComments).to.equal(0)
       expect(res.body.data).to.be.an('array')
       expect(res.body.data).to.have.lengthOf(0)
     })
@@ -94,6 +95,7 @@ describe('Test video comments', function () {
       const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
 
       expect(res.body.total).to.equal(1)
+      expect(res.body.totalNotDeletedComments).to.equal(1)
       expect(res.body.data).to.be.an('array')
       expect(res.body.data).to.have.lengthOf(1)
 
@@ -172,6 +174,7 @@ describe('Test video comments', function () {
       const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt')
 
       expect(res.body.total).to.equal(3)
+      expect(res.body.totalNotDeletedComments).to.equal(6)
       expect(res.body.data).to.be.an('array')
       expect(res.body.data).to.have.lengthOf(3)
 
@@ -186,26 +189,35 @@ describe('Test video comments', function () {
     it('Should delete a reply', async function () {
       await deleteVideoComment(server.url, server.accessToken, videoId, replyToDeleteId)
 
-      const res = await getVideoThreadComments(server.url, videoUUID, threadId)
-
-      const tree: VideoCommentThreadTree = res.body
-      expect(tree.comment.text).equal('my super first comment')
-      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.children).to.have.lengthOf(1)
+      {
+        const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt')
 
-      const childOfFirstChild = firstChild.children[0]
-      expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
-      expect(childOfFirstChild.children).to.have.lengthOf(0)
+        expect(res.body.total).to.equal(3)
+        expect(res.body.totalNotDeletedComments).to.equal(5)
+      }
 
-      const deletedChildOfFirstChild = tree.children[1]
-      expect(deletedChildOfFirstChild.comment.text).to.equal('')
-      expect(deletedChildOfFirstChild.comment.isDeleted).to.be.true
-      expect(deletedChildOfFirstChild.comment.deletedAt).to.not.be.null
-      expect(deletedChildOfFirstChild.comment.account).to.be.null
-      expect(deletedChildOfFirstChild.children).to.have.lengthOf(0)
+      {
+        const res = await getVideoThreadComments(server.url, videoUUID, threadId)
+
+        const tree: VideoCommentThreadTree = res.body
+        expect(tree.comment.text).equal('my super first comment')
+        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.children).to.have.lengthOf(1)
+
+        const childOfFirstChild = firstChild.children[0]
+        expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
+        expect(childOfFirstChild.children).to.have.lengthOf(0)
+
+        const deletedChildOfFirstChild = tree.children[1]
+        expect(deletedChildOfFirstChild.comment.text).to.equal('')
+        expect(deletedChildOfFirstChild.comment.isDeleted).to.be.true
+        expect(deletedChildOfFirstChild.comment.deletedAt).to.not.be.null
+        expect(deletedChildOfFirstChild.comment.account).to.be.null
+        expect(deletedChildOfFirstChild.children).to.have.lengthOf(0)
+      }
     })
 
     it('Should delete a complete thread', async function () {