aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/user-notifications.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
committerChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
commita24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch)
treea54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/api/check-params/user-notifications.ts
parent5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff)
parentc63830f15403ac4e750829f27d8bbbdc9a59282c (diff)
downloadPeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/api/check-params/user-notifications.ts')
-rw-r--r--server/tests/api/check-params/user-notifications.ts57
1 files changed, 26 insertions, 31 deletions
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts
index 26d4423f9..17edf5aa1 100644
--- a/server/tests/api/check-params/user-notifications.ts
+++ b/server/tests/api/check-params/user-notifications.ts
@@ -2,35 +2,30 @@
2 2
3import 'mocha' 3import 'mocha'
4import { io } from 'socket.io-client' 4import { io } from 'socket.io-client'
5
6import { 5import {
6 checkBadCountPagination,
7 checkBadSortPagination,
8 checkBadStartPagination,
7 cleanupTests, 9 cleanupTests,
8 flushAndRunServer, 10 createSingleServer,
9 immutableAssign,
10 makeGetRequest, 11 makeGetRequest,
11 makePostBodyRequest, 12 makePostBodyRequest,
12 makePutBodyRequest, 13 makePutBodyRequest,
13 ServerInfo, 14 PeerTubeServer,
14 setAccessTokensToServers, 15 setAccessTokensToServers,
15 wait 16 wait
16} from '../../../../shared/extra-utils' 17} from '@shared/extra-utils'
17import { 18import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models'
18 checkBadCountPagination,
19 checkBadSortPagination,
20 checkBadStartPagination
21} from '../../../../shared/extra-utils/requests/check-api-params'
22import { UserNotificationSetting, UserNotificationSettingValue } from '../../../../shared/models/users'
23import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
24 19
25describe('Test user notifications API validators', function () { 20describe('Test user notifications API validators', function () {
26 let server: ServerInfo 21 let server: PeerTubeServer
27 22
28 // --------------------------------------------------------------- 23 // ---------------------------------------------------------------
29 24
30 before(async function () { 25 before(async function () {
31 this.timeout(30000) 26 this.timeout(30000)
32 27
33 server = await flushAndRunServer(1) 28 server = await createSingleServer(1)
34 29
35 await setAccessTokensToServers([ server ]) 30 await setAccessTokensToServers([ server ])
36 }) 31 })
@@ -58,7 +53,7 @@ describe('Test user notifications API validators', function () {
58 unread: 'toto' 53 unread: 'toto'
59 }, 54 },
60 token: server.accessToken, 55 token: server.accessToken,
61 statusCodeExpected: HttpStatusCode.OK_200 56 expectedStatus: HttpStatusCode.OK_200
62 }) 57 })
63 }) 58 })
64 59
@@ -66,7 +61,7 @@ describe('Test user notifications API validators', function () {
66 await makeGetRequest({ 61 await makeGetRequest({
67 url: server.url, 62 url: server.url,
68 path, 63 path,
69 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 64 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
70 }) 65 })
71 }) 66 })
72 67
@@ -75,7 +70,7 @@ describe('Test user notifications API validators', function () {
75 url: server.url, 70 url: server.url,
76 path, 71 path,
77 token: server.accessToken, 72 token: server.accessToken,
78 statusCodeExpected: HttpStatusCode.OK_200 73 expectedStatus: HttpStatusCode.OK_200
79 }) 74 })
80 }) 75 })
81 }) 76 })
@@ -91,7 +86,7 @@ describe('Test user notifications API validators', function () {
91 ids: [ 'hello' ] 86 ids: [ 'hello' ]
92 }, 87 },
93 token: server.accessToken, 88 token: server.accessToken,
94 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 89 expectedStatus: HttpStatusCode.BAD_REQUEST_400
95 }) 90 })
96 91
97 await makePostBodyRequest({ 92 await makePostBodyRequest({
@@ -101,7 +96,7 @@ describe('Test user notifications API validators', function () {
101 ids: [ ] 96 ids: [ ]
102 }, 97 },
103 token: server.accessToken, 98 token: server.accessToken,
104 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 99 expectedStatus: HttpStatusCode.BAD_REQUEST_400
105 }) 100 })
106 101
107 await makePostBodyRequest({ 102 await makePostBodyRequest({
@@ -111,7 +106,7 @@ describe('Test user notifications API validators', function () {
111 ids: 5 106 ids: 5
112 }, 107 },
113 token: server.accessToken, 108 token: server.accessToken,
114 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 109 expectedStatus: HttpStatusCode.BAD_REQUEST_400
115 }) 110 })
116 }) 111 })
117 112
@@ -122,7 +117,7 @@ describe('Test user notifications API validators', function () {
122 fields: { 117 fields: {
123 ids: [ 5 ] 118 ids: [ 5 ]
124 }, 119 },
125 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 120 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
126 }) 121 })
127 }) 122 })
128 123
@@ -134,7 +129,7 @@ describe('Test user notifications API validators', function () {
134 ids: [ 5 ] 129 ids: [ 5 ]
135 }, 130 },
136 token: server.accessToken, 131 token: server.accessToken,
137 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 132 expectedStatus: HttpStatusCode.NO_CONTENT_204
138 }) 133 })
139 }) 134 })
140 }) 135 })
@@ -146,7 +141,7 @@ describe('Test user notifications API validators', function () {
146 await makePostBodyRequest({ 141 await makePostBodyRequest({
147 url: server.url, 142 url: server.url,
148 path, 143 path,
149 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 144 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
150 }) 145 })
151 }) 146 })
152 147
@@ -155,7 +150,7 @@ describe('Test user notifications API validators', function () {
155 url: server.url, 150 url: server.url,
156 path, 151 path,
157 token: server.accessToken, 152 token: server.accessToken,
158 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 153 expectedStatus: HttpStatusCode.NO_CONTENT_204
159 }) 154 })
160 }) 155 })
161 }) 156 })
@@ -187,32 +182,32 @@ describe('Test user notifications API validators', function () {
187 path, 182 path,
188 token: server.accessToken, 183 token: server.accessToken,
189 fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB }, 184 fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB },
190 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 185 expectedStatus: HttpStatusCode.BAD_REQUEST_400
191 }) 186 })
192 }) 187 })
193 188
194 it('Should fail with incorrect field values', async function () { 189 it('Should fail with incorrect field values', async function () {
195 { 190 {
196 const fields = immutableAssign(correctFields, { newCommentOnMyVideo: 15 }) 191 const fields = { ...correctFields, newCommentOnMyVideo: 15 }
197 192
198 await makePutBodyRequest({ 193 await makePutBodyRequest({
199 url: server.url, 194 url: server.url,
200 path, 195 path,
201 token: server.accessToken, 196 token: server.accessToken,
202 fields, 197 fields,
203 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 198 expectedStatus: HttpStatusCode.BAD_REQUEST_400
204 }) 199 })
205 } 200 }
206 201
207 { 202 {
208 const fields = immutableAssign(correctFields, { newCommentOnMyVideo: 'toto' }) 203 const fields = { ...correctFields, newCommentOnMyVideo: 'toto' }
209 204
210 await makePutBodyRequest({ 205 await makePutBodyRequest({
211 url: server.url, 206 url: server.url,
212 path, 207 path,
213 fields, 208 fields,
214 token: server.accessToken, 209 token: server.accessToken,
215 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 210 expectedStatus: HttpStatusCode.BAD_REQUEST_400
216 }) 211 })
217 } 212 }
218 }) 213 })
@@ -222,7 +217,7 @@ describe('Test user notifications API validators', function () {
222 url: server.url, 217 url: server.url,
223 path, 218 path,
224 fields: correctFields, 219 fields: correctFields,
225 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 220 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
226 }) 221 })
227 }) 222 })
228 223
@@ -232,7 +227,7 @@ describe('Test user notifications API validators', function () {
232 path, 227 path,
233 token: server.accessToken, 228 token: server.accessToken,
234 fields: correctFields, 229 fields: correctFields,
235 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 230 expectedStatus: HttpStatusCode.NO_CONTENT_204
236 }) 231 })
237 }) 232 })
238 }) 233 })