+ 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-channels/',
+ '/api/v1/search/videos/'
+ ]
+
+ for (const path of paths) {
+ {
+ const customQuery = immutableAssign(query, { searchTarget: 'hello' })
+ await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: 400 })
+ }
+
+ {
+ const customQuery = immutableAssign(query, { searchTarget: undefined })
+ await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: 200 })
+ }
+
+ {
+ const customQuery = immutableAssign(query, { searchTarget: 'local' })
+ await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: 200 })
+ }
+
+ {
+ const customQuery = immutableAssign(query, { searchTarget: 'search-index' })
+ await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: 400 })
+ }
+
+ await updateSearchIndex(server, true, true)
+
+ {
+ const customQuery = immutableAssign(query, { searchTarget: 'local' })
+ await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: 400 })
+ }
+
+ {
+ const customQuery = immutableAssign(query, { searchTarget: 'search-index' })
+ await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: 200 })
+ }
+
+ await updateSearchIndex(server, true, false)
+
+ {
+ const customQuery = immutableAssign(query, { searchTarget: 'local' })
+ await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: 200 })
+ }
+
+ await updateSearchIndex(server, false, false)
+ }
+ })
+ })
+