aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-28 11:45:10 +0100
committerChocobozzz <me@florianbigard.com>2017-12-28 11:45:10 +0100
commitdb799da3d2b2ea465165df78ff71effa653b6309 (patch)
tree11a01db2c9521797f63b6ea6cc78745132505ee4 /server/tests/api
parentda854ddd502cd70685ef779c673b9e63757b8aa0 (diff)
downloadPeerTube-db799da3d2b2ea465165df78ff71effa653b6309.tar.gz
PeerTube-db799da3d2b2ea465165df78ff71effa653b6309.tar.zst
PeerTube-db799da3d2b2ea465165df78ff71effa653b6309.zip
Add get old comment on follow tests
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/follows.ts75
1 files changed, 64 insertions, 11 deletions
diff --git a/server/tests/api/follows.ts b/server/tests/api/follows.ts
index 10eb48969..2ffa426a0 100644
--- a/server/tests/api/follows.ts
+++ b/server/tests/api/follows.ts
@@ -2,21 +2,17 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { VideoComment, VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model'
5 6
6import { 7import {
7 flushAndRunMultipleServers, 8 flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo,
8 flushTests,
9 getVideosList,
10 killallServers,
11 ServerInfo,
12 setAccessTokensToServers,
13 uploadVideo,
14 wait 9 wait
15} from '../utils' 10} from '../utils'
16import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../utils/follows' 11import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../utils/follows'
17import { getUserAccessToken } from '../utils/login' 12import { getUserAccessToken } from '../utils/login'
18import { dateIsValid, webtorrentAdd } from '../utils/miscs' 13import { dateIsValid, webtorrentAdd } from '../utils/miscs'
19import { createUser } from '../utils/users' 14import { createUser } from '../utils/users'
15import { addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, getVideoThreadComments } from '../utils/video-comments'
20import { getVideo, rateVideo, testVideoImage } from '../utils/videos' 16import { getVideo, rateVideo, testVideoImage } from '../utils/videos'
21 17
22const expect = chai.expect 18const expect = chai.expect
@@ -186,11 +182,29 @@ describe('Test follows', function () {
186 await createUser(servers[2].url, servers[2].accessToken, user.username, user.password) 182 await createUser(servers[2].url, servers[2].accessToken, user.username, user.password)
187 const userAccessToken = await getUserAccessToken(servers[2], user) 183 const userAccessToken = await getUserAccessToken(servers[2], user)
188 184
189 const res = await getVideosList(servers[2].url) 185 const resVideos = await getVideosList(servers[ 2 ].url)
190 const video4 = res.body.data.find(v => v.name === 'server3-4') 186 const video4 = resVideos.body.data.find(v => v.name === 'server3-4')
191 187
192 await rateVideo(servers[2].url, servers[2].accessToken, video4.id, 'like') 188 {
193 await rateVideo(servers[2].url, userAccessToken, video4.id, 'dislike') 189 await rateVideo(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, 'like')
190 await rateVideo(servers[ 2 ].url, userAccessToken, video4.id, 'dislike')
191 }
192
193 {
194 const text = 'my super first comment'
195 const res = await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, text)
196 const threadId = res.body.comment.id
197
198 const text1 = 'my super answer to thread 1'
199 const childCommentRes = await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text1)
200 const childCommentId = childCommentRes.body.comment.id
201
202 const text2 = 'my super answer to answer of thread 1'
203 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, childCommentId, text2)
204
205 const text3 = 'my second answer to thread 1'
206 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, video4.id, threadId, text3)
207 }
194 } 208 }
195 209
196 await wait(5000) 210 await wait(5000)
@@ -249,6 +263,45 @@ describe('Test follows', function () {
249 expect(torrent.files).to.be.an('array') 263 expect(torrent.files).to.be.an('array')
250 expect(torrent.files.length).to.equal(1) 264 expect(torrent.files.length).to.equal(1)
251 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 265 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
266
267 {
268 const res1 = await getVideoCommentThreads(servers[0].url, video4.id, 0, 5)
269
270 expect(res1.body.total).to.equal(1)
271 expect(res1.body.data).to.be.an('array')
272 expect(res1.body.data).to.have.lengthOf(1)
273
274 const comment: VideoComment = res1.body.data[0]
275 expect(comment.inReplyToCommentId).to.be.null
276 expect(comment.text).equal('my super first comment')
277 expect(comment.videoId).to.equal(video4.id)
278 expect(comment.id).to.equal(comment.threadId)
279 expect(comment.account.name).to.equal('root')
280 expect(comment.account.host).to.equal('localhost:9003')
281 expect(comment.totalReplies).to.equal(3)
282 expect(dateIsValid(comment.createdAt as string)).to.be.true
283 expect(dateIsValid(comment.updatedAt as string)).to.be.true
284
285 const threadId = comment.threadId
286
287 const res2 = await getVideoThreadComments(servers[0].url, video4.id, threadId)
288
289 const tree: VideoCommentThreadTree = res2.body
290 expect(tree.comment.text).equal('my super first comment')
291 expect(tree.children).to.have.lengthOf(2)
292
293 const firstChild = tree.children[0]
294 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
295 expect(firstChild.children).to.have.lengthOf(1)
296
297 const childOfFirstChild = firstChild.children[0]
298 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
299 expect(childOfFirstChild.children).to.have.lengthOf(0)
300
301 const secondChild = tree.children[1]
302 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
303 expect(secondChild.children).to.have.lengthOf(0)
304 }
252 }) 305 })
253 306
254 after(async function () { 307 after(async function () {