aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-19 09:50:13 +0100
committerChocobozzz <me@florianbigard.com>2021-02-19 10:06:52 +0100
commit9d6b9d10ef8cbef39e89bc709285abffb0d8caa1 (patch)
tree3425b22556e00d1b15de15c72b2802cfc9374473 /server/tests/api/videos
parentfae6e4da8f516a9d6c3bad9bf6f35811ccacbad8 (diff)
downloadPeerTube-9d6b9d10ef8cbef39e89bc709285abffb0d8caa1.tar.gz
PeerTube-9d6b9d10ef8cbef39e89bc709285abffb0d8caa1.tar.zst
PeerTube-9d6b9d10ef8cbef39e89bc709285abffb0d8caa1.zip
Fix video comments display with deleted comments
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/video-comments.ts48
1 files changed, 30 insertions, 18 deletions
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index 141a80690..615e0ea45 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -67,6 +67,7 @@ describe('Test video comments', function () {
67 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) 67 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
68 68
69 expect(res.body.total).to.equal(0) 69 expect(res.body.total).to.equal(0)
70 expect(res.body.totalNotDeletedComments).to.equal(0)
70 expect(res.body.data).to.be.an('array') 71 expect(res.body.data).to.be.an('array')
71 expect(res.body.data).to.have.lengthOf(0) 72 expect(res.body.data).to.have.lengthOf(0)
72 }) 73 })
@@ -94,6 +95,7 @@ describe('Test video comments', function () {
94 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) 95 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
95 96
96 expect(res.body.total).to.equal(1) 97 expect(res.body.total).to.equal(1)
98 expect(res.body.totalNotDeletedComments).to.equal(1)
97 expect(res.body.data).to.be.an('array') 99 expect(res.body.data).to.be.an('array')
98 expect(res.body.data).to.have.lengthOf(1) 100 expect(res.body.data).to.have.lengthOf(1)
99 101
@@ -172,6 +174,7 @@ describe('Test video comments', function () {
172 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt') 174 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt')
173 175
174 expect(res.body.total).to.equal(3) 176 expect(res.body.total).to.equal(3)
177 expect(res.body.totalNotDeletedComments).to.equal(6)
175 expect(res.body.data).to.be.an('array') 178 expect(res.body.data).to.be.an('array')
176 expect(res.body.data).to.have.lengthOf(3) 179 expect(res.body.data).to.have.lengthOf(3)
177 180
@@ -186,26 +189,35 @@ describe('Test video comments', function () {
186 it('Should delete a reply', async function () { 189 it('Should delete a reply', async function () {
187 await deleteVideoComment(server.url, server.accessToken, videoId, replyToDeleteId) 190 await deleteVideoComment(server.url, server.accessToken, videoId, replyToDeleteId)
188 191
189 const res = await getVideoThreadComments(server.url, videoUUID, threadId) 192 {
190 193 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt')
191 const tree: VideoCommentThreadTree = res.body
192 expect(tree.comment.text).equal('my super first comment')
193 expect(tree.children).to.have.lengthOf(2)
194
195 const firstChild = tree.children[0]
196 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
197 expect(firstChild.children).to.have.lengthOf(1)
198 194
199 const childOfFirstChild = firstChild.children[0] 195 expect(res.body.total).to.equal(3)
200 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') 196 expect(res.body.totalNotDeletedComments).to.equal(5)
201 expect(childOfFirstChild.children).to.have.lengthOf(0) 197 }
202 198
203 const deletedChildOfFirstChild = tree.children[1] 199 {
204 expect(deletedChildOfFirstChild.comment.text).to.equal('') 200 const res = await getVideoThreadComments(server.url, videoUUID, threadId)
205 expect(deletedChildOfFirstChild.comment.isDeleted).to.be.true 201
206 expect(deletedChildOfFirstChild.comment.deletedAt).to.not.be.null 202 const tree: VideoCommentThreadTree = res.body
207 expect(deletedChildOfFirstChild.comment.account).to.be.null 203 expect(tree.comment.text).equal('my super first comment')
208 expect(deletedChildOfFirstChild.children).to.have.lengthOf(0) 204 expect(tree.children).to.have.lengthOf(2)
205
206 const firstChild = tree.children[0]
207 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
208 expect(firstChild.children).to.have.lengthOf(1)
209
210 const childOfFirstChild = firstChild.children[0]
211 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
212 expect(childOfFirstChild.children).to.have.lengthOf(0)
213
214 const deletedChildOfFirstChild = tree.children[1]
215 expect(deletedChildOfFirstChild.comment.text).to.equal('')
216 expect(deletedChildOfFirstChild.comment.isDeleted).to.be.true
217 expect(deletedChildOfFirstChild.comment.deletedAt).to.not.be.null
218 expect(deletedChildOfFirstChild.comment.account).to.be.null
219 expect(deletedChildOfFirstChild.children).to.have.lengthOf(0)
220 }
209 }) 221 })
210 222
211 it('Should delete a complete thread', async function () { 223 it('Should delete a complete thread', async function () {