aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-comments.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-comments.ts')
-rw-r--r--server/tests/api/videos/video-comments.ts38
1 files changed, 37 insertions, 1 deletions
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index 604a3027d..18d484ccf 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -9,7 +9,7 @@ import {
9 uploadVideo 9 uploadVideo
10} from '../../utils/index' 10} from '../../utils/index'
11import { 11import {
12 addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, 12 addVideoCommentReply, addVideoCommentThread, deleteVideoComment, getVideoCommentThreads,
13 getVideoThreadComments 13 getVideoThreadComments
14} from '../../utils/videos/video-comments' 14} from '../../utils/videos/video-comments'
15 15
@@ -20,6 +20,7 @@ describe('Test video comments', function () {
20 let videoId 20 let videoId
21 let videoUUID 21 let videoUUID
22 let threadId 22 let threadId
23 let replyToDeleteId: number
23 24
24 before(async function () { 25 before(async function () {
25 this.timeout(10000) 26 this.timeout(10000)
@@ -61,6 +62,7 @@ describe('Test video comments', function () {
61 expect(comment.id).to.equal(comment.threadId) 62 expect(comment.id).to.equal(comment.threadId)
62 expect(comment.account.name).to.equal('root') 63 expect(comment.account.name).to.equal('root')
63 expect(comment.account.host).to.equal('localhost:9001') 64 expect(comment.account.host).to.equal('localhost:9001')
65 expect(comment.account.url).to.equal('http://localhost:9001/accounts/root')
64 expect(comment.totalReplies).to.equal(0) 66 expect(comment.totalReplies).to.equal(0)
65 expect(dateIsValid(comment.createdAt as string)).to.be.true 67 expect(dateIsValid(comment.createdAt as string)).to.be.true
66 expect(dateIsValid(comment.updatedAt as string)).to.be.true 68 expect(dateIsValid(comment.updatedAt as string)).to.be.true
@@ -132,6 +134,8 @@ describe('Test video comments', function () {
132 const secondChild = tree.children[1] 134 const secondChild = tree.children[1]
133 expect(secondChild.comment.text).to.equal('my second answer to thread 1') 135 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
134 expect(secondChild.children).to.have.lengthOf(0) 136 expect(secondChild.children).to.have.lengthOf(0)
137
138 replyToDeleteId = secondChild.comment.id
135 }) 139 })
136 140
137 it('Should create other threads', async function () { 141 it('Should create other threads', async function () {
@@ -157,6 +161,38 @@ describe('Test video comments', function () {
157 expect(res.body.data[2].totalReplies).to.equal(0) 161 expect(res.body.data[2].totalReplies).to.equal(0)
158 }) 162 })
159 163
164 it('Should delete a reply', async function () {
165 await deleteVideoComment(server.url, server.accessToken, videoId, replyToDeleteId)
166
167 const res = await getVideoThreadComments(server.url, videoUUID, threadId)
168
169 const tree: VideoCommentThreadTree = res.body
170 expect(tree.comment.text).equal('my super first comment')
171 expect(tree.children).to.have.lengthOf(1)
172
173 const firstChild = tree.children[0]
174 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
175 expect(firstChild.children).to.have.lengthOf(1)
176
177 const childOfFirstChild = firstChild.children[0]
178 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
179 expect(childOfFirstChild.children).to.have.lengthOf(0)
180 })
181
182 it('Should delete a complete thread', async function () {
183 await deleteVideoComment(server.url, server.accessToken, videoId, threadId)
184
185 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt')
186 expect(res.body.total).to.equal(2)
187 expect(res.body.data).to.be.an('array')
188 expect(res.body.data).to.have.lengthOf(2)
189
190 expect(res.body.data[0].text).to.equal('super thread 2')
191 expect(res.body.data[0].totalReplies).to.equal(0)
192 expect(res.body.data[1].text).to.equal('super thread 3')
193 expect(res.body.data[1].totalReplies).to.equal(0)
194 })
195
160 after(async function () { 196 after(async function () {
161 killallServers([ server ]) 197 killallServers([ server ])
162 198