aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/notifications
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/notifications')
-rw-r--r--server/tests/api/notifications/comments-notifications.ts46
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts51
-rw-r--r--server/tests/api/notifications/notifications-api.ts11
-rw-r--r--server/tests/api/notifications/user-notifications.ts19
4 files changed, 48 insertions, 79 deletions
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts
index 62569f810..a74b38e8a 100644
--- a/server/tests/api/notifications/comments-notifications.ts
+++ b/server/tests/api/notifications/comments-notifications.ts
@@ -10,7 +10,6 @@ import {
10 MockSmtpServer, 10 MockSmtpServer,
11 prepareNotificationsTest, 11 prepareNotificationsTest,
12 ServerInfo, 12 ServerInfo,
13 uploadVideo,
14 waitJobs 13 waitJobs
15} from '@shared/extra-utils' 14} from '@shared/extra-utils'
16import { UserNotification } from '@shared/models' 15import { UserNotification } from '@shared/models'
@@ -53,8 +52,7 @@ describe('Test comments notifications', function () {
53 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 () {
54 this.timeout(20000) 53 this.timeout(20000)
55 54
56 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 55 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
57 const uuid = resVideo.body.video.uuid
58 56
59 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 57 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
60 const commentId = created.id 58 const commentId = created.id
@@ -66,8 +64,7 @@ describe('Test comments notifications', function () {
66 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 () {
67 this.timeout(20000) 65 this.timeout(20000)
68 66
69 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) 67 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
70 const uuid = resVideo.body.video.uuid
71 68
72 const created = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: 'comment' }) 69 const created = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: 'comment' })
73 const commentId = created.id 70 const commentId = created.id
@@ -81,8 +78,7 @@ describe('Test comments notifications', function () {
81 78
82 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' }) 79 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' })
83 80
84 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) 81 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
85 const uuid = resVideo.body.video.uuid
86 82
87 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 83 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
88 const commentId = created.id 84 const commentId = created.id
@@ -96,8 +92,7 @@ describe('Test comments notifications', function () {
96 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 () {
97 this.timeout(20000) 93 this.timeout(20000)
98 94
99 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) 95 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
100 const uuid = resVideo.body.video.uuid
101 96
102 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 97 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
103 const commentId = created.id 98 const commentId = created.id
@@ -109,8 +104,7 @@ describe('Test comments notifications', function () {
109 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 () {
110 this.timeout(20000) 105 this.timeout(20000)
111 106
112 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) 107 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
113 const uuid = resVideo.body.video.uuid
114 108
115 await waitJobs(servers) 109 await waitJobs(servers)
116 110
@@ -128,8 +122,7 @@ describe('Test comments notifications', function () {
128 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 () {
129 this.timeout(20000) 123 this.timeout(20000)
130 124
131 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) 125 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
132 const uuid = resVideo.body.video.uuid
133 126
134 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 127 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
135 128
@@ -142,8 +135,7 @@ describe('Test comments notifications', function () {
142 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 () {
143 this.timeout(20000) 136 this.timeout(20000)
144 137
145 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) 138 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
146 const uuid = resVideo.body.video.uuid
147 await waitJobs(servers) 139 await waitJobs(servers)
148 140
149 { 141 {
@@ -169,8 +161,7 @@ describe('Test comments notifications', function () {
169 it('Should convert markdown in comment to html', async function () { 161 it('Should convert markdown in comment to html', async function () {
170 this.timeout(20000) 162 this.timeout(20000)
171 163
172 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'cool video' }) 164 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'cool video' } })
173 const uuid = resVideo.body.video.uuid
174 165
175 await servers[0].commentsCommand.createThread({ videoId: uuid, text: commentText }) 166 await servers[0].commentsCommand.createThread({ videoId: uuid, text: commentText })
176 167
@@ -199,8 +190,7 @@ describe('Test comments notifications', function () {
199 it('Should not send a new mention comment notification if I mention the video owner', async function () { 190 it('Should not send a new mention comment notification if I mention the video owner', async function () {
200 this.timeout(10000) 191 this.timeout(10000)
201 192
202 const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) 193 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
203 const uuid = resVideo.body.video.uuid
204 194
205 const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) 195 const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
206 196
@@ -211,8 +201,7 @@ describe('Test comments notifications', function () {
211 it('Should not send a new mention comment notification if I mention myself', async function () { 201 it('Should not send a new mention comment notification if I mention myself', async function () {
212 this.timeout(10000) 202 this.timeout(10000)
213 203
214 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 204 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
215 const uuid = resVideo.body.video.uuid
216 205
217 const { id: commentId } = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' }) 206 const { id: commentId } = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' })
218 207
@@ -225,8 +214,7 @@ describe('Test comments notifications', function () {
225 214
226 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' }) 215 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' })
227 216
228 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 217 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
229 const uuid = resVideo.body.video.uuid
230 218
231 const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) 219 const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
232 220
@@ -239,8 +227,7 @@ describe('Test comments notifications', function () {
239 it('Should not send a new mention notification if the remote account mention a local account', async function () { 227 it('Should not send a new mention notification if the remote account mention a local account', async function () {
240 this.timeout(20000) 228 this.timeout(20000)
241 229
242 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 230 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
243 const uuid = resVideo.body.video.uuid
244 231
245 await waitJobs(servers) 232 await waitJobs(servers)
246 const { id: threadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) 233 const { id: threadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
@@ -252,8 +239,7 @@ describe('Test comments notifications', function () {
252 it('Should send a new mention notification after local comments', async function () { 239 it('Should send a new mention notification after local comments', async function () {
253 this.timeout(10000) 240 this.timeout(10000)
254 241
255 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 242 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
256 const uuid = resVideo.body.video.uuid
257 243
258 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' }) 244 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' })
259 245
@@ -269,8 +255,7 @@ describe('Test comments notifications', function () {
269 it('Should send a new mention notification after remote comments', async function () { 255 it('Should send a new mention notification after remote comments', async function () {
270 this.timeout(20000) 256 this.timeout(20000)
271 257
272 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 258 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
273 const uuid = resVideo.body.video.uuid
274 259
275 await waitJobs(servers) 260 await waitJobs(servers)
276 261
@@ -301,8 +286,7 @@ describe('Test comments notifications', function () {
301 it('Should convert markdown in comment to html', async function () { 286 it('Should convert markdown in comment to html', async function () {
302 this.timeout(10000) 287 this.timeout(10000)
303 288
304 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) 289 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
305 const uuid = resVideo.body.video.uuid
306 290
307 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello 1' }) 291 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello 1' })
308 292
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index 0269124c5..91a2b4fa5 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -17,12 +17,10 @@ import {
17 checkVideoAutoBlacklistForModerators, 17 checkVideoAutoBlacklistForModerators,
18 checkVideoIsPublished, 18 checkVideoIsPublished,
19 cleanupTests, 19 cleanupTests,
20 getVideoIdFromUUID,
21 MockInstancesIndex, 20 MockInstancesIndex,
22 MockSmtpServer, 21 MockSmtpServer,
23 prepareNotificationsTest, 22 prepareNotificationsTest,
24 ServerInfo, 23 ServerInfo,
25 uploadVideo,
26 wait, 24 wait,
27 waitJobs 25 waitJobs
28} from '@shared/extra-utils' 26} from '@shared/extra-utils'
@@ -64,8 +62,7 @@ describe('Test moderation notifications', function () {
64 this.timeout(20000) 62 this.timeout(20000)
65 63
66 const name = 'video for abuse ' + buildUUID() 64 const name = 'video for abuse ' + buildUUID()
67 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 65 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
68 const video = resVideo.body.video
69 66
70 await servers[0].abusesCommand.report({ videoId: video.id, reason: 'super reason' }) 67 await servers[0].abusesCommand.report({ videoId: video.id, reason: 'super reason' })
71 68
@@ -77,12 +74,11 @@ describe('Test moderation notifications', function () {
77 this.timeout(20000) 74 this.timeout(20000)
78 75
79 const name = 'video for abuse ' + buildUUID() 76 const name = 'video for abuse ' + buildUUID()
80 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 77 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
81 const video = resVideo.body.video
82 78
83 await waitJobs(servers) 79 await waitJobs(servers)
84 80
85 const videoId = await getVideoIdFromUUID(servers[1].url, video.uuid) 81 const videoId = await servers[1].videosCommand.getId({ uuid: video.uuid })
86 await servers[1].abusesCommand.report({ videoId, reason: 'super reason' }) 82 await servers[1].abusesCommand.report({ videoId, reason: 'super reason' })
87 83
88 await waitJobs(servers) 84 await waitJobs(servers)
@@ -93,8 +89,7 @@ describe('Test moderation notifications', function () {
93 this.timeout(20000) 89 this.timeout(20000)
94 90
95 const name = 'video for abuse ' + buildUUID() 91 const name = 'video for abuse ' + buildUUID()
96 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 92 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
97 const video = resVideo.body.video
98 const comment = await servers[0].commentsCommand.createThread({ 93 const comment = await servers[0].commentsCommand.createThread({
99 token: userAccessToken, 94 token: userAccessToken,
100 videoId: video.id, 95 videoId: video.id,
@@ -113,8 +108,7 @@ describe('Test moderation notifications', function () {
113 this.timeout(20000) 108 this.timeout(20000)
114 109
115 const name = 'video for abuse ' + buildUUID() 110 const name = 'video for abuse ' + buildUUID()
116 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 111 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
117 const video = resVideo.body.video
118 112
119 await servers[0].commentsCommand.createThread({ 113 await servers[0].commentsCommand.createThread({
120 token: userAccessToken, 114 token: userAccessToken,
@@ -150,7 +144,7 @@ describe('Test moderation notifications', function () {
150 144
151 const username = 'user' + new Date().getTime() 145 const username = 'user' + new Date().getTime()
152 const tmpToken = await servers[0].usersCommand.generateUserAndToken(username) 146 const tmpToken = await servers[0].usersCommand.generateUserAndToken(username)
153 await uploadVideo(servers[0].url, tmpToken, { name: 'super video' }) 147 await servers[0].videosCommand.upload({ token: tmpToken, attributes: { name: 'super video' } })
154 148
155 await waitJobs(servers) 149 await waitJobs(servers)
156 150
@@ -175,8 +169,7 @@ describe('Test moderation notifications', function () {
175 } 169 }
176 170
177 const name = 'abuse ' + buildUUID() 171 const name = 'abuse ' + buildUUID()
178 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 172 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
179 const video = resVideo.body.video
180 173
181 const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) 174 const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
182 abuseId = body.abuse.id 175 abuseId = body.abuse.id
@@ -223,8 +216,7 @@ describe('Test moderation notifications', function () {
223 } 216 }
224 217
225 const name = 'abuse ' + buildUUID() 218 const name = 'abuse ' + buildUUID()
226 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 219 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
227 const video = resVideo.body.video
228 220
229 { 221 {
230 const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) 222 const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
@@ -294,8 +286,7 @@ describe('Test moderation notifications', function () {
294 this.timeout(10000) 286 this.timeout(10000)
295 287
296 const name = 'video for abuse ' + buildUUID() 288 const name = 'video for abuse ' + buildUUID()
297 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 289 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
298 const uuid = resVideo.body.video.uuid
299 290
300 await servers[0].blacklistCommand.add({ videoId: uuid }) 291 await servers[0].blacklistCommand.add({ videoId: uuid })
301 292
@@ -307,8 +298,7 @@ describe('Test moderation notifications', function () {
307 this.timeout(10000) 298 this.timeout(10000)
308 299
309 const name = 'video for abuse ' + buildUUID() 300 const name = 'video for abuse ' + buildUUID()
310 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) 301 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
311 const uuid = resVideo.body.video.uuid
312 302
313 await servers[0].blacklistCommand.add({ videoId: uuid }) 303 await servers[0].blacklistCommand.add({ videoId: uuid })
314 304
@@ -497,8 +487,8 @@ describe('Test moderation notifications', function () {
497 this.timeout(40000) 487 this.timeout(40000)
498 488
499 videoName = 'video with auto-blacklist ' + buildUUID() 489 videoName = 'video with auto-blacklist ' + buildUUID()
500 const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: videoName }) 490 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: videoName } })
501 videoUUID = resVideo.body.video.uuid 491 videoUUID = uuid
502 492
503 await waitJobs(servers) 493 await waitJobs(servers)
504 await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, videoUUID, videoName, 'presence') 494 await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, videoUUID, videoName, 'presence')
@@ -544,17 +534,16 @@ describe('Test moderation notifications', function () {
544 534
545 const name = 'video with auto-blacklist and future schedule ' + buildUUID() 535 const name = 'video with auto-blacklist and future schedule ' + buildUUID()
546 536
547 const data = { 537 const attributes = {
548 name, 538 name,
549 privacy: VideoPrivacy.PRIVATE, 539 privacy: VideoPrivacy.PRIVATE,
550 scheduleUpdate: { 540 scheduleUpdate: {
551 updateAt: updateAt.toISOString(), 541 updateAt: updateAt.toISOString(),
552 privacy: VideoPrivacy.PUBLIC 542 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
553 } 543 }
554 } 544 }
555 545
556 const resVideo = await uploadVideo(servers[0].url, userAccessToken, data) 546 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes })
557 const uuid = resVideo.body.video.uuid
558 547
559 await servers[0].blacklistCommand.remove({ videoId: uuid }) 548 await servers[0].blacklistCommand.remove({ videoId: uuid })
560 549
@@ -577,17 +566,16 @@ describe('Test moderation notifications', function () {
577 566
578 const name = 'video with schedule done and still auto-blacklisted ' + buildUUID() 567 const name = 'video with schedule done and still auto-blacklisted ' + buildUUID()
579 568
580 const data = { 569 const attributes = {
581 name, 570 name,
582 privacy: VideoPrivacy.PRIVATE, 571 privacy: VideoPrivacy.PRIVATE,
583 scheduleUpdate: { 572 scheduleUpdate: {
584 updateAt: updateAt.toISOString(), 573 updateAt: updateAt.toISOString(),
585 privacy: VideoPrivacy.PUBLIC 574 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
586 } 575 }
587 } 576 }
588 577
589 const resVideo = await uploadVideo(servers[0].url, userAccessToken, data) 578 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes })
590 const uuid = resVideo.body.video.uuid
591 579
592 await wait(6000) 580 await wait(6000)
593 await checkVideoIsPublished(userBaseParams, name, uuid, 'absence') 581 await checkVideoIsPublished(userBaseParams, name, uuid, 'absence')
@@ -601,8 +589,7 @@ describe('Test moderation notifications', function () {
601 const name = 'video without auto-blacklist ' + buildUUID() 589 const name = 'video without auto-blacklist ' + buildUUID()
602 590
603 // admin with blacklist right will not be auto-blacklisted 591 // admin with blacklist right will not be auto-blacklisted
604 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name }) 592 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name } })
605 const uuid = resVideo.body.video.uuid
606 593
607 await waitJobs(servers) 594 await waitJobs(servers)
608 await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence') 595 await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence')
diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts
index f33d8e64d..41e1b8015 100644
--- a/server/tests/api/notifications/notifications-api.ts
+++ b/server/tests/api/notifications/notifications-api.ts
@@ -10,7 +10,6 @@ import {
10 MockSmtpServer, 10 MockSmtpServer,
11 prepareNotificationsTest, 11 prepareNotificationsTest,
12 ServerInfo, 12 ServerInfo,
13 uploadRandomVideo,
14 waitJobs 13 waitJobs
15} from '@shared/extra-utils' 14} from '@shared/extra-utils'
16import { UserNotification, UserNotificationSettingValue } from '@shared/models' 15import { UserNotification, UserNotificationSettingValue } from '@shared/models'
@@ -35,7 +34,7 @@ describe('Test notifications API', function () {
35 await server.subscriptionsCommand.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port }) 34 await server.subscriptionsCommand.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port })
36 35
37 for (let i = 0; i < 10; i++) { 36 for (let i = 0; i < 10; i++) {
38 await uploadRandomVideo(server, false) 37 await server.videosCommand.randomUpload({ wait: false })
39 } 38 }
40 39
41 await waitJobs([ server ]) 40 await waitJobs([ server ])
@@ -112,7 +111,7 @@ describe('Test notifications API', function () {
112 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE) 111 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE)
113 } 112 }
114 113
115 const { name, uuid } = await uploadRandomVideo(server) 114 const { name, uuid } = await server.videosCommand.randomUpload()
116 115
117 const check = { web: true, mail: true } 116 const check = { web: true, mail: true }
118 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') 117 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence')
@@ -131,7 +130,7 @@ describe('Test notifications API', function () {
131 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB) 130 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
132 } 131 }
133 132
134 const { name, uuid } = await uploadRandomVideo(server) 133 const { name, uuid } = await server.videosCommand.randomUpload()
135 134
136 { 135 {
137 const check = { mail: true, web: false } 136 const check = { mail: true, web: false }
@@ -157,7 +156,7 @@ describe('Test notifications API', function () {
157 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL) 156 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL)
158 } 157 }
159 158
160 const { name, uuid } = await uploadRandomVideo(server) 159 const { name, uuid } = await server.videosCommand.randomUpload()
161 160
162 { 161 {
163 const check = { mail: false, web: true } 162 const check = { mail: false, web: true }
@@ -188,7 +187,7 @@ describe('Test notifications API', function () {
188 ) 187 )
189 } 188 }
190 189
191 const { name, uuid } = await uploadRandomVideo(server) 190 const { name, uuid } = await server.videosCommand.randomUpload()
192 191
193 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 192 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
194 }) 193 })
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index 465349fb9..4db8c1576 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -14,7 +14,6 @@ import {
14 MockSmtpServer, 14 MockSmtpServer,
15 prepareNotificationsTest, 15 prepareNotificationsTest,
16 ServerInfo, 16 ServerInfo,
17 updateVideo,
18 uploadRandomVideoOnServers, 17 uploadRandomVideoOnServers,
19 wait, 18 wait,
20 waitJobs 19 waitJobs
@@ -99,7 +98,7 @@ describe('Test user notifications', function () {
99 privacy: VideoPrivacy.PRIVATE, 98 privacy: VideoPrivacy.PRIVATE,
100 scheduleUpdate: { 99 scheduleUpdate: {
101 updateAt: updateAt.toISOString(), 100 updateAt: updateAt.toISOString(),
102 privacy: VideoPrivacy.PUBLIC 101 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
103 } 102 }
104 } 103 }
105 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) 104 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data)
@@ -118,7 +117,7 @@ describe('Test user notifications', function () {
118 privacy: VideoPrivacy.PRIVATE, 117 privacy: VideoPrivacy.PRIVATE,
119 scheduleUpdate: { 118 scheduleUpdate: {
120 updateAt: updateAt.toISOString(), 119 updateAt: updateAt.toISOString(),
121 privacy: VideoPrivacy.PUBLIC 120 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
122 } 121 }
123 } 122 }
124 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 123 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data)
@@ -137,7 +136,7 @@ describe('Test user notifications', function () {
137 privacy: VideoPrivacy.PRIVATE, 136 privacy: VideoPrivacy.PRIVATE,
138 scheduleUpdate: { 137 scheduleUpdate: {
139 updateAt: updateAt.toISOString(), 138 updateAt: updateAt.toISOString(),
140 privacy: VideoPrivacy.PUBLIC 139 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
141 } 140 }
142 } 141 }
143 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) 142 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data)
@@ -154,7 +153,7 @@ describe('Test user notifications', function () {
154 153
155 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 154 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
156 155
157 await updateVideo(servers[0].url, servers[0].accessToken, uuid, { privacy: VideoPrivacy.PUBLIC }) 156 await servers[0].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
158 157
159 await waitJobs(servers) 158 await waitJobs(servers)
160 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 159 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
@@ -168,7 +167,7 @@ describe('Test user notifications', function () {
168 167
169 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 168 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
170 169
171 await updateVideo(servers[1].url, servers[1].accessToken, uuid, { privacy: VideoPrivacy.PUBLIC }) 170 await servers[1].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
172 171
173 await waitJobs(servers) 172 await waitJobs(servers)
174 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 173 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
@@ -180,7 +179,7 @@ describe('Test user notifications', function () {
180 const data = { privacy: VideoPrivacy.PRIVATE } 179 const data = { privacy: VideoPrivacy.PRIVATE }
181 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) 180 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data)
182 181
183 await updateVideo(servers[0].url, servers[0].accessToken, uuid, { privacy: VideoPrivacy.UNLISTED }) 182 await servers[0].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
184 183
185 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 184 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
186 }) 185 })
@@ -191,7 +190,7 @@ describe('Test user notifications', function () {
191 const data = { privacy: VideoPrivacy.PRIVATE } 190 const data = { privacy: VideoPrivacy.PRIVATE }
192 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 191 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data)
193 192
194 await updateVideo(servers[1].url, servers[1].accessToken, uuid, { privacy: VideoPrivacy.UNLISTED }) 193 await servers[1].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
195 194
196 await waitJobs(servers) 195 await waitJobs(servers)
197 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 196 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
@@ -295,7 +294,7 @@ describe('Test user notifications', function () {
295 privacy: VideoPrivacy.PRIVATE, 294 privacy: VideoPrivacy.PRIVATE,
296 scheduleUpdate: { 295 scheduleUpdate: {
297 updateAt: updateAt.toISOString(), 296 updateAt: updateAt.toISOString(),
298 privacy: VideoPrivacy.PUBLIC 297 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
299 } 298 }
300 } 299 }
301 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 300 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data)
@@ -313,7 +312,7 @@ describe('Test user notifications', function () {
313 privacy: VideoPrivacy.PRIVATE, 312 privacy: VideoPrivacy.PRIVATE,
314 scheduleUpdate: { 313 scheduleUpdate: {
315 updateAt: updateAt.toISOString(), 314 updateAt: updateAt.toISOString(),
316 privacy: VideoPrivacy.PUBLIC 315 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
317 } 316 }
318 } 317 }
319 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 318 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data)