+ it('Should fail with an invalid host', async function () {
+ await makeGetRequest({ url: server.url, path, query: { ...query, host: '6565' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ })
+
+ it('Should fail with invalid handles', async function () {
+ await makeGetRequest({ url: server.url, path, query: { ...query, handles: [ '' ] }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ })
+
+ it('Should succeed with the correct parameters', async function () {
+ await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
+ })
+ })
+
+ describe('Search target', function () {
+
+ it('Should fail/succeed depending on the search target', async function () {
+ this.timeout(10000)
+
+ const query = { search: 'coucou' }
+ const paths = [
+ '/api/v1/search/video-playlists/',
+ '/api/v1/search/video-channels/',
+ '/api/v1/search/videos/'
+ ]
+
+ for (const path of paths) {
+ {
+ const customQuery = { ...query, searchTarget: 'hello' }
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ }
+
+ {
+ const customQuery = { ...query, searchTarget: undefined }
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
+ }
+
+ {
+ const customQuery = { ...query, searchTarget: 'local' }
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
+ }
+
+ {
+ const customQuery = { ...query, searchTarget: 'search-index' }
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ }
+
+ await updateSearchIndex(server, true, true)
+
+ {
+ const customQuery = { ...query, searchTarget: 'search-index' }
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
+ }
+
+ await updateSearchIndex(server, true, false)
+
+ {
+ const customQuery = { ...query, searchTarget: 'local' }
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
+ }
+
+ await updateSearchIndex(server, false, false)
+ }