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.ts47
1 files changed, 42 insertions, 5 deletions
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index 62b797b47..15a34f5aa 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -14,10 +14,13 @@ import {
14 getVideoCommentThreads, 14 getVideoCommentThreads,
15 getVideoThreadComments, 15 getVideoThreadComments,
16 immutableAssign, 16 immutableAssign,
17 MockInstancesIndex,
17 registerUser, 18 registerUser,
18 removeVideoFromBlacklist, 19 removeVideoFromBlacklist,
19 reportVideoAbuse, unfollow, 20 reportVideoAbuse,
20 updateCustomConfig, updateCustomSubConfig, 21 unfollow,
22 updateCustomConfig,
23 updateCustomSubConfig,
21 updateMyUser, 24 updateMyUser,
22 updateVideo, 25 updateVideo,
23 updateVideoChannel, 26 updateVideoChannel,
@@ -29,6 +32,7 @@ import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/l
29import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 32import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
30import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io' 33import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io'
31import { 34import {
35 checkAutoInstanceFollowing,
32 checkCommentMention, 36 checkCommentMention,
33 CheckerBaseParams, 37 CheckerBaseParams,
34 checkMyVideoImportIsFinished, 38 checkMyVideoImportIsFinished,
@@ -45,8 +49,7 @@ import {
45 getUserNotifications, 49 getUserNotifications,
46 markAsReadAllNotifications, 50 markAsReadAllNotifications,
47 markAsReadNotifications, 51 markAsReadNotifications,
48 updateMyNotificationSettings, 52 updateMyNotificationSettings
49 checkAutoInstanceFollowing
50} from '../../../../shared/extra-utils/users/user-notifications' 53} from '../../../../shared/extra-utils/users/user-notifications'
51import { 54import {
52 User, 55 User,
@@ -875,7 +878,18 @@ describe('Test users notifications', function () {
875 }) 878 })
876 }) 879 })
877 880
878 describe('New instance follower', function () { 881 describe('New instance follows', function () {
882 const instanceIndexServer = new MockInstancesIndex()
883 const config = {
884 followings: {
885 instance: {
886 autoFollowIndex: {
887 indexUrl: 'http://localhost:42100',
888 enabled: true
889 }
890 }
891 }
892 }
879 let baseParams: CheckerBaseParams 893 let baseParams: CheckerBaseParams
880 894
881 before(async () => { 895 before(async () => {
@@ -885,6 +899,9 @@ describe('Test users notifications', function () {
885 socketNotifications: adminNotifications, 899 socketNotifications: adminNotifications,
886 token: servers[0].accessToken 900 token: servers[0].accessToken
887 } 901 }
902
903 await instanceIndexServer.initialize()
904 instanceIndexServer.addInstance(servers[1].host)
888 }) 905 })
889 906
890 it('Should send a notification only to admin when there is a new instance follower', async function () { 907 it('Should send a notification only to admin when there is a new instance follower', async function () {
@@ -928,6 +945,26 @@ describe('Test users notifications', function () {
928 945
929 config.followings.instance.autoFollowBack.enabled = false 946 config.followings.instance.autoFollowBack.enabled = false
930 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) 947 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
948 await unfollow(servers[0].url, servers[0].accessToken, servers[2])
949 await unfollow(servers[2].url, servers[2].accessToken, servers[0])
950 })
951
952 it('Should send a notification on auto instances index follow', async function () {
953 this.timeout(30000)
954 await unfollow(servers[0].url, servers[0].accessToken, servers[1])
955
956 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
957
958 await wait(5000)
959 await waitJobs(servers)
960
961 const followerHost = servers[0].host
962 const followingHost = servers[1].host
963 await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
964
965 config.followings.instance.autoFollowIndex.enabled = false
966 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
967 await unfollow(servers[0].url, servers[0].accessToken, servers[1])
931 }) 968 })
932 }) 969 })
933 970