diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-08 17:26:01 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-08 17:30:48 +0200 |
commit | 883993c81ecc2388d4a4b37b29b81b6de73d264f (patch) | |
tree | f0f76995b6762b10a0c1a7ccc2b5d952f68014ea /server/tests/api | |
parent | 0dc647775881eb1378b213a530996cd096de24ea (diff) | |
download | PeerTube-883993c81ecc2388d4a4b37b29b81b6de73d264f.tar.gz PeerTube-883993c81ecc2388d4a4b37b29b81b6de73d264f.tar.zst PeerTube-883993c81ecc2388d4a4b37b29b81b6de73d264f.zip |
Add notification on new instance follower (server side)
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/user-notifications.ts | 3 | ||||
-rw-r--r-- | server/tests/api/index-1.ts | 1 | ||||
-rw-r--r-- | server/tests/api/notifications/index.ts | 1 | ||||
-rw-r--r-- | server/tests/api/notifications/user-notifications.ts (renamed from server/tests/api/users/user-notifications.ts) | 35 | ||||
-rw-r--r-- | server/tests/api/users/index.ts | 1 |
5 files changed, 35 insertions, 6 deletions
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 36eaceac7..4b75f6920 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts | |||
@@ -174,7 +174,8 @@ describe('Test user notifications API validators', function () { | |||
174 | myVideoPublished: UserNotificationSettingValue.WEB, | 174 | myVideoPublished: UserNotificationSettingValue.WEB, |
175 | commentMention: UserNotificationSettingValue.WEB, | 175 | commentMention: UserNotificationSettingValue.WEB, |
176 | newFollow: UserNotificationSettingValue.WEB, | 176 | newFollow: UserNotificationSettingValue.WEB, |
177 | newUserRegistration: UserNotificationSettingValue.WEB | 177 | newUserRegistration: UserNotificationSettingValue.WEB, |
178 | newInstanceFollower: UserNotificationSettingValue.WEB | ||
178 | } | 179 | } |
179 | 180 | ||
180 | it('Should fail with missing fields', async function () { | 181 | it('Should fail with missing fields', async function () { |
diff --git a/server/tests/api/index-1.ts b/server/tests/api/index-1.ts index 80d752f42..75cdd9025 100644 --- a/server/tests/api/index-1.ts +++ b/server/tests/api/index-1.ts | |||
@@ -1,2 +1,3 @@ | |||
1 | import './check-params' | 1 | import './check-params' |
2 | import './notifications' | ||
2 | import './search' | 3 | import './search' |
diff --git a/server/tests/api/notifications/index.ts b/server/tests/api/notifications/index.ts new file mode 100644 index 000000000..95ac8fc51 --- /dev/null +++ b/server/tests/api/notifications/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './user-notifications' | |||
diff --git a/server/tests/api/users/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index ac47978e2..7bff52796 100644 --- a/server/tests/api/users/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts | |||
@@ -19,7 +19,7 @@ import { | |||
19 | userLogin, | 19 | userLogin, |
20 | wait, | 20 | wait, |
21 | getCustomConfig, | 21 | getCustomConfig, |
22 | updateCustomConfig, getVideoThreadComments, getVideoCommentThreads | 22 | updateCustomConfig, getVideoThreadComments, getVideoCommentThreads, follow |
23 | } from '../../../../shared/utils' | 23 | } from '../../../../shared/utils' |
24 | import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/utils/index' | 24 | import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/utils/index' |
25 | import { setAccessTokensToServers } from '../../../../shared/utils/users/login' | 25 | import { setAccessTokensToServers } from '../../../../shared/utils/users/login' |
@@ -41,7 +41,7 @@ import { | |||
41 | getUserNotifications, | 41 | getUserNotifications, |
42 | markAsReadNotifications, | 42 | markAsReadNotifications, |
43 | updateMyNotificationSettings, | 43 | updateMyNotificationSettings, |
44 | markAsReadAllNotifications | 44 | markAsReadAllNotifications, checkNewInstanceFollower |
45 | } from '../../../../shared/utils/users/user-notifications' | 45 | } from '../../../../shared/utils/users/user-notifications' |
46 | import { | 46 | import { |
47 | User, | 47 | User, |
@@ -103,7 +103,8 @@ describe('Test users notifications', function () { | |||
103 | myVideoPublished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 103 | myVideoPublished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
104 | commentMention: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 104 | commentMention: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
105 | newFollow: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 105 | newFollow: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
106 | newUserRegistration: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL | 106 | newUserRegistration: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
107 | newInstanceFollower: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL | ||
107 | } | 108 | } |
108 | 109 | ||
109 | before(async function () { | 110 | before(async function () { |
@@ -118,7 +119,7 @@ describe('Test users notifications', function () { | |||
118 | hostname: 'localhost' | 119 | hostname: 'localhost' |
119 | } | 120 | } |
120 | } | 121 | } |
121 | servers = await flushAndRunMultipleServers(2, overrideConfig) | 122 | servers = await flushAndRunMultipleServers(3, overrideConfig) |
122 | 123 | ||
123 | // Get the access tokens | 124 | // Get the access tokens |
124 | await setAccessTokensToServers(servers) | 125 | await setAccessTokensToServers(servers) |
@@ -861,6 +862,32 @@ describe('Test users notifications', function () { | |||
861 | }) | 862 | }) |
862 | }) | 863 | }) |
863 | 864 | ||
865 | describe('New instance follower', function () { | ||
866 | let baseParams: CheckerBaseParams | ||
867 | |||
868 | before(async () => { | ||
869 | baseParams = { | ||
870 | server: servers[0], | ||
871 | emails, | ||
872 | socketNotifications: adminNotifications, | ||
873 | token: servers[0].accessToken | ||
874 | } | ||
875 | }) | ||
876 | |||
877 | it('Should send a notification only to admin when there is a new instance follower', async function () { | ||
878 | this.timeout(10000) | ||
879 | |||
880 | await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken) | ||
881 | |||
882 | await waitJobs(servers) | ||
883 | |||
884 | await checkNewInstanceFollower(baseParams, 'localhost:9003', 'presence') | ||
885 | |||
886 | const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } | ||
887 | await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:9003', 'absence') | ||
888 | }) | ||
889 | }) | ||
890 | |||
864 | describe('New actor follow', function () { | 891 | describe('New actor follow', function () { |
865 | let baseParams: CheckerBaseParams | 892 | let baseParams: CheckerBaseParams |
866 | let myChannelName = 'super channel name' | 893 | let myChannelName = 'super channel name' |
diff --git a/server/tests/api/users/index.ts b/server/tests/api/users/index.ts index 52ba6984e..fcd022429 100644 --- a/server/tests/api/users/index.ts +++ b/server/tests/api/users/index.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import './users-verification' | 1 | import './users-verification' |
2 | import './user-notifications' | ||
3 | import './blocklist' | 2 | import './blocklist' |
4 | import './user-subscriptions' | 3 | import './user-subscriptions' |
5 | import './users' | 4 | import './users' |