diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-07 16:40:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | 2c27e70471120c92e0bc8c8114141fbb31ff98ac (patch) | |
tree | f52d89adc0351168fd1d89cbc07652e1408caaf2 /server/tests/api/notifications | |
parent | 5f8bd4cbb178290da7d8f81e996f19f0eccc8e4c (diff) | |
download | PeerTube-2c27e70471120c92e0bc8c8114141fbb31ff98ac.tar.gz PeerTube-2c27e70471120c92e0bc8c8114141fbb31ff98ac.tar.zst PeerTube-2c27e70471120c92e0bc8c8114141fbb31ff98ac.zip |
Introduce subscriptions command
Diffstat (limited to 'server/tests/api/notifications')
-rw-r--r-- | server/tests/api/notifications/moderation-notifications.ts | 10 | ||||
-rw-r--r-- | server/tests/api/notifications/notifications-api.ts | 19 | ||||
-rw-r--r-- | server/tests/api/notifications/user-notifications.ts | 42 |
3 files changed, 34 insertions, 37 deletions
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index e90640ad6..605b41947 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts | |||
@@ -3,7 +3,6 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { buildUUID } from '@server/helpers/uuid' | 4 | import { buildUUID } from '@server/helpers/uuid' |
5 | import { | 5 | import { |
6 | addUserSubscription, | ||
7 | addVideoCommentThread, | 6 | addVideoCommentThread, |
8 | addVideoToBlacklist, | 7 | addVideoToBlacklist, |
9 | checkAbuseStateChange, | 8 | checkAbuseStateChange, |
@@ -29,7 +28,6 @@ import { | |||
29 | MockSmtpServer, | 28 | MockSmtpServer, |
30 | prepareNotificationsTest, | 29 | prepareNotificationsTest, |
31 | registerUser, | 30 | registerUser, |
32 | removeUserSubscription, | ||
33 | removeVideoFromBlacklist, | 31 | removeVideoFromBlacklist, |
34 | ServerInfo, | 32 | ServerInfo, |
35 | uploadVideo, | 33 | uploadVideo, |
@@ -488,8 +486,8 @@ describe('Test moderation notifications', function () { | |||
488 | autoBlacklistTestsCustomConfig.transcoding.enabled = true | 486 | autoBlacklistTestsCustomConfig.transcoding.enabled = true |
489 | await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig }) | 487 | await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig }) |
490 | 488 | ||
491 | await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 489 | await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) |
492 | await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 490 | await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) |
493 | 491 | ||
494 | }) | 492 | }) |
495 | 493 | ||
@@ -611,8 +609,8 @@ describe('Test moderation notifications', function () { | |||
611 | after(async () => { | 609 | after(async () => { |
612 | await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig }) | 610 | await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig }) |
613 | 611 | ||
614 | await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 612 | await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) |
615 | await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 613 | await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) |
616 | }) | 614 | }) |
617 | }) | 615 | }) |
618 | 616 | ||
diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index 19f9dbbab..1ed98ae7a 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts | |||
@@ -2,21 +2,24 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { addUserSubscription } from '@shared/extra-utils/users/user-subscriptions' | ||
6 | import { cleanupTests, getMyUserInformation, immutableAssign, uploadRandomVideo, waitJobs } from '../../../../shared/extra-utils' | ||
7 | import { ServerInfo } from '../../../../shared/extra-utils/index' | ||
8 | import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' | ||
9 | import { | 5 | import { |
10 | CheckerBaseParams, | 6 | CheckerBaseParams, |
11 | checkNewVideoFromSubscription, | 7 | checkNewVideoFromSubscription, |
8 | cleanupTests, | ||
12 | getAllNotificationsSettings, | 9 | getAllNotificationsSettings, |
10 | getMyUserInformation, | ||
13 | getUserNotifications, | 11 | getUserNotifications, |
12 | immutableAssign, | ||
14 | markAsReadAllNotifications, | 13 | markAsReadAllNotifications, |
15 | markAsReadNotifications, | 14 | markAsReadNotifications, |
15 | MockSmtpServer, | ||
16 | prepareNotificationsTest, | 16 | prepareNotificationsTest, |
17 | updateMyNotificationSettings | 17 | ServerInfo, |
18 | } from '../../../../shared/extra-utils/users/user-notifications' | 18 | updateMyNotificationSettings, |
19 | import { User, UserNotification, UserNotificationSettingValue } from '../../../../shared/models/users' | 19 | uploadRandomVideo, |
20 | waitJobs | ||
21 | } from '@shared/extra-utils' | ||
22 | import { User, UserNotification, UserNotificationSettingValue } from '@shared/models' | ||
20 | 23 | ||
21 | const expect = chai.expect | 24 | const expect = chai.expect |
22 | 25 | ||
@@ -35,7 +38,7 @@ describe('Test notifications API', function () { | |||
35 | userNotifications = res.userNotifications | 38 | userNotifications = res.userNotifications |
36 | server = res.servers[0] | 39 | server = res.servers[0] |
37 | 40 | ||
38 | await addUserSubscription(server.url, userAccessToken, 'root_channel@localhost:' + server.port) | 41 | await server.subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + server.port }) |
39 | 42 | ||
40 | for (let i = 0; i < 10; i++) { | 43 | for (let i = 0; i < 10; i++) { |
41 | await uploadRandomVideo(server, false) | 44 | await uploadRandomVideo(server, false) |
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' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { buildUUID } from '@server/helpers/uuid' | 5 | import { buildUUID } from '@server/helpers/uuid' |
6 | import { | 6 | import { |
7 | cleanupTests, | ||
8 | updateMyUser, | ||
9 | updateVideo, | ||
10 | updateVideoChannel, | ||
11 | uploadRandomVideoOnServers, | ||
12 | wait | ||
13 | } from '../../../../shared/extra-utils' | ||
14 | import { ServerInfo } from '../../../../shared/extra-utils/index' | ||
15 | import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' | ||
16 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||
17 | import { | ||
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, |
26 | import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' | 16 | ServerInfo, |
27 | import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' | 17 | updateMyUser, |
28 | import { UserNotification, UserNotificationType } from '../../../../shared/models/users' | 18 | updateVideo, |
29 | import { VideoPrivacy } from '../../../../shared/models/videos' | 19 | updateVideoChannel, |
20 | uploadRandomVideoOnServers, | ||
21 | wait, | ||
22 | waitJobs | ||
23 | } from '@shared/extra-utils' | ||
24 | import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '@shared/extra-utils/videos/video-imports' | ||
25 | import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models' | ||
30 | 26 | ||
31 | const expect = chai.expect | 27 | const 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 |