]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
cef534ed | 2 | |
86347717 | 3 | import { expect } from 'chai' |
cef534ed C |
4 | import { |
5 | CheckerBaseParams, | |
f7cc67b4 C |
6 | checkMyVideoImportIsFinished, |
7 | checkNewActorFollow, | |
cef534ed | 8 | checkNewVideoFromSubscription, |
f7cc67b4 | 9 | checkVideoIsPublished, |
26e3e98f | 10 | checkVideoStudioEditionIsFinished, |
59bbcced | 11 | FIXTURE_URLS, |
2c27e704 | 12 | MockSmtpServer, |
59bbcced | 13 | prepareNotificationsTest, |
c55e3d72 C |
14 | uploadRandomVideoOnServers |
15 | } from '@server/tests/shared' | |
0628157f C |
16 | import { wait } from '@shared/core-utils' |
17 | import { buildUUID } from '@shared/extra-utils' | |
26e3e98f C |
18 | import { UserNotification, UserNotificationType, VideoPrivacy, VideoStudioTask } from '@shared/models' |
19 | import { cleanupTests, findExternalSavedVideo, PeerTubeServer, stopFfmpeg, waitJobs } from '@shared/server-commands' | |
cef534ed | 20 | |
8eb07b01 | 21 | describe('Test user notifications', function () { |
254d3579 | 22 | let servers: PeerTubeServer[] = [] |
cef534ed | 23 | let userAccessToken: string |
1808a1f8 | 24 | |
8eb07b01 C |
25 | let userNotifications: UserNotification[] = [] |
26 | let adminNotifications: UserNotification[] = [] | |
27 | let adminNotificationsServer2: UserNotification[] = [] | |
28 | let emails: object[] = [] | |
1808a1f8 | 29 | |
dc133480 C |
30 | let channelId: number |
31 | ||
cef534ed C |
32 | before(async function () { |
33 | this.timeout(120000) | |
34 | ||
8eb07b01 C |
35 | const res = await prepareNotificationsTest(3) |
36 | emails = res.emails | |
37 | userAccessToken = res.userAccessToken | |
38 | servers = res.servers | |
39 | userNotifications = res.userNotifications | |
40 | adminNotifications = res.adminNotifications | |
41 | adminNotificationsServer2 = res.adminNotificationsServer2 | |
42 | channelId = res.channelId | |
cef534ed C |
43 | }) |
44 | ||
45 | describe('New video from my subscription notification', function () { | |
46 | let baseParams: CheckerBaseParams | |
47 | ||
48 | before(() => { | |
49 | baseParams = { | |
50 | server: servers[0], | |
51 | emails, | |
52 | socketNotifications: userNotifications, | |
53 | token: userAccessToken | |
54 | } | |
55 | }) | |
56 | ||
57 | it('Should not send notifications if the user does not follow the video publisher', async function () { | |
59fd824c | 58 | this.timeout(50000) |
f7effe8d | 59 | |
8eb07b01 | 60 | await uploadRandomVideoOnServers(servers, 1) |
cef534ed | 61 | |
5d3c5f27 | 62 | const notification = await servers[0].notifications.getLatest({ token: userAccessToken }) |
cef534ed C |
63 | expect(notification).to.be.undefined |
64 | ||
65 | expect(emails).to.have.lengthOf(0) | |
66 | expect(userNotifications).to.have.lengthOf(0) | |
67 | }) | |
68 | ||
69 | it('Should send a new video notification if the user follows the local video publisher', async function () { | |
89ada4e2 | 70 | this.timeout(15000) |
2f1548fd | 71 | |
2732eeff | 72 | await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@' + servers[0].host }) |
2f1548fd | 73 | await waitJobs(servers) |
cef534ed | 74 | |
29837f88 C |
75 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1) |
76 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | |
cef534ed C |
77 | }) |
78 | ||
79 | it('Should send a new video notification from a remote account', async function () { | |
83befebe | 80 | this.timeout(150000) // Server 2 has transcoding enabled |
cef534ed | 81 | |
2732eeff | 82 | await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@' + servers[1].host }) |
2f1548fd | 83 | await waitJobs(servers) |
cef534ed | 84 | |
29837f88 C |
85 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2) |
86 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | |
cef534ed C |
87 | }) |
88 | ||
89 | it('Should send a new video notification on a scheduled publication', async function () { | |
59fd824c | 90 | this.timeout(50000) |
cef534ed | 91 | |
cef534ed | 92 | // In 2 seconds |
a1587156 | 93 | const updateAt = new Date(new Date().getTime() + 2000) |
cef534ed C |
94 | |
95 | const data = { | |
96 | privacy: VideoPrivacy.PRIVATE, | |
97 | scheduleUpdate: { | |
98 | updateAt: updateAt.toISOString(), | |
d23dd9fb | 99 | privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC |
cef534ed C |
100 | } |
101 | } | |
29837f88 | 102 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) |
cef534ed C |
103 | |
104 | await wait(6000) | |
29837f88 | 105 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) |
cef534ed C |
106 | }) |
107 | ||
108 | it('Should send a new video notification on a remote scheduled publication', async function () { | |
8ace6805 | 109 | this.timeout(100000) |
cef534ed | 110 | |
cef534ed | 111 | // In 2 seconds |
a1587156 | 112 | const updateAt = new Date(new Date().getTime() + 2000) |
cef534ed C |
113 | |
114 | const data = { | |
115 | privacy: VideoPrivacy.PRIVATE, | |
116 | scheduleUpdate: { | |
117 | updateAt: updateAt.toISOString(), | |
d23dd9fb | 118 | privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC |
cef534ed C |
119 | } |
120 | } | |
29837f88 | 121 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) |
e8d246d5 | 122 | await waitJobs(servers) |
cef534ed C |
123 | |
124 | await wait(6000) | |
29837f88 | 125 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) |
cef534ed C |
126 | }) |
127 | ||
128 | it('Should not send a notification before the video is published', async function () { | |
21d68e68 | 129 | this.timeout(150000) |
cef534ed | 130 | |
a1587156 | 131 | const updateAt = new Date(new Date().getTime() + 1000000) |
cef534ed C |
132 | |
133 | const data = { | |
134 | privacy: VideoPrivacy.PRIVATE, | |
135 | scheduleUpdate: { | |
136 | updateAt: updateAt.toISOString(), | |
d23dd9fb | 137 | privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC |
cef534ed C |
138 | } |
139 | } | |
29837f88 | 140 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) |
cef534ed C |
141 | |
142 | await wait(6000) | |
29837f88 | 143 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) |
cef534ed C |
144 | }) |
145 | ||
146 | it('Should send a new video notification when a video becomes public', async function () { | |
59fd824c | 147 | this.timeout(50000) |
cef534ed | 148 | |
cef534ed | 149 | const data = { privacy: VideoPrivacy.PRIVATE } |
29837f88 | 150 | const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) |
cef534ed | 151 | |
29837f88 | 152 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) |
cef534ed | 153 | |
89d241a7 | 154 | await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) |
cef534ed | 155 | |
9f39c546 | 156 | await waitJobs(servers) |
29837f88 | 157 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) |
cef534ed C |
158 | }) |
159 | ||
160 | it('Should send a new video notification when a remote video becomes public', async function () { | |
aac7f430 | 161 | this.timeout(120000) |
cef534ed | 162 | |
cef534ed | 163 | const data = { privacy: VideoPrivacy.PRIVATE } |
29837f88 | 164 | const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) |
cef534ed | 165 | |
29837f88 | 166 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) |
cef534ed | 167 | |
89d241a7 | 168 | await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) |
cef534ed C |
169 | |
170 | await waitJobs(servers) | |
29837f88 | 171 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) |
cef534ed C |
172 | }) |
173 | ||
174 | it('Should not send a new video notification when a video becomes unlisted', async function () { | |
59fd824c | 175 | this.timeout(50000) |
cef534ed | 176 | |
cef534ed | 177 | const data = { privacy: VideoPrivacy.PRIVATE } |
29837f88 | 178 | const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) |
cef534ed | 179 | |
89d241a7 | 180 | await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } }) |
cef534ed | 181 | |
29837f88 | 182 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) |
cef534ed C |
183 | }) |
184 | ||
185 | it('Should not send a new video notification when a remote video becomes unlisted', async function () { | |
10178c47 | 186 | this.timeout(100000) |
cef534ed | 187 | |
cef534ed | 188 | const data = { privacy: VideoPrivacy.PRIVATE } |
29837f88 | 189 | const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) |
cef534ed | 190 | |
89d241a7 | 191 | await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } }) |
cef534ed C |
192 | |
193 | await waitJobs(servers) | |
29837f88 | 194 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) |
cef534ed C |
195 | }) |
196 | ||
197 | it('Should send a new video notification after a video import', async function () { | |
7ccddd7b | 198 | this.timeout(100000) |
cef534ed | 199 | |
d4a8e7a6 | 200 | const name = 'video import ' + buildUUID() |
cef534ed C |
201 | |
202 | const attributes = { | |
dc133480 | 203 | name, |
cef534ed C |
204 | channelId, |
205 | privacy: VideoPrivacy.PUBLIC, | |
59bbcced | 206 | targetUrl: FIXTURE_URLS.goodVideo |
cef534ed | 207 | } |
89d241a7 | 208 | const { video } = await servers[0].imports.importVideo({ attributes }) |
cef534ed C |
209 | |
210 | await waitJobs(servers) | |
211 | ||
29837f88 | 212 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID: video.shortUUID, checkType: 'presence' }) |
cef534ed C |
213 | }) |
214 | }) | |
215 | ||
dc133480 C |
216 | describe('My video is published', function () { |
217 | let baseParams: CheckerBaseParams | |
218 | ||
219 | before(() => { | |
220 | baseParams = { | |
221 | server: servers[1], | |
222 | emails, | |
223 | socketNotifications: adminNotificationsServer2, | |
224 | token: servers[1].accessToken | |
225 | } | |
226 | }) | |
227 | ||
228 | it('Should not send a notification if transcoding is not enabled', async function () { | |
59fd824c | 229 | this.timeout(50000) |
f7effe8d | 230 | |
29837f88 | 231 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1) |
dc133480 C |
232 | await waitJobs(servers) |
233 | ||
29837f88 | 234 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) |
dc133480 C |
235 | }) |
236 | ||
237 | it('Should not send a notification if the wait transcoding is false', async function () { | |
5d3c5f27 | 238 | this.timeout(100_000) |
dc133480 | 239 | |
8eb07b01 | 240 | await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: false }) |
dc133480 C |
241 | await waitJobs(servers) |
242 | ||
5d3c5f27 | 243 | const notification = await servers[0].notifications.getLatest({ token: userAccessToken }) |
dc133480 C |
244 | if (notification) { |
245 | expect(notification.type).to.not.equal(UserNotificationType.MY_VIDEO_PUBLISHED) | |
246 | } | |
247 | }) | |
248 | ||
249 | it('Should send a notification even if the video is not transcoded in other resolutions', async function () { | |
9b6c9b5a | 250 | this.timeout(100_000) |
dc133480 | 251 | |
29837f88 | 252 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true, fixture: 'video_short_240p.mp4' }) |
dc133480 C |
253 | await waitJobs(servers) |
254 | ||
29837f88 | 255 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) |
dc133480 C |
256 | }) |
257 | ||
258 | it('Should send a notification with a transcoded video', async function () { | |
9b6c9b5a | 259 | this.timeout(100_000) |
dc133480 | 260 | |
29837f88 | 261 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true }) |
dc133480 C |
262 | await waitJobs(servers) |
263 | ||
29837f88 | 264 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) |
dc133480 C |
265 | }) |
266 | ||
267 | it('Should send a notification when an imported video is transcoded', async function () { | |
33675a47 | 268 | this.timeout(120000) |
dc133480 | 269 | |
d4a8e7a6 | 270 | const name = 'video import ' + buildUUID() |
dc133480 C |
271 | |
272 | const attributes = { | |
273 | name, | |
274 | channelId, | |
275 | privacy: VideoPrivacy.PUBLIC, | |
59bbcced | 276 | targetUrl: FIXTURE_URLS.goodVideo, |
dc133480 C |
277 | waitTranscoding: true |
278 | } | |
89d241a7 | 279 | const { video } = await servers[1].imports.importVideo({ attributes }) |
dc133480 C |
280 | |
281 | await waitJobs(servers) | |
29837f88 | 282 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID: video.shortUUID, checkType: 'presence' }) |
dc133480 C |
283 | }) |
284 | ||
285 | it('Should send a notification when the scheduled update has been proceeded', async function () { | |
286 | this.timeout(70000) | |
287 | ||
288 | // In 2 seconds | |
a1587156 | 289 | const updateAt = new Date(new Date().getTime() + 2000) |
dc133480 C |
290 | |
291 | const data = { | |
292 | privacy: VideoPrivacy.PRIVATE, | |
293 | scheduleUpdate: { | |
294 | updateAt: updateAt.toISOString(), | |
d23dd9fb | 295 | privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC |
dc133480 C |
296 | } |
297 | } | |
29837f88 | 298 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) |
dc133480 C |
299 | |
300 | await wait(6000) | |
29837f88 | 301 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) |
dc133480 | 302 | }) |
f7effe8d JM |
303 | |
304 | it('Should not send a notification before the video is published', async function () { | |
638949c6 | 305 | this.timeout(150000) |
f7effe8d | 306 | |
a1587156 | 307 | const updateAt = new Date(new Date().getTime() + 1000000) |
f7effe8d JM |
308 | |
309 | const data = { | |
310 | privacy: VideoPrivacy.PRIVATE, | |
311 | scheduleUpdate: { | |
312 | updateAt: updateAt.toISOString(), | |
d23dd9fb | 313 | privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC |
f7effe8d JM |
314 | } |
315 | } | |
29837f88 | 316 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) |
f7effe8d JM |
317 | |
318 | await wait(6000) | |
29837f88 | 319 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) |
f7effe8d | 320 | }) |
dc133480 C |
321 | }) |
322 | ||
26e3e98f C |
323 | describe('My live replay is published', function () { |
324 | ||
325 | let baseParams: CheckerBaseParams | |
326 | ||
327 | before(() => { | |
328 | baseParams = { | |
329 | server: servers[1], | |
330 | emails, | |
331 | socketNotifications: adminNotificationsServer2, | |
332 | token: servers[1].accessToken | |
333 | } | |
334 | }) | |
335 | ||
336 | it('Should send a notification is a live replay of a non permanent live is published', async function () { | |
337 | this.timeout(120000) | |
338 | ||
339 | const { shortUUID } = await servers[1].live.create({ | |
340 | fields: { | |
341 | name: 'non permanent live', | |
342 | privacy: VideoPrivacy.PUBLIC, | |
343 | channelId: servers[1].store.channel.id, | |
344 | saveReplay: true, | |
05a60d85 | 345 | replaySettings: { privacy: VideoPrivacy.PUBLIC }, |
26e3e98f C |
346 | permanentLive: false |
347 | } | |
348 | }) | |
349 | ||
350 | const ffmpegCommand = await servers[1].live.sendRTMPStreamInVideo({ videoId: shortUUID }) | |
351 | ||
352 | await waitJobs(servers) | |
353 | await servers[1].live.waitUntilPublished({ videoId: shortUUID }) | |
354 | ||
355 | await stopFfmpeg(ffmpegCommand) | |
356 | await servers[1].live.waitUntilReplacedByReplay({ videoId: shortUUID }) | |
357 | ||
358 | await waitJobs(servers) | |
359 | await checkVideoIsPublished({ ...baseParams, videoName: 'non permanent live', shortUUID, checkType: 'presence' }) | |
360 | }) | |
361 | ||
362 | it('Should send a notification is a live replay of a permanent live is published', async function () { | |
363 | this.timeout(120000) | |
364 | ||
365 | const { shortUUID } = await servers[1].live.create({ | |
366 | fields: { | |
367 | name: 'permanent live', | |
368 | privacy: VideoPrivacy.PUBLIC, | |
369 | channelId: servers[1].store.channel.id, | |
370 | saveReplay: true, | |
05a60d85 | 371 | replaySettings: { privacy: VideoPrivacy.PUBLIC }, |
26e3e98f C |
372 | permanentLive: true |
373 | } | |
374 | }) | |
375 | ||
376 | const ffmpegCommand = await servers[1].live.sendRTMPStreamInVideo({ videoId: shortUUID }) | |
377 | ||
378 | await waitJobs(servers) | |
379 | await servers[1].live.waitUntilPublished({ videoId: shortUUID }) | |
380 | ||
381 | const liveDetails = await servers[1].videos.get({ id: shortUUID }) | |
382 | ||
383 | await stopFfmpeg(ffmpegCommand) | |
384 | ||
385 | await servers[1].live.waitUntilWaiting({ videoId: shortUUID }) | |
386 | await waitJobs(servers) | |
387 | ||
388 | const video = await findExternalSavedVideo(servers[1], liveDetails) | |
389 | expect(video).to.exist | |
390 | ||
391 | await checkVideoIsPublished({ ...baseParams, videoName: video.name, shortUUID: video.shortUUID, checkType: 'presence' }) | |
392 | }) | |
393 | }) | |
394 | ||
92e66e04 | 395 | describe('Video studio', function () { |
1808a1f8 C |
396 | let baseParams: CheckerBaseParams |
397 | ||
398 | before(() => { | |
399 | baseParams = { | |
400 | server: servers[1], | |
401 | emails, | |
402 | socketNotifications: adminNotificationsServer2, | |
403 | token: servers[1].accessToken | |
404 | } | |
405 | }) | |
406 | ||
92e66e04 | 407 | it('Should send a notification after studio edition', async function () { |
1808a1f8 C |
408 | this.timeout(240000) |
409 | ||
410 | const { name, shortUUID, id } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true }) | |
411 | ||
412 | await waitJobs(servers) | |
413 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | |
414 | ||
92e66e04 | 415 | const tasks: VideoStudioTask[] = [ |
1808a1f8 C |
416 | { |
417 | name: 'cut', | |
418 | options: { | |
419 | start: 0, | |
420 | end: 1 | |
421 | } | |
422 | } | |
423 | ] | |
92e66e04 | 424 | await servers[1].videoStudio.createEditionTasks({ videoId: id, tasks }) |
1808a1f8 C |
425 | await waitJobs(servers) |
426 | ||
92e66e04 | 427 | await checkVideoStudioEditionIsFinished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) |
1808a1f8 C |
428 | }) |
429 | }) | |
430 | ||
dc133480 C |
431 | describe('My video is imported', function () { |
432 | let baseParams: CheckerBaseParams | |
433 | ||
434 | before(() => { | |
435 | baseParams = { | |
436 | server: servers[0], | |
437 | emails, | |
438 | socketNotifications: adminNotifications, | |
439 | token: servers[0].accessToken | |
440 | } | |
441 | }) | |
442 | ||
443 | it('Should send a notification when the video import failed', async function () { | |
444 | this.timeout(70000) | |
445 | ||
d4a8e7a6 | 446 | const name = 'video import ' + buildUUID() |
dc133480 C |
447 | |
448 | const attributes = { | |
449 | name, | |
450 | channelId, | |
451 | privacy: VideoPrivacy.PRIVATE, | |
59bbcced | 452 | targetUrl: FIXTURE_URLS.badVideo |
dc133480 | 453 | } |
29837f88 | 454 | const { video: { shortUUID } } = await servers[0].imports.importVideo({ attributes }) |
dc133480 C |
455 | |
456 | await waitJobs(servers) | |
29837f88 C |
457 | |
458 | const url = FIXTURE_URLS.badVideo | |
459 | await checkMyVideoImportIsFinished({ ...baseParams, videoName: name, shortUUID, url, success: false, checkType: 'presence' }) | |
dc133480 C |
460 | }) |
461 | ||
462 | it('Should send a notification when the video import succeeded', async function () { | |
463 | this.timeout(70000) | |
464 | ||
d4a8e7a6 | 465 | const name = 'video import ' + buildUUID() |
dc133480 C |
466 | |
467 | const attributes = { | |
468 | name, | |
469 | channelId, | |
470 | privacy: VideoPrivacy.PRIVATE, | |
59bbcced | 471 | targetUrl: FIXTURE_URLS.goodVideo |
dc133480 | 472 | } |
29837f88 | 473 | const { video: { shortUUID } } = await servers[0].imports.importVideo({ attributes }) |
dc133480 C |
474 | |
475 | await waitJobs(servers) | |
29837f88 C |
476 | |
477 | const url = FIXTURE_URLS.goodVideo | |
478 | await checkMyVideoImportIsFinished({ ...baseParams, videoName: name, shortUUID, url, success: true, checkType: 'presence' }) | |
cef534ed C |
479 | }) |
480 | }) | |
481 | ||
f7cc67b4 C |
482 | describe('New actor follow', function () { |
483 | let baseParams: CheckerBaseParams | |
a1587156 C |
484 | const myChannelName = 'super channel name' |
485 | const myUserName = 'super user name' | |
f7cc67b4 C |
486 | |
487 | before(async () => { | |
488 | baseParams = { | |
489 | server: servers[0], | |
490 | emails, | |
491 | socketNotifications: userNotifications, | |
492 | token: userAccessToken | |
493 | } | |
494 | ||
89d241a7 | 495 | await servers[0].users.updateMe({ displayName: 'super root name' }) |
f7cc67b4 | 496 | |
89d241a7 | 497 | await servers[0].users.updateMe({ |
7926c5f9 | 498 | token: userAccessToken, |
f7cc67b4 C |
499 | displayName: myUserName |
500 | }) | |
501 | ||
89d241a7 | 502 | await servers[1].users.updateMe({ displayName: 'super root 2 name' }) |
f7cc67b4 | 503 | |
89d241a7 | 504 | await servers[0].channels.update({ |
a5461888 C |
505 | token: userAccessToken, |
506 | channelName: 'user_1_channel', | |
507 | attributes: { displayName: myChannelName } | |
508 | }) | |
f7cc67b4 C |
509 | }) |
510 | ||
511 | it('Should notify when a local channel is following one of our channel', async function () { | |
59fd824c | 512 | this.timeout(50000) |
f7cc67b4 | 513 | |
2732eeff | 514 | await servers[0].subscriptions.add({ targetUri: 'user_1_channel@' + servers[0].host }) |
f7cc67b4 C |
515 | await waitJobs(servers) |
516 | ||
29837f88 C |
517 | await checkNewActorFollow({ |
518 | ...baseParams, | |
519 | followType: 'channel', | |
520 | followerName: 'root', | |
521 | followerDisplayName: 'super root name', | |
522 | followingDisplayName: myChannelName, | |
523 | checkType: 'presence' | |
524 | }) | |
f7cc67b4 | 525 | |
2732eeff | 526 | await servers[0].subscriptions.remove({ uri: 'user_1_channel@' + servers[0].host }) |
f7cc67b4 C |
527 | }) |
528 | ||
529 | it('Should notify when a remote channel is following one of our channel', async function () { | |
59fd824c | 530 | this.timeout(50000) |
f7cc67b4 | 531 | |
2732eeff | 532 | await servers[1].subscriptions.add({ targetUri: 'user_1_channel@' + servers[0].host }) |
f7cc67b4 C |
533 | await waitJobs(servers) |
534 | ||
29837f88 C |
535 | await checkNewActorFollow({ |
536 | ...baseParams, | |
537 | followType: 'channel', | |
538 | followerName: 'root', | |
539 | followerDisplayName: 'super root 2 name', | |
540 | followingDisplayName: myChannelName, | |
541 | checkType: 'presence' | |
542 | }) | |
f7cc67b4 | 543 | |
2732eeff | 544 | await servers[1].subscriptions.remove({ uri: 'user_1_channel@' + servers[0].host }) |
f7cc67b4 C |
545 | }) |
546 | ||
7a4fd56c | 547 | // PeerTube does not support account -> account follows |
0dd57e4d | 548 | // it('Should notify when a local account is following one of our channel', async function () { |
59fd824c | 549 | // this.timeout(50000) |
0dd57e4d | 550 | // |
2732eeff | 551 | // await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@' + servers[0].host) |
0dd57e4d C |
552 | // |
553 | // await waitJobs(servers) | |
554 | // | |
555 | // await checkNewActorFollow(baseParams, 'account', 'root', 'super root name', myUserName, 'presence') | |
556 | // }) | |
f7cc67b4 | 557 | |
6ed2e4ea | 558 | // it('Should notify when a remote account is following one of our channel', async function () { |
59fd824c | 559 | // this.timeout(50000) |
6ed2e4ea | 560 | // |
2732eeff | 561 | // await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@' + servers[0].host) |
6ed2e4ea C |
562 | // |
563 | // await waitJobs(servers) | |
564 | // | |
565 | // await checkNewActorFollow(baseParams, 'account', 'root', 'super root 2 name', myUserName, 'presence') | |
566 | // }) | |
f7cc67b4 C |
567 | }) |
568 | ||
7c3b7976 | 569 | after(async function () { |
89ada4e2 C |
570 | MockSmtpServer.Instance.kill() |
571 | ||
7c3b7976 | 572 | await cleanupTests(servers) |
cef534ed C |
573 | }) |
574 | }) |