diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/user-notifications.ts | 51 | ||||
-rw-r--r-- | server/tests/api/check-params/users.ts | 3 | ||||
-rw-r--r-- | server/tests/api/users/user-notifications.ts | 50 | ||||
-rw-r--r-- | server/tests/api/users/users.ts | 4 |
4 files changed, 76 insertions, 32 deletions
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 635f5c9a3..714f481e9 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts | |||
@@ -100,6 +100,16 @@ describe('Test user notifications API validators', function () { | |||
100 | url: server.url, | 100 | url: server.url, |
101 | path, | 101 | path, |
102 | fields: { | 102 | fields: { |
103 | ids: [ ] | ||
104 | }, | ||
105 | token: server.accessToken, | ||
106 | statusCodeExpected: 400 | ||
107 | }) | ||
108 | |||
109 | await makePostBodyRequest({ | ||
110 | url: server.url, | ||
111 | path, | ||
112 | fields: { | ||
103 | ids: 5 | 113 | ids: 5 |
104 | }, | 114 | }, |
105 | token: server.accessToken, | 115 | token: server.accessToken, |
@@ -131,18 +141,39 @@ describe('Test user notifications API validators', function () { | |||
131 | }) | 141 | }) |
132 | }) | 142 | }) |
133 | 143 | ||
144 | describe('When marking as read my notifications', function () { | ||
145 | const path = '/api/v1/users/me/notifications/read-all' | ||
146 | |||
147 | it('Should fail with a non authenticated user', async function () { | ||
148 | await makePostBodyRequest({ | ||
149 | url: server.url, | ||
150 | path, | ||
151 | statusCodeExpected: 401 | ||
152 | }) | ||
153 | }) | ||
154 | |||
155 | it('Should succeed with the correct parameters', async function () { | ||
156 | await makePostBodyRequest({ | ||
157 | url: server.url, | ||
158 | path, | ||
159 | token: server.accessToken, | ||
160 | statusCodeExpected: 204 | ||
161 | }) | ||
162 | }) | ||
163 | }) | ||
164 | |||
134 | describe('When updating my notification settings', function () { | 165 | describe('When updating my notification settings', function () { |
135 | const path = '/api/v1/users/me/notification-settings' | 166 | const path = '/api/v1/users/me/notification-settings' |
136 | const correctFields: UserNotificationSetting = { | 167 | const correctFields: UserNotificationSetting = { |
137 | newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION, | 168 | newVideoFromSubscription: UserNotificationSettingValue.WEB, |
138 | newCommentOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION, | 169 | newCommentOnMyVideo: UserNotificationSettingValue.WEB, |
139 | videoAbuseAsModerator: UserNotificationSettingValue.WEB_NOTIFICATION, | 170 | videoAbuseAsModerator: UserNotificationSettingValue.WEB, |
140 | blacklistOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION, | 171 | blacklistOnMyVideo: UserNotificationSettingValue.WEB, |
141 | myVideoImportFinished: UserNotificationSettingValue.WEB_NOTIFICATION, | 172 | myVideoImportFinished: UserNotificationSettingValue.WEB, |
142 | myVideoPublished: UserNotificationSettingValue.WEB_NOTIFICATION, | 173 | myVideoPublished: UserNotificationSettingValue.WEB, |
143 | commentMention: UserNotificationSettingValue.WEB_NOTIFICATION, | 174 | commentMention: UserNotificationSettingValue.WEB, |
144 | newFollow: UserNotificationSettingValue.WEB_NOTIFICATION, | 175 | newFollow: UserNotificationSettingValue.WEB, |
145 | newUserRegistration: UserNotificationSettingValue.WEB_NOTIFICATION | 176 | newUserRegistration: UserNotificationSettingValue.WEB |
146 | } | 177 | } |
147 | 178 | ||
148 | it('Should fail with missing fields', async function () { | 179 | it('Should fail with missing fields', async function () { |
@@ -150,7 +181,7 @@ describe('Test user notifications API validators', function () { | |||
150 | url: server.url, | 181 | url: server.url, |
151 | path, | 182 | path, |
152 | token: server.accessToken, | 183 | token: server.accessToken, |
153 | fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION }, | 184 | fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB }, |
154 | statusCodeExpected: 400 | 185 | statusCodeExpected: 400 |
155 | }) | 186 | }) |
156 | }) | 187 | }) |
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index f8044cbd4..a3e8e2e9c 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -485,11 +485,10 @@ describe('Test users API validators', function () { | |||
485 | email: 'email@example.com', | 485 | email: 'email@example.com', |
486 | emailVerified: true, | 486 | emailVerified: true, |
487 | videoQuota: 42, | 487 | videoQuota: 42, |
488 | role: UserRole.MODERATOR | 488 | role: UserRole.USER |
489 | } | 489 | } |
490 | 490 | ||
491 | await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 }) | 491 | await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 }) |
492 | userAccessToken = await userLogin(server, user) | ||
493 | }) | 492 | }) |
494 | }) | 493 | }) |
495 | 494 | ||
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' |
42 | import { | 43 | import { |
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 | }) |