aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/notifications
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-09 14:15:11 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit12edc1495a36b2199f1bf1ba37f50c7b694be382 (patch)
tree3abfe2e5b54076de73fbfa25386d0313fc3b7242 /server/tests/api/notifications
parenta54618880c394ad7571f3f3222dc96ec2dd10d9a (diff)
downloadPeerTube-12edc1495a36b2199f1bf1ba37f50c7b694be382.tar.gz
PeerTube-12edc1495a36b2199f1bf1ba37f50c7b694be382.tar.zst
PeerTube-12edc1495a36b2199f1bf1ba37f50c7b694be382.zip
Introduce comments command
Diffstat (limited to 'server/tests/api/notifications')
-rw-r--r--server/tests/api/notifications/comments-notifications.ts123
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts20
2 files changed, 67 insertions, 76 deletions
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts
index 13fcee843..ea6055386 100644
--- a/server/tests/api/notifications/comments-notifications.ts
+++ b/server/tests/api/notifications/comments-notifications.ts
@@ -3,14 +3,10 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import {
6 addVideoCommentReply,
7 addVideoCommentThread,
8 checkCommentMention, 6 checkCommentMention,
9 CheckerBaseParams, 7 CheckerBaseParams,
10 checkNewCommentOnMyVideo, 8 checkNewCommentOnMyVideo,
11 cleanupTests, 9 cleanupTests,
12 getVideoCommentThreads,
13 getVideoThreadComments,
14 MockSmtpServer, 10 MockSmtpServer,
15 prepareNotificationsTest, 11 prepareNotificationsTest,
16 ServerInfo, 12 ServerInfo,
@@ -18,13 +14,13 @@ import {
18 uploadVideo, 14 uploadVideo,
19 waitJobs 15 waitJobs
20} from '@shared/extra-utils' 16} from '@shared/extra-utils'
21import { UserNotification, VideoCommentThreadTree } from '@shared/models' 17import { UserNotification } from '@shared/models'
22 18
23const expect = chai.expect 19const expect = chai.expect
24 20
25describe('Test comments notifications', function () { 21describe('Test comments notifications', function () {
26 let servers: ServerInfo[] = [] 22 let servers: ServerInfo[] = []
27 let userAccessToken: string 23 let userToken: string
28 let userNotifications: UserNotification[] = [] 24 let userNotifications: UserNotification[] = []
29 let emails: object[] = [] 25 let emails: object[] = []
30 26
@@ -38,7 +34,7 @@ describe('Test comments notifications', function () {
38 34
39 const res = await prepareNotificationsTest(2) 35 const res = await prepareNotificationsTest(2)
40 emails = res.emails 36 emails = res.emails
41 userAccessToken = res.userAccessToken 37 userToken = res.userAccessToken
42 servers = res.servers 38 servers = res.servers
43 userNotifications = res.userNotifications 39 userNotifications = res.userNotifications
44 }) 40 })
@@ -51,7 +47,7 @@ describe('Test comments notifications', function () {
51 server: servers[0], 47 server: servers[0],
52 emails, 48 emails,
53 socketNotifications: userNotifications, 49 socketNotifications: userNotifications,
54 token: userAccessToken 50 token: userToken
55 } 51 }
56 }) 52 })
57 53
@@ -61,8 +57,8 @@ describe('Test comments notifications', function () {
61 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 57 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
62 const uuid = resVideo.body.video.uuid 58 const uuid = resVideo.body.video.uuid
63 59
64 const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') 60 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
65 const commentId = resComment.body.comment.id 61 const commentId = created.id
66 62
67 await waitJobs(servers) 63 await waitJobs(servers)
68 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') 64 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
@@ -71,11 +67,11 @@ describe('Test comments notifications', function () {
71 it('Should not send a new comment notification if I comment my own video', async function () { 67 it('Should not send a new comment notification if I comment my own video', async function () {
72 this.timeout(20000) 68 this.timeout(20000)
73 69
74 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) 70 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' })
75 const uuid = resVideo.body.video.uuid 71 const uuid = resVideo.body.video.uuid
76 72
77 const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, 'comment') 73 const created = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: 'comment' })
78 const commentId = resComment.body.comment.id 74 const commentId = created.id
79 75
80 await waitJobs(servers) 76 await waitJobs(servers)
81 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') 77 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
@@ -84,28 +80,28 @@ describe('Test comments notifications', function () {
84 it('Should not send a new comment notification if the account is muted', async function () { 80 it('Should not send a new comment notification if the account is muted', async function () {
85 this.timeout(20000) 81 this.timeout(20000)
86 82
87 await servers[0].blocklistCommand.addToMyBlocklist({ token: userAccessToken, account: 'root' }) 83 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' })
88 84
89 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) 85 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' })
90 const uuid = resVideo.body.video.uuid 86 const uuid = resVideo.body.video.uuid
91 87
92 const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') 88 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
93 const commentId = resComment.body.comment.id 89 const commentId = created.id
94 90
95 await waitJobs(servers) 91 await waitJobs(servers)
96 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') 92 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
97 93
98 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userAccessToken, account: 'root' }) 94 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' })
99 }) 95 })
100 96
101 it('Should send a new comment notification after a local comment on my video', async function () { 97 it('Should send a new comment notification after a local comment on my video', async function () {
102 this.timeout(20000) 98 this.timeout(20000)
103 99
104 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) 100 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' })
105 const uuid = resVideo.body.video.uuid 101 const uuid = resVideo.body.video.uuid
106 102
107 const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') 103 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
108 const commentId = resComment.body.comment.id 104 const commentId = created.id
109 105
110 await waitJobs(servers) 106 await waitJobs(servers)
111 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence') 107 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence')
@@ -114,33 +110,31 @@ describe('Test comments notifications', function () {
114 it('Should send a new comment notification after a remote comment on my video', async function () { 110 it('Should send a new comment notification after a remote comment on my video', async function () {
115 this.timeout(20000) 111 this.timeout(20000)
116 112
117 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) 113 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' })
118 const uuid = resVideo.body.video.uuid 114 const uuid = resVideo.body.video.uuid
119 115
120 await waitJobs(servers) 116 await waitJobs(servers)
121 117
122 await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'comment') 118 await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
123 119
124 await waitJobs(servers) 120 await waitJobs(servers)
125 121
126 const resComment = await getVideoCommentThreads(servers[0].url, uuid, 0, 5) 122 const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid })
127 expect(resComment.body.data).to.have.lengthOf(1) 123 expect(data).to.have.lengthOf(1)
128 const commentId = resComment.body.data[0].id
129 124
125 const commentId = data[0].id
130 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence') 126 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence')
131 }) 127 })
132 128
133 it('Should send a new comment notification after a local reply on my video', async function () { 129 it('Should send a new comment notification after a local reply on my video', async function () {
134 this.timeout(20000) 130 this.timeout(20000)
135 131
136 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) 132 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' })
137 const uuid = resVideo.body.video.uuid 133 const uuid = resVideo.body.video.uuid
138 134
139 const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') 135 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
140 const threadId = resThread.body.comment.id
141 136
142 const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'reply') 137 const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
143 const commentId = resComment.body.comment.id
144 138
145 await waitJobs(servers) 139 await waitJobs(servers)
146 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence') 140 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence')
@@ -149,24 +143,23 @@ describe('Test comments notifications', function () {
149 it('Should send a new comment notification after a remote reply on my video', async function () { 143 it('Should send a new comment notification after a remote reply on my video', async function () {
150 this.timeout(20000) 144 this.timeout(20000)
151 145
152 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) 146 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' })
153 const uuid = resVideo.body.video.uuid 147 const uuid = resVideo.body.video.uuid
154 await waitJobs(servers) 148 await waitJobs(servers)
155 149
156 { 150 {
157 const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'comment') 151 const created = await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
158 const threadId = resThread.body.comment.id 152 const threadId = created.id
159 await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, threadId, 'reply') 153 await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
160 } 154 }
161 155
162 await waitJobs(servers) 156 await waitJobs(servers)
163 157
164 const resThread = await getVideoCommentThreads(servers[0].url, uuid, 0, 5) 158 const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid })
165 expect(resThread.body.data).to.have.lengthOf(1) 159 expect(data).to.have.lengthOf(1)
166 const threadId = resThread.body.data[0].id
167 160
168 const resComments = await getVideoThreadComments(servers[0].url, uuid, threadId) 161 const threadId = data[0].id
169 const tree = resComments.body as VideoCommentThreadTree 162 const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId })
170 163
171 expect(tree.children).to.have.lengthOf(1) 164 expect(tree.children).to.have.lengthOf(1)
172 const commentId = tree.children[0].comment.id 165 const commentId = tree.children[0].comment.id
@@ -177,10 +170,10 @@ describe('Test comments notifications', function () {
177 it('Should convert markdown in comment to html', async function () { 170 it('Should convert markdown in comment to html', async function () {
178 this.timeout(20000) 171 this.timeout(20000)
179 172
180 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'cool video' }) 173 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'cool video' })
181 const uuid = resVideo.body.video.uuid 174 const uuid = resVideo.body.video.uuid
182 175
183 await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, commentText) 176 await servers[0].commentsCommand.createThread({ videoId: uuid, text: commentText })
184 177
185 await waitJobs(servers) 178 await waitJobs(servers)
186 179
@@ -197,7 +190,7 @@ describe('Test comments notifications', function () {
197 server: servers[0], 190 server: servers[0],
198 emails, 191 emails,
199 socketNotifications: userNotifications, 192 socketNotifications: userNotifications,
200 token: userAccessToken 193 token: userToken
201 } 194 }
202 195
203 await updateMyUser({ 196 await updateMyUser({
@@ -216,11 +209,10 @@ describe('Test comments notifications', function () {
216 it('Should not send a new mention comment notification if I mention the video owner', async function () { 209 it('Should not send a new mention comment notification if I mention the video owner', async function () {
217 this.timeout(10000) 210 this.timeout(10000)
218 211
219 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) 212 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' })
220 const uuid = resVideo.body.video.uuid 213 const uuid = resVideo.body.video.uuid
221 214
222 const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello') 215 const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
223 const commentId = resComment.body.comment.id
224 216
225 await waitJobs(servers) 217 await waitJobs(servers)
226 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 218 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
@@ -232,8 +224,7 @@ describe('Test comments notifications', function () {
232 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 224 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
233 const uuid = resVideo.body.video.uuid 225 const uuid = resVideo.body.video.uuid
234 226
235 const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, '@user_1 hello') 227 const { id: commentId } = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' })
236 const commentId = resComment.body.comment.id
237 228
238 await waitJobs(servers) 229 await waitJobs(servers)
239 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 230 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
@@ -242,18 +233,17 @@ describe('Test comments notifications', function () {
242 it('Should not send a new mention notification if the account is muted', async function () { 233 it('Should not send a new mention notification if the account is muted', async function () {
243 this.timeout(10000) 234 this.timeout(10000)
244 235
245 await servers[0].blocklistCommand.addToMyBlocklist({ token: userAccessToken, account: 'root' }) 236 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' })
246 237
247 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 238 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
248 const uuid = resVideo.body.video.uuid 239 const uuid = resVideo.body.video.uuid
249 240
250 const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello') 241 const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
251 const commentId = resComment.body.comment.id
252 242
253 await waitJobs(servers) 243 await waitJobs(servers)
254 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 244 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
255 245
256 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userAccessToken, account: 'root' }) 246 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' })
257 }) 247 })
258 248
259 it('Should not send a new mention notification if the remote account mention a local account', async function () { 249 it('Should not send a new mention notification if the remote account mention a local account', async function () {
@@ -263,8 +253,7 @@ describe('Test comments notifications', function () {
263 const uuid = resVideo.body.video.uuid 253 const uuid = resVideo.body.video.uuid
264 254
265 await waitJobs(servers) 255 await waitJobs(servers)
266 const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, '@user_1 hello') 256 const { id: threadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
267 const threadId = resThread.body.comment.id
268 257
269 await waitJobs(servers) 258 await waitJobs(servers)
270 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence') 259 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence')
@@ -276,14 +265,12 @@ describe('Test comments notifications', function () {
276 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 265 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
277 const uuid = resVideo.body.video.uuid 266 const uuid = resVideo.body.video.uuid
278 267
279 const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello 1') 268 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' })
280 const threadId = resThread.body.comment.id
281 269
282 await waitJobs(servers) 270 await waitJobs(servers)
283 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence') 271 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence')
284 272
285 const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'hello 2 @user_1') 273 const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' })
286 const commentId = resComment.body.comment.id
287 274
288 await waitJobs(servers) 275 await waitJobs(servers)
289 await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence') 276 await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence')
@@ -298,23 +285,22 @@ describe('Test comments notifications', function () {
298 await waitJobs(servers) 285 await waitJobs(servers)
299 286
300 const text1 = `hello @user_1@localhost:${servers[0].port} 1` 287 const text1 = `hello @user_1@localhost:${servers[0].port} 1`
301 const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, text1) 288 const { id: server2ThreadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: text1 })
302 const server2ThreadId = resThread.body.comment.id
303 289
304 await waitJobs(servers) 290 await waitJobs(servers)
305 291
306 const resThread2 = await getVideoCommentThreads(servers[0].url, uuid, 0, 5) 292 const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid })
307 expect(resThread2.body.data).to.have.lengthOf(1) 293 expect(data).to.have.lengthOf(1)
308 const server1ThreadId = resThread2.body.data[0].id 294
295 const server1ThreadId = data[0].id
309 await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence') 296 await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence')
310 297
311 const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}` 298 const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}`
312 await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, server2ThreadId, text2) 299 await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 })
313 300
314 await waitJobs(servers) 301 await waitJobs(servers)
315 302
316 const resComments = await getVideoThreadComments(servers[0].url, uuid, server1ThreadId) 303 const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId: server1ThreadId })
317 const tree = resComments.body as VideoCommentThreadTree
318 304
319 expect(tree.children).to.have.lengthOf(1) 305 expect(tree.children).to.have.lengthOf(1)
320 const commentId = tree.children[0].comment.id 306 const commentId = tree.children[0].comment.id
@@ -328,10 +314,9 @@ describe('Test comments notifications', function () {
328 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 314 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
329 const uuid = resVideo.body.video.uuid 315 const uuid = resVideo.body.video.uuid
330 316
331 const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello 1') 317 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello 1' })
332 const threadId = resThread.body.comment.id
333 318
334 await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, '@user_1 ' + commentText) 319 await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText })
335 320
336 await waitJobs(servers) 321 await waitJobs(servers)
337 322
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index 52ade0548..229f78811 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -3,7 +3,6 @@
3import 'mocha' 3import 'mocha'
4import { buildUUID } from '@server/helpers/uuid' 4import { buildUUID } from '@server/helpers/uuid'
5import { 5import {
6 addVideoCommentThread,
7 checkAbuseStateChange, 6 checkAbuseStateChange,
8 checkAutoInstanceFollowing, 7 checkAutoInstanceFollowing,
9 CheckerBaseParams, 8 CheckerBaseParams,
@@ -20,7 +19,6 @@ import {
20 cleanupTests, 19 cleanupTests,
21 createUser, 20 createUser,
22 generateUserAccessToken, 21 generateUserAccessToken,
23 getVideoCommentThreads,
24 getVideoIdFromUUID, 22 getVideoIdFromUUID,
25 immutableAssign, 23 immutableAssign,
26 MockInstancesIndex, 24 MockInstancesIndex,
@@ -101,8 +99,11 @@ describe('Test moderation notifications', function () {
101 const name = 'video for abuse ' + buildUUID() 99 const name = 'video for abuse ' + buildUUID()
102 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 100 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
103 const video = resVideo.body.video 101 const video = resVideo.body.video
104 const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + buildUUID()) 102 const comment = await servers[0].commentsCommand.createThread({
105 const comment = resComment.body.comment 103 token: userAccessToken,
104 videoId: video.id,
105 text: 'comment abuse ' + buildUUID()
106 })
106 107
107 await waitJobs(servers) 108 await waitJobs(servers)
108 109
@@ -118,12 +119,17 @@ describe('Test moderation notifications', function () {
118 const name = 'video for abuse ' + buildUUID() 119 const name = 'video for abuse ' + buildUUID()
119 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 120 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
120 const video = resVideo.body.video 121 const video = resVideo.body.video
121 await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + buildUUID()) 122
123 await servers[0].commentsCommand.createThread({
124 token: userAccessToken,
125 videoId: video.id,
126 text: 'comment abuse ' + buildUUID()
127 })
122 128
123 await waitJobs(servers) 129 await waitJobs(servers)
124 130
125 const resComments = await getVideoCommentThreads(servers[1].url, video.uuid, 0, 5) 131 const { data } = await servers[1].commentsCommand.listThreads({ videoId: video.uuid })
126 const commentId = resComments.body.data[0].id 132 const commentId = data[0].id
127 await servers[1].abusesCommand.report({ commentId, reason: 'super reason' }) 133 await servers[1].abusesCommand.report({ commentId, reason: 'super reason' })
128 134
129 await waitJobs(servers) 135 await waitJobs(servers)