diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-01-03 13:36:34 +0100 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2020-01-03 16:25:31 +0100 |
commit | 32c68d67d9125df62ead71668efca4da30132786 (patch) | |
tree | edaea0ae31184544a60bf77d41be3b3a588d5a93 /server/tests/api | |
parent | b7819090de8ced71e5f9c5773c575ab627a148e4 (diff) | |
download | PeerTube-32c68d67d9125df62ead71668efca4da30132786.tar.gz PeerTube-32c68d67d9125df62ead71668efca4da30132786.tar.zst PeerTube-32c68d67d9125df62ead71668efca4da30132786.zip |
Tests for totalRepliesFromVideoAuthor
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/users/blocklist.ts | 2 | ||||
-rw-r--r-- | server/tests/api/videos/video-comments.ts | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/server/tests/api/users/blocklist.ts b/server/tests/api/users/blocklist.ts index 09e72d068..05e58017a 100644 --- a/server/tests/api/users/blocklist.ts +++ b/server/tests/api/users/blocklist.ts | |||
@@ -38,7 +38,7 @@ import { | |||
38 | removeServerFromAccountBlocklist, | 38 | removeServerFromAccountBlocklist, |
39 | removeServerFromServerBlocklist | 39 | removeServerFromServerBlocklist |
40 | } from '../../../../shared/extra-utils/users/blocklist' | 40 | } from '../../../../shared/extra-utils/users/blocklist' |
41 | import { getUserNotifications } from '@shared/extra-utils/users/user-notifications' | 41 | import { getUserNotifications } from '../../../../shared/extra-utils/users/user-notifications' |
42 | 42 | ||
43 | const expect = chai.expect | 43 | const expect = chai.expect |
44 | 44 | ||
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' |
15 | import { | 17 | import { |
@@ -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 | }) |