diff options
Diffstat (limited to 'server/tests/api/videos/video-comments.ts')
-rw-r--r-- | server/tests/api/videos/video-comments.ts | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index dc47f8a4a..e35500b0b 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts | |||
@@ -38,6 +38,8 @@ describe('Test video comments', function () { | |||
38 | await setDefaultAccountAvatar(server) | 38 | await setDefaultAccountAvatar(server) |
39 | 39 | ||
40 | userAccessTokenServer1 = await server.users.generateUserAndToken('user1') | 40 | userAccessTokenServer1 = await server.users.generateUserAndToken('user1') |
41 | await setDefaultChannelAvatar(server, 'user1_channel') | ||
42 | await setDefaultAccountAvatar(server, userAccessTokenServer1) | ||
41 | 43 | ||
42 | command = server.comments | 44 | command = server.comments |
43 | }) | 45 | }) |
@@ -167,6 +169,13 @@ describe('Test video comments', function () { | |||
167 | expect(body.data[2].totalReplies).to.equal(0) | 169 | expect(body.data[2].totalReplies).to.equal(0) |
168 | }) | 170 | }) |
169 | 171 | ||
172 | it('Should list the and sort them by total replies', async function () { | ||
173 | const body = await command.listThreads({ videoId: videoUUID, sort: 'totalReplies' }) | ||
174 | |||
175 | expect(body.data[2].text).to.equal('my super first comment') | ||
176 | expect(body.data[2].totalReplies).to.equal(3) | ||
177 | }) | ||
178 | |||
170 | it('Should delete a reply', async function () { | 179 | it('Should delete a reply', async function () { |
171 | await command.delete({ videoId, commentId: replyToDeleteId }) | 180 | await command.delete({ videoId, commentId: replyToDeleteId }) |
172 | 181 | ||
@@ -232,16 +241,34 @@ describe('Test video comments', function () { | |||
232 | await command.addReply({ videoId, toCommentId: threadId2, text: text3 }) | 241 | await command.addReply({ videoId, toCommentId: threadId2, text: text3 }) |
233 | 242 | ||
234 | const tree = await command.getThread({ videoId: videoUUID, threadId: threadId2 }) | 243 | const tree = await command.getThread({ videoId: videoUUID, threadId: threadId2 }) |
235 | expect(tree.comment.totalReplies).to.equal(tree.comment.totalRepliesFromVideoAuthor + 1) | 244 | expect(tree.comment.totalRepliesFromVideoAuthor).to.equal(1) |
245 | expect(tree.comment.totalReplies).to.equal(2) | ||
236 | }) | 246 | }) |
237 | }) | 247 | }) |
238 | 248 | ||
239 | describe('All instance comments', function () { | 249 | describe('All instance comments', function () { |
240 | 250 | ||
241 | it('Should list instance comments as admin', async function () { | 251 | it('Should list instance comments as admin', async function () { |
242 | const { data } = await command.listForAdmin({ start: 0, count: 1 }) | 252 | { |
253 | const { data, total } = await command.listForAdmin({ start: 0, count: 1 }) | ||
254 | |||
255 | expect(total).to.equal(7) | ||
256 | expect(data).to.have.lengthOf(1) | ||
257 | expect(data[0].text).to.equal('my second answer to thread 4') | ||
258 | expect(data[0].account.name).to.equal('root') | ||
259 | expect(data[0].account.displayName).to.equal('root') | ||
260 | expect(data[0].account.avatars).to.have.lengthOf(2) | ||
261 | } | ||
262 | |||
263 | { | ||
264 | const { data, total } = await command.listForAdmin({ start: 1, count: 2 }) | ||
243 | 265 | ||
244 | expect(data[0].text).to.equal('my second answer to thread 4') | 266 | expect(total).to.equal(7) |
267 | expect(data).to.have.lengthOf(2) | ||
268 | |||
269 | expect(data[0].account.avatars).to.have.lengthOf(2) | ||
270 | expect(data[1].account.avatars).to.have.lengthOf(2) | ||
271 | } | ||
245 | }) | 272 | }) |
246 | 273 | ||
247 | it('Should filter instance comments by isLocal', async function () { | 274 | it('Should filter instance comments by isLocal', async function () { |