aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/notifications/user-notifications.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/notifications/user-notifications.ts')
-rw-r--r--server/tests/api/notifications/user-notifications.ts42
1 files changed, 19 insertions, 23 deletions
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index ace7e48c7..15be983f2 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -4,29 +4,25 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { buildUUID } from '@server/helpers/uuid' 5import { buildUUID } from '@server/helpers/uuid'
6import { 6import {
7 cleanupTests,
8 updateMyUser,
9 updateVideo,
10 updateVideoChannel,
11 uploadRandomVideoOnServers,
12 wait
13} from '../../../../shared/extra-utils'
14import { ServerInfo } from '../../../../shared/extra-utils/index'
15import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email'
16import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
17import {
18 CheckerBaseParams, 7 CheckerBaseParams,
19 checkMyVideoImportIsFinished, 8 checkMyVideoImportIsFinished,
20 checkNewActorFollow, 9 checkNewActorFollow,
21 checkNewVideoFromSubscription, 10 checkNewVideoFromSubscription,
22 checkVideoIsPublished, 11 checkVideoIsPublished,
12 cleanupTests,
23 getLastNotification, 13 getLastNotification,
24 prepareNotificationsTest 14 MockSmtpServer,
25} from '../../../../shared/extra-utils/users/user-notifications' 15 prepareNotificationsTest,
26import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' 16 ServerInfo,
27import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' 17 updateMyUser,
28import { UserNotification, UserNotificationType } from '../../../../shared/models/users' 18 updateVideo,
29import { VideoPrivacy } from '../../../../shared/models/videos' 19 updateVideoChannel,
20 uploadRandomVideoOnServers,
21 wait,
22 waitJobs
23} from '@shared/extra-utils'
24import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '@shared/extra-utils/videos/video-imports'
25import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models'
30 26
31const expect = chai.expect 27const expect = chai.expect
32 28
@@ -79,7 +75,7 @@ describe('Test user notifications', function () {
79 it('Should send a new video notification if the user follows the local video publisher', async function () { 75 it('Should send a new video notification if the user follows the local video publisher', async function () {
80 this.timeout(15000) 76 this.timeout(15000)
81 77
82 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[0].port) 78 await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
83 await waitJobs(servers) 79 await waitJobs(servers)
84 80
85 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1) 81 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1)
@@ -89,7 +85,7 @@ describe('Test user notifications', function () {
89 it('Should send a new video notification from a remote account', async function () { 85 it('Should send a new video notification from a remote account', async function () {
90 this.timeout(150000) // Server 2 has transcoding enabled 86 this.timeout(150000) // Server 2 has transcoding enabled
91 87
92 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[1].port) 88 await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port })
93 await waitJobs(servers) 89 await waitJobs(servers)
94 90
95 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2) 91 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2)
@@ -418,23 +414,23 @@ describe('Test user notifications', function () {
418 it('Should notify when a local channel is following one of our channel', async function () { 414 it('Should notify when a local channel is following one of our channel', async function () {
419 this.timeout(50000) 415 this.timeout(50000)
420 416
421 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) 417 await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
422 await waitJobs(servers) 418 await waitJobs(servers)
423 419
424 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') 420 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence')
425 421
426 await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) 422 await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
427 }) 423 })
428 424
429 it('Should notify when a remote channel is following one of our channel', async function () { 425 it('Should notify when a remote channel is following one of our channel', async function () {
430 this.timeout(50000) 426 this.timeout(50000)
431 427
432 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) 428 await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
433 await waitJobs(servers) 429 await waitJobs(servers)
434 430
435 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') 431 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence')
436 432
437 await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) 433 await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
438 }) 434 })
439 435
440 // PeerTube does not support accout -> account follows 436 // PeerTube does not support accout -> account follows