diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-31 14:34:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-08-11 15:02:33 +0200 |
commit | 3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch) | |
tree | e4510b39bdac9c318fdb4b47018d08f15368b8f0 /packages/tests/src/api/notifications/user-notifications.ts | |
parent | 04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff) | |
download | PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip |
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge
conflicts, but it's a major step forward:
* Server can be faster at startup because imports() are async and we can
easily lazy import big modules
* Angular doesn't seem to support ES import (with .js extension), so we
had to correctly organize peertube into a monorepo:
* Use yarn workspace feature
* Use typescript reference projects for dependencies
* Shared projects have been moved into "packages", each one is now a
node module (with a dedicated package.json/tsconfig.json)
* server/tools have been moved into apps/ and is now a dedicated app
bundled and published on NPM so users don't have to build peertube
cli tools manually
* server/tests have been moved into packages/ so we don't compile
them every time we want to run the server
* Use isolatedModule option:
* Had to move from const enum to const
(https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums)
* Had to explictely specify "type" imports when used in decorators
* Prefer tsx (that uses esbuild under the hood) instead of ts-node to
load typescript files (tests with mocha or scripts):
* To reduce test complexity as esbuild doesn't support decorator
metadata, we only test server files that do not import server
models
* We still build tests files into js files for a faster CI
* Remove unmaintained peertube CLI import script
* Removed some barrels to speed up execution (less imports)
Diffstat (limited to 'packages/tests/src/api/notifications/user-notifications.ts')
-rw-r--r-- | packages/tests/src/api/notifications/user-notifications.ts | 574 |
1 files changed, 574 insertions, 0 deletions
diff --git a/packages/tests/src/api/notifications/user-notifications.ts b/packages/tests/src/api/notifications/user-notifications.ts new file mode 100644 index 000000000..4c03cdb47 --- /dev/null +++ b/packages/tests/src/api/notifications/user-notifications.ts | |||
@@ -0,0 +1,574 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { wait } from '@peertube/peertube-core-utils' | ||
5 | import { UserNotification, UserNotificationType, VideoPrivacy, VideoStudioTask } from '@peertube/peertube-models' | ||
6 | import { buildUUID } from '@peertube/peertube-node-utils' | ||
7 | import { cleanupTests, findExternalSavedVideo, PeerTubeServer, stopFfmpeg, waitJobs } from '@peertube/peertube-server-commands' | ||
8 | import { MockSmtpServer } from '@tests/shared/mock-servers/mock-email.js' | ||
9 | import { | ||
10 | prepareNotificationsTest, | ||
11 | CheckerBaseParams, | ||
12 | checkNewVideoFromSubscription, | ||
13 | checkVideoIsPublished, | ||
14 | checkVideoStudioEditionIsFinished, | ||
15 | checkMyVideoImportIsFinished, | ||
16 | checkNewActorFollow | ||
17 | } from '@tests/shared/notifications.js' | ||
18 | import { FIXTURE_URLS } from '@tests/shared/tests.js' | ||
19 | import { uploadRandomVideoOnServers } from '@tests/shared/videos.js' | ||
20 | |||
21 | describe('Test user notifications', function () { | ||
22 | let servers: PeerTubeServer[] = [] | ||
23 | let userAccessToken: string | ||
24 | |||
25 | let userNotifications: UserNotification[] = [] | ||
26 | let adminNotifications: UserNotification[] = [] | ||
27 | let adminNotificationsServer2: UserNotification[] = [] | ||
28 | let emails: object[] = [] | ||
29 | |||
30 | let channelId: number | ||
31 | |||
32 | before(async function () { | ||
33 | this.timeout(120000) | ||
34 | |||
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 | ||
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 () { | ||
58 | this.timeout(50000) | ||
59 | |||
60 | await uploadRandomVideoOnServers(servers, 1) | ||
61 | |||
62 | const notification = await servers[0].notifications.getLatest({ token: userAccessToken }) | ||
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 () { | ||
70 | this.timeout(15000) | ||
71 | |||
72 | await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@' + servers[0].host }) | ||
73 | await waitJobs(servers) | ||
74 | |||
75 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1) | ||
76 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | ||
77 | }) | ||
78 | |||
79 | it('Should send a new video notification from a remote account', async function () { | ||
80 | this.timeout(150000) // Server 2 has transcoding enabled | ||
81 | |||
82 | await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@' + servers[1].host }) | ||
83 | await waitJobs(servers) | ||
84 | |||
85 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2) | ||
86 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | ||
87 | }) | ||
88 | |||
89 | it('Should send a new video notification on a scheduled publication', async function () { | ||
90 | this.timeout(50000) | ||
91 | |||
92 | // In 2 seconds | ||
93 | const updateAt = new Date(new Date().getTime() + 2000) | ||
94 | |||
95 | const data = { | ||
96 | privacy: VideoPrivacy.PRIVATE, | ||
97 | scheduleUpdate: { | ||
98 | updateAt: updateAt.toISOString(), | ||
99 | privacy: VideoPrivacy.PUBLIC | ||
100 | } | ||
101 | } | ||
102 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) | ||
103 | |||
104 | await wait(6000) | ||
105 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | ||
106 | }) | ||
107 | |||
108 | it('Should send a new video notification on a remote scheduled publication', async function () { | ||
109 | this.timeout(100000) | ||
110 | |||
111 | // In 2 seconds | ||
112 | const updateAt = new Date(new Date().getTime() + 2000) | ||
113 | |||
114 | const data = { | ||
115 | privacy: VideoPrivacy.PRIVATE, | ||
116 | scheduleUpdate: { | ||
117 | updateAt: updateAt.toISOString(), | ||
118 | privacy: VideoPrivacy.PUBLIC | ||
119 | } | ||
120 | } | ||
121 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) | ||
122 | await waitJobs(servers) | ||
123 | |||
124 | await wait(6000) | ||
125 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | ||
126 | }) | ||
127 | |||
128 | it('Should not send a notification before the video is published', async function () { | ||
129 | this.timeout(150000) | ||
130 | |||
131 | const updateAt = new Date(new Date().getTime() + 1000000) | ||
132 | |||
133 | const data = { | ||
134 | privacy: VideoPrivacy.PRIVATE, | ||
135 | scheduleUpdate: { | ||
136 | updateAt: updateAt.toISOString(), | ||
137 | privacy: VideoPrivacy.PUBLIC | ||
138 | } | ||
139 | } | ||
140 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) | ||
141 | |||
142 | await wait(6000) | ||
143 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) | ||
144 | }) | ||
145 | |||
146 | it('Should send a new video notification when a video becomes public', async function () { | ||
147 | this.timeout(50000) | ||
148 | |||
149 | const data = { privacy: VideoPrivacy.PRIVATE } | ||
150 | const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) | ||
151 | |||
152 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) | ||
153 | |||
154 | await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) | ||
155 | |||
156 | await waitJobs(servers) | ||
157 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | ||
158 | }) | ||
159 | |||
160 | it('Should send a new video notification when a remote video becomes public', async function () { | ||
161 | this.timeout(120000) | ||
162 | |||
163 | const data = { privacy: VideoPrivacy.PRIVATE } | ||
164 | const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) | ||
165 | |||
166 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) | ||
167 | |||
168 | await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) | ||
169 | |||
170 | await waitJobs(servers) | ||
171 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | ||
172 | }) | ||
173 | |||
174 | it('Should not send a new video notification when a video becomes unlisted', async function () { | ||
175 | this.timeout(50000) | ||
176 | |||
177 | const data = { privacy: VideoPrivacy.PRIVATE } | ||
178 | const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) | ||
179 | |||
180 | await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } }) | ||
181 | |||
182 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) | ||
183 | }) | ||
184 | |||
185 | it('Should not send a new video notification when a remote video becomes unlisted', async function () { | ||
186 | this.timeout(100000) | ||
187 | |||
188 | const data = { privacy: VideoPrivacy.PRIVATE } | ||
189 | const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) | ||
190 | |||
191 | await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } }) | ||
192 | |||
193 | await waitJobs(servers) | ||
194 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) | ||
195 | }) | ||
196 | |||
197 | it('Should send a new video notification after a video import', async function () { | ||
198 | this.timeout(100000) | ||
199 | |||
200 | const name = 'video import ' + buildUUID() | ||
201 | |||
202 | const attributes = { | ||
203 | name, | ||
204 | channelId, | ||
205 | privacy: VideoPrivacy.PUBLIC, | ||
206 | targetUrl: FIXTURE_URLS.goodVideo | ||
207 | } | ||
208 | const { video } = await servers[0].imports.importVideo({ attributes }) | ||
209 | |||
210 | await waitJobs(servers) | ||
211 | |||
212 | await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID: video.shortUUID, checkType: 'presence' }) | ||
213 | }) | ||
214 | }) | ||
215 | |||
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 () { | ||
229 | this.timeout(50000) | ||
230 | |||
231 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1) | ||
232 | await waitJobs(servers) | ||
233 | |||
234 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) | ||
235 | }) | ||
236 | |||
237 | it('Should not send a notification if the wait transcoding is false', async function () { | ||
238 | this.timeout(100_000) | ||
239 | |||
240 | await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: false }) | ||
241 | await waitJobs(servers) | ||
242 | |||
243 | const notification = await servers[0].notifications.getLatest({ token: userAccessToken }) | ||
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 () { | ||
250 | this.timeout(100_000) | ||
251 | |||
252 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true, fixture: 'video_short_240p.mp4' }) | ||
253 | await waitJobs(servers) | ||
254 | |||
255 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | ||
256 | }) | ||
257 | |||
258 | it('Should send a notification with a transcoded video', async function () { | ||
259 | this.timeout(100_000) | ||
260 | |||
261 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true }) | ||
262 | await waitJobs(servers) | ||
263 | |||
264 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | ||
265 | }) | ||
266 | |||
267 | it('Should send a notification when an imported video is transcoded', async function () { | ||
268 | this.timeout(120000) | ||
269 | |||
270 | const name = 'video import ' + buildUUID() | ||
271 | |||
272 | const attributes = { | ||
273 | name, | ||
274 | channelId, | ||
275 | privacy: VideoPrivacy.PUBLIC, | ||
276 | targetUrl: FIXTURE_URLS.goodVideo, | ||
277 | waitTranscoding: true | ||
278 | } | ||
279 | const { video } = await servers[1].imports.importVideo({ attributes }) | ||
280 | |||
281 | await waitJobs(servers) | ||
282 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID: video.shortUUID, checkType: 'presence' }) | ||
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 | ||
289 | const updateAt = new Date(new Date().getTime() + 2000) | ||
290 | |||
291 | const data = { | ||
292 | privacy: VideoPrivacy.PRIVATE, | ||
293 | scheduleUpdate: { | ||
294 | updateAt: updateAt.toISOString(), | ||
295 | privacy: VideoPrivacy.PUBLIC | ||
296 | } | ||
297 | } | ||
298 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) | ||
299 | |||
300 | await wait(6000) | ||
301 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | ||
302 | }) | ||
303 | |||
304 | it('Should not send a notification before the video is published', async function () { | ||
305 | this.timeout(150000) | ||
306 | |||
307 | const updateAt = new Date(new Date().getTime() + 1000000) | ||
308 | |||
309 | const data = { | ||
310 | privacy: VideoPrivacy.PRIVATE, | ||
311 | scheduleUpdate: { | ||
312 | updateAt: updateAt.toISOString(), | ||
313 | privacy: VideoPrivacy.PUBLIC | ||
314 | } | ||
315 | } | ||
316 | const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) | ||
317 | |||
318 | await wait(6000) | ||
319 | await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) | ||
320 | }) | ||
321 | }) | ||
322 | |||
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, | ||
345 | replaySettings: { privacy: VideoPrivacy.PUBLIC }, | ||
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, | ||
371 | replaySettings: { privacy: VideoPrivacy.PUBLIC }, | ||
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 | |||
395 | describe('Video studio', function () { | ||
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 | |||
407 | it('Should send a notification after studio edition', async function () { | ||
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 | |||
415 | const tasks: VideoStudioTask[] = [ | ||
416 | { | ||
417 | name: 'cut', | ||
418 | options: { | ||
419 | start: 0, | ||
420 | end: 1 | ||
421 | } | ||
422 | } | ||
423 | ] | ||
424 | await servers[1].videoStudio.createEditionTasks({ videoId: id, tasks }) | ||
425 | await waitJobs(servers) | ||
426 | |||
427 | await checkVideoStudioEditionIsFinished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) | ||
428 | }) | ||
429 | }) | ||
430 | |||
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 | |||
446 | const name = 'video import ' + buildUUID() | ||
447 | |||
448 | const attributes = { | ||
449 | name, | ||
450 | channelId, | ||
451 | privacy: VideoPrivacy.PRIVATE, | ||
452 | targetUrl: FIXTURE_URLS.badVideo | ||
453 | } | ||
454 | const { video: { shortUUID } } = await servers[0].imports.importVideo({ attributes }) | ||
455 | |||
456 | await waitJobs(servers) | ||
457 | |||
458 | const url = FIXTURE_URLS.badVideo | ||
459 | await checkMyVideoImportIsFinished({ ...baseParams, videoName: name, shortUUID, url, success: false, checkType: 'presence' }) | ||
460 | }) | ||
461 | |||
462 | it('Should send a notification when the video import succeeded', async function () { | ||
463 | this.timeout(70000) | ||
464 | |||
465 | const name = 'video import ' + buildUUID() | ||
466 | |||
467 | const attributes = { | ||
468 | name, | ||
469 | channelId, | ||
470 | privacy: VideoPrivacy.PRIVATE, | ||
471 | targetUrl: FIXTURE_URLS.goodVideo | ||
472 | } | ||
473 | const { video: { shortUUID } } = await servers[0].imports.importVideo({ attributes }) | ||
474 | |||
475 | await waitJobs(servers) | ||
476 | |||
477 | const url = FIXTURE_URLS.goodVideo | ||
478 | await checkMyVideoImportIsFinished({ ...baseParams, videoName: name, shortUUID, url, success: true, checkType: 'presence' }) | ||
479 | }) | ||
480 | }) | ||
481 | |||
482 | describe('New actor follow', function () { | ||
483 | let baseParams: CheckerBaseParams | ||
484 | const myChannelName = 'super channel name' | ||
485 | const myUserName = 'super user name' | ||
486 | |||
487 | before(async function () { | ||
488 | baseParams = { | ||
489 | server: servers[0], | ||
490 | emails, | ||
491 | socketNotifications: userNotifications, | ||
492 | token: userAccessToken | ||
493 | } | ||
494 | |||
495 | await servers[0].users.updateMe({ displayName: 'super root name' }) | ||
496 | |||
497 | await servers[0].users.updateMe({ | ||
498 | token: userAccessToken, | ||
499 | displayName: myUserName | ||
500 | }) | ||
501 | |||
502 | await servers[1].users.updateMe({ displayName: 'super root 2 name' }) | ||
503 | |||
504 | await servers[0].channels.update({ | ||
505 | token: userAccessToken, | ||
506 | channelName: 'user_1_channel', | ||
507 | attributes: { displayName: myChannelName } | ||
508 | }) | ||
509 | }) | ||
510 | |||
511 | it('Should notify when a local channel is following one of our channel', async function () { | ||
512 | this.timeout(50000) | ||
513 | |||
514 | await servers[0].subscriptions.add({ targetUri: 'user_1_channel@' + servers[0].host }) | ||
515 | await waitJobs(servers) | ||
516 | |||
517 | await checkNewActorFollow({ | ||
518 | ...baseParams, | ||
519 | followType: 'channel', | ||
520 | followerName: 'root', | ||
521 | followerDisplayName: 'super root name', | ||
522 | followingDisplayName: myChannelName, | ||
523 | checkType: 'presence' | ||
524 | }) | ||
525 | |||
526 | await servers[0].subscriptions.remove({ uri: 'user_1_channel@' + servers[0].host }) | ||
527 | }) | ||
528 | |||
529 | it('Should notify when a remote channel is following one of our channel', async function () { | ||
530 | this.timeout(50000) | ||
531 | |||
532 | await servers[1].subscriptions.add({ targetUri: 'user_1_channel@' + servers[0].host }) | ||
533 | await waitJobs(servers) | ||
534 | |||
535 | await checkNewActorFollow({ | ||
536 | ...baseParams, | ||
537 | followType: 'channel', | ||
538 | followerName: 'root', | ||
539 | followerDisplayName: 'super root 2 name', | ||
540 | followingDisplayName: myChannelName, | ||
541 | checkType: 'presence' | ||
542 | }) | ||
543 | |||
544 | await servers[1].subscriptions.remove({ uri: 'user_1_channel@' + servers[0].host }) | ||
545 | }) | ||
546 | |||
547 | // PeerTube does not support account -> account follows | ||
548 | // it('Should notify when a local account is following one of our channel', async function () { | ||
549 | // this.timeout(50000) | ||
550 | // | ||
551 | // await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@' + servers[0].host) | ||
552 | // | ||
553 | // await waitJobs(servers) | ||
554 | // | ||
555 | // await checkNewActorFollow(baseParams, 'account', 'root', 'super root name', myUserName, 'presence') | ||
556 | // }) | ||
557 | |||
558 | // it('Should notify when a remote account is following one of our channel', async function () { | ||
559 | // this.timeout(50000) | ||
560 | // | ||
561 | // await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@' + servers[0].host) | ||
562 | // | ||
563 | // await waitJobs(servers) | ||
564 | // | ||
565 | // await checkNewActorFollow(baseParams, 'account', 'root', 'super root 2 name', myUserName, 'presence') | ||
566 | // }) | ||
567 | }) | ||
568 | |||
569 | after(async function () { | ||
570 | MockSmtpServer.Instance.kill() | ||
571 | |||
572 | await cleanupTests(servers) | ||
573 | }) | ||
574 | }) | ||