diff options
Diffstat (limited to 'server/tests/api/check-params/search.ts')
-rw-r--r-- | server/tests/api/check-params/search.ts | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts index 4a2fc1197..7973c112f 100644 --- a/server/tests/api/check-params/search.ts +++ b/server/tests/api/check-params/search.ts | |||
@@ -8,7 +8,6 @@ import { | |||
8 | checkBadStartPagination, | 8 | checkBadStartPagination, |
9 | cleanupTests, | 9 | cleanupTests, |
10 | flushAndRunServer, | 10 | flushAndRunServer, |
11 | immutableAssign, | ||
12 | makeGetRequest, | 11 | makeGetRequest, |
13 | ServerInfo, | 12 | ServerInfo, |
14 | setAccessTokensToServers | 13 | setAccessTokensToServers |
@@ -63,78 +62,78 @@ describe('Test videos API validator', function () { | |||
63 | }) | 62 | }) |
64 | 63 | ||
65 | it('Should fail with an invalid category', async function () { | 64 | it('Should fail with an invalid category', async function () { |
66 | const customQuery1 = immutableAssign(query, { categoryOneOf: [ 'aa', 'b' ] }) | 65 | const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] } |
67 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 66 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
68 | 67 | ||
69 | const customQuery2 = immutableAssign(query, { categoryOneOf: 'a' }) | 68 | const customQuery2 = { ...query, categoryOneOf: 'a' } |
70 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 69 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
71 | }) | 70 | }) |
72 | 71 | ||
73 | it('Should succeed with a valid category', async function () { | 72 | it('Should succeed with a valid category', async function () { |
74 | const customQuery1 = immutableAssign(query, { categoryOneOf: [ 1, 7 ] }) | 73 | const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] } |
75 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) | 74 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) |
76 | 75 | ||
77 | const customQuery2 = immutableAssign(query, { categoryOneOf: 1 }) | 76 | const customQuery2 = { ...query, categoryOneOf: 1 } |
78 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) | 77 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) |
79 | }) | 78 | }) |
80 | 79 | ||
81 | it('Should fail with an invalid licence', async function () { | 80 | it('Should fail with an invalid licence', async function () { |
82 | const customQuery1 = immutableAssign(query, { licenceOneOf: [ 'aa', 'b' ] }) | 81 | const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] } |
83 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 82 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
84 | 83 | ||
85 | const customQuery2 = immutableAssign(query, { licenceOneOf: 'a' }) | 84 | const customQuery2 = { ...query, licenceOneOf: 'a' } |
86 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 85 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
87 | }) | 86 | }) |
88 | 87 | ||
89 | it('Should succeed with a valid licence', async function () { | 88 | it('Should succeed with a valid licence', async function () { |
90 | const customQuery1 = immutableAssign(query, { licenceOneOf: [ 1, 2 ] }) | 89 | const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] } |
91 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) | 90 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) |
92 | 91 | ||
93 | const customQuery2 = immutableAssign(query, { licenceOneOf: 1 }) | 92 | const customQuery2 = { ...query, licenceOneOf: 1 } |
94 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) | 93 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) |
95 | }) | 94 | }) |
96 | 95 | ||
97 | it('Should succeed with a valid language', async function () { | 96 | it('Should succeed with a valid language', async function () { |
98 | const customQuery1 = immutableAssign(query, { languageOneOf: [ 'fr', 'en' ] }) | 97 | const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] } |
99 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) | 98 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) |
100 | 99 | ||
101 | const customQuery2 = immutableAssign(query, { languageOneOf: 'fr' }) | 100 | const customQuery2 = { ...query, languageOneOf: 'fr' } |
102 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) | 101 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) |
103 | }) | 102 | }) |
104 | 103 | ||
105 | it('Should succeed with valid tags', async function () { | 104 | it('Should succeed with valid tags', async function () { |
106 | const customQuery1 = immutableAssign(query, { tagsOneOf: [ 'tag1', 'tag2' ] }) | 105 | const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] } |
107 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) | 106 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) |
108 | 107 | ||
109 | const customQuery2 = immutableAssign(query, { tagsOneOf: 'tag1' }) | 108 | const customQuery2 = { ...query, tagsOneOf: 'tag1' } |
110 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) | 109 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) |
111 | 110 | ||
112 | const customQuery3 = immutableAssign(query, { tagsAllOf: [ 'tag1', 'tag2' ] }) | 111 | const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] } |
113 | await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 }) | 112 | await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 }) |
114 | 113 | ||
115 | const customQuery4 = immutableAssign(query, { tagsAllOf: 'tag1' }) | 114 | const customQuery4 = { ...query, tagsAllOf: 'tag1' } |
116 | await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 }) | 115 | await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 }) |
117 | }) | 116 | }) |
118 | 117 | ||
119 | it('Should fail with invalid durations', async function () { | 118 | it('Should fail with invalid durations', async function () { |
120 | const customQuery1 = immutableAssign(query, { durationMin: 'hello' }) | 119 | const customQuery1 = { ...query, durationMin: 'hello' } |
121 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 120 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
122 | 121 | ||
123 | const customQuery2 = immutableAssign(query, { durationMax: 'hello' }) | 122 | const customQuery2 = { ...query, durationMax: 'hello' } |
124 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 123 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
125 | }) | 124 | }) |
126 | 125 | ||
127 | it('Should fail with invalid dates', async function () { | 126 | it('Should fail with invalid dates', async function () { |
128 | const customQuery1 = immutableAssign(query, { startDate: 'hello' }) | 127 | const customQuery1 = { ...query, startDate: 'hello' } |
129 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 128 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
130 | 129 | ||
131 | const customQuery2 = immutableAssign(query, { endDate: 'hello' }) | 130 | const customQuery2 = { ...query, endDate: 'hello' } |
132 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 131 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
133 | 132 | ||
134 | const customQuery3 = immutableAssign(query, { originallyPublishedStartDate: 'hello' }) | 133 | const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' } |
135 | await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 134 | await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
136 | 135 | ||
137 | const customQuery4 = immutableAssign(query, { originallyPublishedEndDate: 'hello' }) | 136 | const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' } |
138 | await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 137 | await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
139 | }) | 138 | }) |
140 | }) | 139 | }) |
@@ -201,41 +200,41 @@ describe('Test videos API validator', function () { | |||
201 | 200 | ||
202 | for (const path of paths) { | 201 | for (const path of paths) { |
203 | { | 202 | { |
204 | const customQuery = immutableAssign(query, { searchTarget: 'hello' }) | 203 | const customQuery = { ...query, searchTarget: 'hello' } |
205 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 204 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
206 | } | 205 | } |
207 | 206 | ||
208 | { | 207 | { |
209 | const customQuery = immutableAssign(query, { searchTarget: undefined }) | 208 | const customQuery = { ...query, searchTarget: undefined } |
210 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) | 209 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) |
211 | } | 210 | } |
212 | 211 | ||
213 | { | 212 | { |
214 | const customQuery = immutableAssign(query, { searchTarget: 'local' }) | 213 | const customQuery = { ...query, searchTarget: 'local' } |
215 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) | 214 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) |
216 | } | 215 | } |
217 | 216 | ||
218 | { | 217 | { |
219 | const customQuery = immutableAssign(query, { searchTarget: 'search-index' }) | 218 | const customQuery = { ...query, searchTarget: 'search-index' } |
220 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 219 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
221 | } | 220 | } |
222 | 221 | ||
223 | await updateSearchIndex(server, true, true) | 222 | await updateSearchIndex(server, true, true) |
224 | 223 | ||
225 | { | 224 | { |
226 | const customQuery = immutableAssign(query, { searchTarget: 'local' }) | 225 | const customQuery = { ...query, searchTarget: 'local' } |
227 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 226 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) |
228 | } | 227 | } |
229 | 228 | ||
230 | { | 229 | { |
231 | const customQuery = immutableAssign(query, { searchTarget: 'search-index' }) | 230 | const customQuery = { ...query, searchTarget: 'search-index' } |
232 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) | 231 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) |
233 | } | 232 | } |
234 | 233 | ||
235 | await updateSearchIndex(server, true, false) | 234 | await updateSearchIndex(server, true, false) |
236 | 235 | ||
237 | { | 236 | { |
238 | const customQuery = immutableAssign(query, { searchTarget: 'local' }) | 237 | const customQuery = { ...query, searchTarget: 'local' } |
239 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) | 238 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) |
240 | } | 239 | } |
241 | 240 | ||