aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/video-comments.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index 95be14c0e..06e4ff9c8 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -10,6 +10,8 @@ import {
10 ServerInfo, 10 ServerInfo,
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 updateMyAvatar, 12 updateMyAvatar,
13 getAccessToken,
14 createUser,
13 uploadVideo 15 uploadVideo
14} from '../../../../shared/extra-utils/index' 16} from '../../../../shared/extra-utils/index'
15import { 17import {
@@ -29,6 +31,8 @@ describe('Test video comments', function () {
29 let threadId 31 let threadId
30 let replyToDeleteId: number 32 let replyToDeleteId: number
31 33
34 let userAccessTokenServer1: string
35
32 before(async function () { 36 before(async function () {
33 this.timeout(30000) 37 this.timeout(30000)
34 38
@@ -45,6 +49,14 @@ describe('Test video comments', function () {
45 accessToken: server.accessToken, 49 accessToken: server.accessToken,
46 fixture: 'avatar.png' 50 fixture: 'avatar.png'
47 }) 51 })
52
53 await createUser({
54 url: server.url,
55 accessToken: server.accessToken,
56 username: 'user1',
57 password: 'password'
58 })
59 userAccessTokenServer1 = await getAccessToken(server.url, 'user1', 'password')
48 }) 60 })
49 61
50 it('Should not have threads on this video', async function () { 62 it('Should not have threads on this video', async function () {
@@ -69,6 +81,7 @@ describe('Test video comments', function () {
69 expect(comment.account.host).to.equal('localhost:' + server.port) 81 expect(comment.account.host).to.equal('localhost:' + server.port)
70 expect(comment.account.url).to.equal('http://localhost:' + server.port + '/accounts/root') 82 expect(comment.account.url).to.equal('http://localhost:' + server.port + '/accounts/root')
71 expect(comment.totalReplies).to.equal(0) 83 expect(comment.totalReplies).to.equal(0)
84 expect(comment.totalRepliesFromVideoAuthor).to.equal(0)
72 expect(dateIsValid(comment.createdAt as string)).to.be.true 85 expect(dateIsValid(comment.createdAt as string)).to.be.true
73 expect(dateIsValid(comment.updatedAt as string)).to.be.true 86 expect(dateIsValid(comment.updatedAt as string)).to.be.true
74 }) 87 })
@@ -91,6 +104,7 @@ describe('Test video comments', function () {
91 await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png') 104 await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png')
92 105
93 expect(comment.totalReplies).to.equal(0) 106 expect(comment.totalReplies).to.equal(0)
107 expect(comment.totalRepliesFromVideoAuthor).to.equal(0)
94 expect(dateIsValid(comment.createdAt as string)).to.be.true 108 expect(dateIsValid(comment.createdAt as string)).to.be.true
95 expect(dateIsValid(comment.updatedAt as string)).to.be.true 109 expect(dateIsValid(comment.updatedAt as string)).to.be.true
96 110
@@ -209,6 +223,24 @@ describe('Test video comments', function () {
209 expect(res.body.data[2].totalReplies).to.equal(0) 223 expect(res.body.data[2].totalReplies).to.equal(0)
210 }) 224 })
211 225
226 it('Should count replies from the video author correctly', async function () {
227 const text = 'my super first comment'
228 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text)
229 let res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
230 const comment: VideoComment = res.body.data[0]
231 const threadId2 = comment.threadId
232
233 const text2 = 'a first answer to thread 4 by a third party'
234 await addVideoCommentReply(server.url, userAccessTokenServer1, videoId, threadId2, text2)
235
236 const text3 = 'my second answer to thread 4'
237 await addVideoCommentReply(server.url, server.accessToken, videoId, threadId2, text3)
238
239 res = await getVideoThreadComments(server.url, videoUUID, threadId2)
240 const tree: VideoCommentThreadTree = res.body
241 expect(tree.comment.totalReplies).to.equal(tree.comment.totalRepliesFromVideoAuthor + 1)
242 })
243
212 after(async function () { 244 after(async function () {
213 await cleanupTests([ server ]) 245 await cleanupTests([ server ])
214 }) 246 })