aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/notifications/comments-notifications.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/notifications/comments-notifications.ts')
-rw-r--r--server/tests/api/notifications/comments-notifications.ts64
1 files changed, 34 insertions, 30 deletions
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts
index cbb46e510..7cbb21397 100644
--- a/server/tests/api/notifications/comments-notifications.ts
+++ b/server/tests/api/notifications/comments-notifications.ts
@@ -52,25 +52,25 @@ describe('Test comments notifications', function () {
52 it('Should not send a new comment notification after a comment on another video', async function () { 52 it('Should not send a new comment notification after a comment on another video', async function () {
53 this.timeout(20000) 53 this.timeout(20000)
54 54
55 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 55 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
56 56
57 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) 57 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
58 const commentId = created.id 58 const commentId = created.id
59 59
60 await waitJobs(servers) 60 await waitJobs(servers)
61 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') 61 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'absence' })
62 }) 62 })
63 63
64 it('Should not send a new comment notification if I comment my own video', async function () { 64 it('Should not send a new comment notification if I comment my own video', async function () {
65 this.timeout(20000) 65 this.timeout(20000)
66 66
67 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 67 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
68 68
69 const created = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: 'comment' }) 69 const created = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: 'comment' })
70 const commentId = created.id 70 const commentId = created.id
71 71
72 await waitJobs(servers) 72 await waitJobs(servers)
73 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') 73 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'absence' })
74 }) 74 })
75 75
76 it('Should not send a new comment notification if the account is muted', async function () { 76 it('Should not send a new comment notification if the account is muted', async function () {
@@ -78,13 +78,13 @@ describe('Test comments notifications', function () {
78 78
79 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' }) 79 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
80 80
81 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 81 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
82 82
83 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) 83 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
84 const commentId = created.id 84 const commentId = created.id
85 85
86 await waitJobs(servers) 86 await waitJobs(servers)
87 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') 87 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'absence' })
88 88
89 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' }) 89 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
90 }) 90 })
@@ -92,19 +92,19 @@ describe('Test comments notifications', function () {
92 it('Should send a new comment notification after a local comment on my video', async function () { 92 it('Should send a new comment notification after a local comment on my video', async function () {
93 this.timeout(20000) 93 this.timeout(20000)
94 94
95 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 95 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
96 96
97 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) 97 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
98 const commentId = created.id 98 const commentId = created.id
99 99
100 await waitJobs(servers) 100 await waitJobs(servers)
101 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence') 101 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'presence' })
102 }) 102 })
103 103
104 it('Should send a new comment notification after a remote comment on my video', async function () { 104 it('Should send a new comment notification after a remote comment on my video', async function () {
105 this.timeout(20000) 105 this.timeout(20000)
106 106
107 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 107 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
108 108
109 await waitJobs(servers) 109 await waitJobs(servers)
110 110
@@ -116,26 +116,26 @@ describe('Test comments notifications', function () {
116 expect(data).to.have.lengthOf(1) 116 expect(data).to.have.lengthOf(1)
117 117
118 const commentId = data[0].id 118 const commentId = data[0].id
119 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence') 119 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'presence' })
120 }) 120 })
121 121
122 it('Should send a new comment notification after a local reply on my video', async function () { 122 it('Should send a new comment notification after a local reply on my video', async function () {
123 this.timeout(20000) 123 this.timeout(20000)
124 124
125 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 125 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
126 126
127 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) 127 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
128 128
129 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }) 129 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
130 130
131 await waitJobs(servers) 131 await waitJobs(servers)
132 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence') 132 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId, commentId, checkType: 'presence' })
133 }) 133 })
134 134
135 it('Should send a new comment notification after a remote reply on my video', async function () { 135 it('Should send a new comment notification after a remote reply on my video', async function () {
136 this.timeout(20000) 136 this.timeout(20000)
137 137
138 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 138 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
139 await waitJobs(servers) 139 await waitJobs(servers)
140 140
141 { 141 {
@@ -155,7 +155,7 @@ describe('Test comments notifications', function () {
155 expect(tree.children).to.have.lengthOf(1) 155 expect(tree.children).to.have.lengthOf(1)
156 const commentId = tree.children[0].comment.id 156 const commentId = tree.children[0].comment.id
157 157
158 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence') 158 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId, commentId, checkType: 'presence' })
159 }) 159 })
160 160
161 it('Should convert markdown in comment to html', async function () { 161 it('Should convert markdown in comment to html', async function () {
@@ -174,6 +174,7 @@ describe('Test comments notifications', function () {
174 174
175 describe('Mention notifications', function () { 175 describe('Mention notifications', function () {
176 let baseParams: CheckerBaseParams 176 let baseParams: CheckerBaseParams
177 const byAccountDisplayName = 'super root name'
177 178
178 before(async () => { 179 before(async () => {
179 baseParams = { 180 baseParams = {
@@ -190,23 +191,23 @@ describe('Test comments notifications', function () {
190 it('Should not send a new mention comment notification if I mention the video owner', async function () { 191 it('Should not send a new mention comment notification if I mention the video owner', async function () {
191 this.timeout(10000) 192 this.timeout(10000)
192 193
193 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 194 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
194 195
195 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' }) 196 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
196 197
197 await waitJobs(servers) 198 await waitJobs(servers)
198 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 199 await checkCommentMention({ ...baseParams, shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })
199 }) 200 })
200 201
201 it('Should not send a new mention comment notification if I mention myself', async function () { 202 it('Should not send a new mention comment notification if I mention myself', async function () {
202 this.timeout(10000) 203 this.timeout(10000)
203 204
204 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 205 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
205 206
206 const { id: commentId } = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' }) 207 const { id: commentId } = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' })
207 208
208 await waitJobs(servers) 209 await waitJobs(servers)
209 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 210 await checkCommentMention({ ...baseParams, shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })
210 }) 211 })
211 212
212 it('Should not send a new mention notification if the account is muted', async function () { 213 it('Should not send a new mention notification if the account is muted', async function () {
@@ -214,12 +215,12 @@ describe('Test comments notifications', function () {
214 215
215 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' }) 216 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
216 217
217 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 218 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
218 219
219 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' }) 220 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
220 221
221 await waitJobs(servers) 222 await waitJobs(servers)
222 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 223 await checkCommentMention({ ...baseParams, shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })
223 224
224 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' }) 225 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
225 }) 226 })
@@ -227,35 +228,37 @@ describe('Test comments notifications', function () {
227 it('Should not send a new mention notification if the remote account mention a local account', async function () { 228 it('Should not send a new mention notification if the remote account mention a local account', async function () {
228 this.timeout(20000) 229 this.timeout(20000)
229 230
230 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 231 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
231 232
232 await waitJobs(servers) 233 await waitJobs(servers)
233 const { id: threadId } = await servers[1].comments.createThread({ videoId: uuid, text: '@user_1 hello' }) 234 const { id: threadId } = await servers[1].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
234 235
235 await waitJobs(servers) 236 await waitJobs(servers)
236 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence') 237
238 const byAccountDisplayName = 'super root 2 name'
239 await checkCommentMention({ ...baseParams, shortUUID, threadId, commentId: threadId, byAccountDisplayName, checkType: 'absence' })
237 }) 240 })
238 241
239 it('Should send a new mention notification after local comments', async function () { 242 it('Should send a new mention notification after local comments', async function () {
240 this.timeout(10000) 243 this.timeout(10000)
241 244
242 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 245 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
243 246
244 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' }) 247 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' })
245 248
246 await waitJobs(servers) 249 await waitJobs(servers)
247 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence') 250 await checkCommentMention({ ...baseParams, shortUUID, threadId, commentId: threadId, byAccountDisplayName, checkType: 'presence' })
248 251
249 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' }) 252 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' })
250 253
251 await waitJobs(servers) 254 await waitJobs(servers)
252 await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence') 255 await checkCommentMention({ ...baseParams, shortUUID, commentId, threadId, byAccountDisplayName, checkType: 'presence' })
253 }) 256 })
254 257
255 it('Should send a new mention notification after remote comments', async function () { 258 it('Should send a new mention notification after remote comments', async function () {
256 this.timeout(20000) 259 this.timeout(20000)
257 260
258 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 261 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
259 262
260 await waitJobs(servers) 263 await waitJobs(servers)
261 264
@@ -267,20 +270,21 @@ describe('Test comments notifications', function () {
267 const { data } = await servers[0].comments.listThreads({ videoId: uuid }) 270 const { data } = await servers[0].comments.listThreads({ videoId: uuid })
268 expect(data).to.have.lengthOf(1) 271 expect(data).to.have.lengthOf(1)
269 272
270 const server1ThreadId = data[0].id 273 const byAccountDisplayName = 'super root 2 name'
271 await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence') 274 const threadId = data[0].id
275 await checkCommentMention({ ...baseParams, shortUUID, commentId: threadId, threadId, byAccountDisplayName, checkType: 'presence' })
272 276
273 const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}` 277 const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}`
274 await servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 }) 278 await servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 })
275 279
276 await waitJobs(servers) 280 await waitJobs(servers)
277 281
278 const tree = await servers[0].comments.getThread({ videoId: uuid, threadId: server1ThreadId }) 282 const tree = await servers[0].comments.getThread({ videoId: uuid, threadId })
279 283
280 expect(tree.children).to.have.lengthOf(1) 284 expect(tree.children).to.have.lengthOf(1)
281 const commentId = tree.children[0].comment.id 285 const commentId = tree.children[0].comment.id
282 286
283 await checkCommentMention(baseParams, uuid, commentId, server1ThreadId, 'super root 2 name', 'presence') 287 await checkCommentMention({ ...baseParams, shortUUID, commentId, threadId, byAccountDisplayName, checkType: 'presence' })
284 }) 288 })
285 289
286 it('Should convert markdown in comment to html', async function () { 290 it('Should convert markdown in comment to html', async function () {