aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-04 11:19:16 +0100
committerChocobozzz <me@florianbigard.com>2018-01-04 11:19:16 +0100
commit4cb6d4578893db310297d7e118ce2fb7ecb952a3 (patch)
treea89a2e2062ba7bb91e922f07a7950ee51e090ccf /server/tests/api/videos
parentcf117aaafc1e9ae1ab4c388fc5d2e5ba9349efee (diff)
downloadPeerTube-4cb6d4578893db310297d7e118ce2fb7ecb952a3.tar.gz
PeerTube-4cb6d4578893db310297d7e118ce2fb7ecb952a3.tar.zst
PeerTube-4cb6d4578893db310297d7e118ce2fb7ecb952a3.zip
Add ability to delete comments
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/multiple-servers.ts33
-rw-r--r--server/tests/api/videos/video-comments.ts38
2 files changed, 69 insertions, 2 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index b6dfe0d1b..6712829d4 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -13,7 +13,7 @@ import {
13 updateVideo, uploadVideo, userLogin, viewVideo, wait, webtorrentAdd 13 updateVideo, uploadVideo, userLogin, viewVideo, wait, webtorrentAdd
14} from '../../utils' 14} from '../../utils'
15import { 15import {
16 addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, 16 addVideoCommentReply, addVideoCommentThread, deleteVideoComment, getVideoCommentThreads,
17 getVideoThreadComments 17 getVideoThreadComments
18} from '../../utils/videos/video-comments' 18} from '../../utils/videos/video-comments'
19 19
@@ -738,6 +738,37 @@ describe('Test multiple servers', function () {
738 } 738 }
739 }) 739 })
740 740
741 it('Should delete the thread comments', async function () {
742 this.timeout(10000)
743
744 const res1 = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
745 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
746 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
747
748 await wait(5000)
749 })
750
751 it('Should have the thread comments deleted on other servers too', async function () {
752 for (const server of servers) {
753 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
754
755 expect(res.body.total).to.equal(1)
756 expect(res.body.data).to.be.an('array')
757 expect(res.body.data).to.have.lengthOf(1)
758
759 {
760 const comment: VideoComment = res.body.data[0]
761 expect(comment).to.not.be.undefined
762 expect(comment.inReplyToCommentId).to.be.null
763 expect(comment.account.name).to.equal('root')
764 expect(comment.account.host).to.equal('localhost:9003')
765 expect(comment.totalReplies).to.equal(0)
766 expect(dateIsValid(comment.createdAt as string)).to.be.true
767 expect(dateIsValid(comment.updatedAt as string)).to.be.true
768 }
769 }
770 })
771
741 it('Should disable comments', async function () { 772 it('Should disable comments', async function () {
742 this.timeout(20000) 773 this.timeout(20000)
743 774
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