aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/users
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/users')
-rw-r--r--server/tests/api/users/user-notifications.ts50
-rw-r--r--server/tests/api/users/users.ts4
2 files changed, 34 insertions, 20 deletions
diff --git a/server/tests/api/users/user-notifications.ts b/server/tests/api/users/user-notifications.ts
index ae77b4db2..ad68d8e69 100644
--- a/server/tests/api/users/user-notifications.ts
+++ b/server/tests/api/users/user-notifications.ts
@@ -37,7 +37,8 @@ import {
37 getLastNotification, 37 getLastNotification,
38 getUserNotifications, 38 getUserNotifications,
39 markAsReadNotifications, 39 markAsReadNotifications,
40 updateMyNotificationSettings 40 updateMyNotificationSettings,
41 markAsReadAllNotifications
41} from '../../../../shared/utils/users/user-notifications' 42} from '../../../../shared/utils/users/user-notifications'
42import { 43import {
43 User, 44 User,
@@ -88,15 +89,15 @@ describe('Test users notifications', function () {
88 let channelId: number 89 let channelId: number
89 90
90 const allNotificationSettings: UserNotificationSetting = { 91 const allNotificationSettings: UserNotificationSetting = {
91 newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 92 newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
92 newCommentOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 93 newCommentOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
93 videoAbuseAsModerator: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 94 videoAbuseAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
94 blacklistOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 95 blacklistOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
95 myVideoImportFinished: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 96 myVideoImportFinished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
96 myVideoPublished: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 97 myVideoPublished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
97 commentMention: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 98 commentMention: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
98 newFollow: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 99 newFollow: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
99 newUserRegistration: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL 100 newUserRegistration: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
100 } 101 }
101 102
102 before(async function () { 103 before(async function () {
@@ -174,7 +175,10 @@ describe('Test users notifications', function () {
174 }) 175 })
175 176
176 it('Should send a new video notification if the user follows the local video publisher', async function () { 177 it('Should send a new video notification if the user follows the local video publisher', async function () {
178 this.timeout(10000)
179
177 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9001') 180 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9001')
181 await waitJobs(servers)
178 182
179 const { name, uuid } = await uploadVideoByLocalAccount(servers) 183 const { name, uuid } = await uploadVideoByLocalAccount(servers)
180 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 184 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
@@ -184,6 +188,7 @@ describe('Test users notifications', function () {
184 this.timeout(50000) // Server 2 has transcoding enabled 188 this.timeout(50000) // Server 2 has transcoding enabled
185 189
186 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9002') 190 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9002')
191 await waitJobs(servers)
187 192
188 const { name, uuid } = await uploadVideoByRemoteAccount(servers) 193 const { name, uuid } = await uploadVideoByRemoteAccount(servers)
189 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 194 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
@@ -822,8 +827,9 @@ describe('Test users notifications', function () {
822 }) 827 })
823 828
824 it('Should notify when a local channel is following one of our channel', async function () { 829 it('Should notify when a local channel is following one of our channel', async function () {
825 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001') 830 this.timeout(10000)
826 831
832 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001')
827 await waitJobs(servers) 833 await waitJobs(servers)
828 834
829 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') 835 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence')
@@ -832,8 +838,9 @@ describe('Test users notifications', function () {
832 }) 838 })
833 839
834 it('Should notify when a remote channel is following one of our channel', async function () { 840 it('Should notify when a remote channel is following one of our channel', async function () {
835 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001') 841 this.timeout(10000)
836 842
843 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001')
837 await waitJobs(servers) 844 await waitJobs(servers)
838 845
839 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') 846 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence')
@@ -895,6 +902,15 @@ describe('Test users notifications', function () {
895 expect(notification.read).to.be.false 902 expect(notification.read).to.be.false
896 } 903 }
897 }) 904 })
905
906 it('Should mark as read all notifications', async function () {
907 await markAsReadAllNotifications(servers[ 0 ].url, userAccessToken)
908
909 const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 0, 10, true)
910
911 expect(res.body.total).to.equal(0)
912 expect(res.body.data).to.have.lengthOf(0)
913 })
898 }) 914 })
899 915
900 describe('Notification settings', function () { 916 describe('Notification settings', function () {
@@ -928,13 +944,13 @@ describe('Test users notifications', function () {
928 944
929 it('Should only have web notifications', async function () { 945 it('Should only have web notifications', async function () {
930 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, { 946 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
931 newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION 947 newVideoFromSubscription: UserNotificationSettingValue.WEB
932 })) 948 }))
933 949
934 { 950 {
935 const res = await getMyUserInformation(servers[0].url, userAccessToken) 951 const res = await getMyUserInformation(servers[0].url, userAccessToken)
936 const info = res.body as User 952 const info = res.body as User
937 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB_NOTIFICATION) 953 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
938 } 954 }
939 955
940 const { name, uuid } = await uploadVideoByLocalAccount(servers) 956 const { name, uuid } = await uploadVideoByLocalAccount(servers)
@@ -976,13 +992,15 @@ describe('Test users notifications', function () {
976 992
977 it('Should have email and web notifications', async function () { 993 it('Should have email and web notifications', async function () {
978 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, { 994 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
979 newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL 995 newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
980 })) 996 }))
981 997
982 { 998 {
983 const res = await getMyUserInformation(servers[0].url, userAccessToken) 999 const res = await getMyUserInformation(servers[0].url, userAccessToken)
984 const info = res.body as User 1000 const info = res.body as User
985 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL) 1001 expect(info.notificationSettings.newVideoFromSubscription).to.equal(
1002 UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
1003 )
986 } 1004 }
987 1005
988 const { name, uuid } = await uploadVideoByLocalAccount(servers) 1006 const { name, uuid } = await uploadVideoByLocalAccount(servers)
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 4914c8ed5..ad98ab1c7 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -501,10 +501,6 @@ describe('Test users', function () {
501 accessTokenUser = await userLogin(server, user) 501 accessTokenUser = await userLogin(server, user)
502 }) 502 })
503 503
504 it('Should not be able to delete a user by a moderator', async function () {
505 await removeUser(server.url, 2, accessTokenUser, 403)
506 })
507
508 it('Should be able to list video blacklist by a moderator', async function () { 504 it('Should be able to list video blacklist by a moderator', async function () {
509 await getBlacklistedVideosList(server.url, accessTokenUser) 505 await getBlacklistedVideosList(server.url, accessTokenUser)
510 }) 506 })