aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/search.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/search.ts')
-rw-r--r--server/tests/api/check-params/search.ts62
1 files changed, 31 insertions, 31 deletions
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts
index 43cd81af9..b49169e38 100644
--- a/server/tests/api/check-params/search.ts
+++ b/server/tests/api/check-params/search.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadSortPagination, 7 checkBadSortPagination,
@@ -58,83 +58,83 @@ describe('Test videos API validator', function () {
58 }) 58 })
59 59
60 it('Should success with the correct parameters', async function () { 60 it('Should success with the correct parameters', async function () {
61 await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) 61 await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
62 }) 62 })
63 63
64 it('Should fail with an invalid category', async function () { 64 it('Should fail with an invalid category', async function () {
65 const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] } 65 const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] }
66 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 66 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
67 67
68 const customQuery2 = { ...query, categoryOneOf: 'a' } 68 const customQuery2 = { ...query, categoryOneOf: 'a' }
69 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 69 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
70 }) 70 })
71 71
72 it('Should succeed with a valid category', async function () { 72 it('Should succeed with a valid category', async function () {
73 const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] } 73 const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] }
74 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 74 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
75 75
76 const customQuery2 = { ...query, categoryOneOf: 1 } 76 const customQuery2 = { ...query, categoryOneOf: 1 }
77 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 77 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
78 }) 78 })
79 79
80 it('Should fail with an invalid licence', async function () { 80 it('Should fail with an invalid licence', async function () {
81 const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] } 81 const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] }
82 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 82 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
83 83
84 const customQuery2 = { ...query, licenceOneOf: 'a' } 84 const customQuery2 = { ...query, licenceOneOf: 'a' }
85 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 85 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
86 }) 86 })
87 87
88 it('Should succeed with a valid licence', async function () { 88 it('Should succeed with a valid licence', async function () {
89 const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] } 89 const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] }
90 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 90 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
91 91
92 const customQuery2 = { ...query, licenceOneOf: 1 } 92 const customQuery2 = { ...query, licenceOneOf: 1 }
93 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 93 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
94 }) 94 })
95 95
96 it('Should succeed with a valid language', async function () { 96 it('Should succeed with a valid language', async function () {
97 const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] } 97 const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] }
98 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 98 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
99 99
100 const customQuery2 = { ...query, languageOneOf: 'fr' } 100 const customQuery2 = { ...query, languageOneOf: 'fr' }
101 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 101 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
102 }) 102 })
103 103
104 it('Should succeed with valid tags', async function () { 104 it('Should succeed with valid tags', async function () {
105 const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] } 105 const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] }
106 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 106 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
107 107
108 const customQuery2 = { ...query, tagsOneOf: 'tag1' } 108 const customQuery2 = { ...query, tagsOneOf: 'tag1' }
109 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 109 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
110 110
111 const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] } 111 const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] }
112 await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 }) 112 await makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: HttpStatusCode.OK_200 })
113 113
114 const customQuery4 = { ...query, tagsAllOf: 'tag1' } 114 const customQuery4 = { ...query, tagsAllOf: 'tag1' }
115 await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 }) 115 await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.OK_200 })
116 }) 116 })
117 117
118 it('Should fail with invalid durations', async function () { 118 it('Should fail with invalid durations', async function () {
119 const customQuery1 = { ...query, durationMin: 'hello' } 119 const customQuery1 = { ...query, durationMin: 'hello' }
120 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 120 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
121 121
122 const customQuery2 = { ...query, durationMax: 'hello' } 122 const customQuery2 = { ...query, durationMax: 'hello' }
123 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 123 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
124 }) 124 })
125 125
126 it('Should fail with invalid dates', async function () { 126 it('Should fail with invalid dates', async function () {
127 const customQuery1 = { ...query, startDate: 'hello' } 127 const customQuery1 = { ...query, startDate: 'hello' }
128 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 128 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
129 129
130 const customQuery2 = { ...query, endDate: 'hello' } 130 const customQuery2 = { ...query, endDate: 'hello' }
131 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 131 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
132 132
133 const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' } 133 const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' }
134 await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 134 await makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
135 135
136 const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' } 136 const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' }
137 await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 137 await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
138 }) 138 })
139 }) 139 })
140 140
@@ -158,7 +158,7 @@ describe('Test videos API validator', function () {
158 }) 158 })
159 159
160 it('Should success with the correct parameters', async function () { 160 it('Should success with the correct parameters', async function () {
161 await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) 161 await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
162 }) 162 })
163 }) 163 })
164 164
@@ -182,7 +182,7 @@ describe('Test videos API validator', function () {
182 }) 182 })
183 183
184 it('Should success with the correct parameters', async function () { 184 it('Should success with the correct parameters', async function () {
185 await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) 185 await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
186 }) 186 })
187 }) 187 })
188 188
@@ -201,41 +201,41 @@ describe('Test videos API validator', function () {
201 for (const path of paths) { 201 for (const path of paths) {
202 { 202 {
203 const customQuery = { ...query, searchTarget: 'hello' } 203 const customQuery = { ...query, searchTarget: 'hello' }
204 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 204 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
205 } 205 }
206 206
207 { 207 {
208 const customQuery = { ...query, searchTarget: undefined } 208 const customQuery = { ...query, searchTarget: undefined }
209 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 209 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
210 } 210 }
211 211
212 { 212 {
213 const customQuery = { ...query, searchTarget: 'local' } 213 const customQuery = { ...query, searchTarget: 'local' }
214 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 214 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
215 } 215 }
216 216
217 { 217 {
218 const customQuery = { ...query, searchTarget: 'search-index' } 218 const customQuery = { ...query, searchTarget: 'search-index' }
219 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 219 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
220 } 220 }
221 221
222 await updateSearchIndex(server, true, true) 222 await updateSearchIndex(server, true, true)
223 223
224 { 224 {
225 const customQuery = { ...query, searchTarget: 'local' } 225 const customQuery = { ...query, searchTarget: 'local' }
226 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 226 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
227 } 227 }
228 228
229 { 229 {
230 const customQuery = { ...query, searchTarget: 'search-index' } 230 const customQuery = { ...query, searchTarget: 'search-index' }
231 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 231 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
232 } 232 }
233 233
234 await updateSearchIndex(server, true, false) 234 await updateSearchIndex(server, true, false)
235 235
236 { 236 {
237 const customQuery = { ...query, searchTarget: 'local' } 237 const customQuery = { ...query, searchTarget: 'local' }
238 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 238 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
239 } 239 }
240 240
241 await updateSearchIndex(server, false, false) 241 await updateSearchIndex(server, false, false)