diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java index 7ea519fcd7e..78d8fb43e84 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java @@ -1340,7 +1340,7 @@ public okhttp3.Call batchRulesAsync( * Build call for browse * * @param indexName The index in which to perform the request. (required) - * @param browseRequest (required) + * @param browseRequest (optional) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -1413,13 +1413,6 @@ private okhttp3.Call browseValidateBeforeCall( ); } - // verify the required parameter 'browseRequest' is set - if (browseRequest == null) { - throw new ApiException( - "Missing the required parameter 'browseRequest' when calling browse(Async)" - ); - } - okhttp3.Call localVarCall = browseCall(indexName, browseRequest, _callback); return localVarCall; } @@ -1434,7 +1427,7 @@ private okhttp3.Call browseValidateBeforeCall( * has been reached, the cursor field is absent from the response. * * @param indexName The index in which to perform the request. (required) - * @param browseRequest (required) + * @param browseRequest (optional) * @return BrowseResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body @@ -1467,7 +1460,7 @@ public BrowseResponse browse(String indexName, BrowseRequest browseRequest) * has been reached, the cursor field is absent from the response. * * @param indexName The index in which to perform the request. (required) - * @param browseRequest (required) + * @param browseRequest (optional) * @return ApiResponse<BrowseResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body @@ -1505,7 +1498,7 @@ public ApiResponse browseWithHttpInfo( * response. * * @param indexName The index in which to perform the request. (required) - * @param browseRequest (required) + * @param browseRequest (optional) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -7426,7 +7419,7 @@ public okhttp3.Call searchDictionaryEntriesAsync( * * @param indexName The index in which to perform the request. (required) * @param facetName The facet name. (required) - * @param searchForFacetValuesRequest (required) + * @param searchForFacetValuesRequest (optional) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -7512,14 +7505,6 @@ private okhttp3.Call searchForFacetValuesValidateBeforeCall( ); } - // verify the required parameter 'searchForFacetValuesRequest' is set - if (searchForFacetValuesRequest == null) { - throw new ApiException( - "Missing the required parameter 'searchForFacetValuesRequest' when calling" + - " searchForFacetValues(Async)" - ); - } - okhttp3.Call localVarCall = searchForFacetValuesCall( indexName, facetName, @@ -7535,7 +7520,7 @@ private okhttp3.Call searchForFacetValuesValidateBeforeCall( * * @param indexName The index in which to perform the request. (required) * @param facetName The facet name. (required) - * @param searchForFacetValuesRequest (required) + * @param searchForFacetValuesRequest (optional) * @return SearchForFacetValuesResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body @@ -7568,7 +7553,7 @@ public SearchForFacetValuesResponse searchForFacetValues( * * @param indexName The index in which to perform the request. (required) * @param facetName The facet name. (required) - * @param searchForFacetValuesRequest (required) + * @param searchForFacetValuesRequest (optional) * @return ApiResponse<SearchForFacetValuesResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body @@ -7605,7 +7590,7 @@ public ApiResponse searchForFacetValuesWithHttpInf * * @param indexName The index in which to perform the request. (required) * @param facetName The facet name. (required) - * @param searchForFacetValuesRequest (required) + * @param searchForFacetValuesRequest (optional) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object diff --git a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts index 17e084980da..248b5f680ae 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -443,7 +443,7 @@ export class SearchApi { */ browse( indexName: string, - browseRequest: BrowseRequest + browseRequest?: BrowseRequest ): Promise { const path = '/1/indexes/{indexName}/browse'.replace( '{indexName}', @@ -458,12 +458,6 @@ export class SearchApi { ); } - if (browseRequest === null || browseRequest === undefined) { - throw new Error( - 'Required parameter browseRequest was null or undefined when calling browse.' - ); - } - const request: Request = { method: 'POST', path, @@ -1698,7 +1692,7 @@ export class SearchApi { searchForFacetValues( indexName: string, facetName: string, - searchForFacetValuesRequest: SearchForFacetValuesRequest + searchForFacetValuesRequest?: SearchForFacetValuesRequest ): Promise { const path = '/1/indexes/{indexName}/facets/{facetName}/query' .replace('{indexName}', encodeURIComponent(String(indexName))) @@ -1718,15 +1712,6 @@ export class SearchApi { ); } - if ( - searchForFacetValuesRequest === null || - searchForFacetValuesRequest === undefined - ) { - throw new Error( - 'Required parameter searchForFacetValuesRequest was null or undefined when calling searchForFacetValues.' - ); - } - const request: Request = { method: 'POST', path, diff --git a/specs/search/paths/search/browse.yml b/specs/search/paths/search/browse.yml index c36d824f51b..216d6734fcb 100644 --- a/specs/search/paths/search/browse.yml +++ b/specs/search/paths/search/browse.yml @@ -12,7 +12,6 @@ post: parameters: - $ref: '../../../common/parameters.yml#/IndexName' requestBody: - required: true content: application/json: schema: diff --git a/specs/search/paths/search/searchForFacetValues.yml b/specs/search/paths/search/searchForFacetValues.yml index 74863b7c95c..7825c06a395 100644 --- a/specs/search/paths/search/searchForFacetValues.yml +++ b/specs/search/paths/search/searchForFacetValues.yml @@ -13,7 +13,6 @@ post: schema: type: string requestBody: - required: true content: application/json: schema: diff --git a/tests/CTS/clients/recommend/getRecommendations.json b/tests/CTS/clients/recommend/getRecommendations.json new file mode 100644 index 00000000000..c86f5322de9 --- /dev/null +++ b/tests/CTS/clients/recommend/getRecommendations.json @@ -0,0 +1,188 @@ +[ + { + "method": "getRecommendations", + "testName": "get recommendations with minimal parameters", + "parameters": [ + { + "requests": [ + { + "indexName": "indexName", + "objectID": "objectID", + "model": "related-products", + "threshold": 42 + } + ] + } + ], + "request": { + "path": "/1/indexes/*/recommendations", + "method": "POST", + "data": { + "requests": [ + { + "indexName": "indexName", + "objectID": "objectID", + "model": "related-products", + "threshold": 42 + } + ] + } + } + }, + { + "method": "getRecommendations", + "testName": "get recommendations with all parameters", + "parameters": [ + { + "requests": [ + { + "indexName": "indexName", + "objectID": "objectID", + "model": "related-products", + "threshold": 42, + "queryParameters": { "facetFilters": ["query"] }, + "fallbackParameters": { "facetFilters": ["fallback"] } + } + ] + } + ], + "request": { + "path": "/1/indexes/*/recommendations", + "method": "POST", + "data": { + "requests": [ + { + "indexName": "indexName", + "objectID": "objectID", + "model": "related-products", + "threshold": 42, + "queryParameters": { "facetFilters": ["query"] }, + "fallbackParameters": { "facetFilters": ["fallback"] } + } + ] + } + } + }, + { + "method": "getRecommendations", + "testName": "get multiple recommendations with minimal parameters", + "parameters": [ + { + "requests": [ + { + "indexName": "indexName1", + "objectID": "objectID1", + "model": "related-products", + "threshold": 21 + }, + { + "indexName": "indexName2", + "objectID": "objectID2", + "model": "related-products", + "threshold": 21 + } + ] + } + ], + "request": { + "path": "/1/indexes/*/recommendations", + "method": "POST", + "data": { + "requests": [ + { + "indexName": "indexName1", + "objectID": "objectID1", + "model": "related-products", + "threshold": 21 + }, + { + "indexName": "indexName2", + "objectID": "objectID2", + "model": "related-products", + "threshold": 21 + } + ] + } + } + }, + { + "method": "getRecommendations", + "testName": "get multiple recommendations with all parameters", + "parameters": [ + { + "requests": [ + { + "indexName": "indexName1", + "objectID": "objectID1", + "model": "related-products", + "threshold": 21, + "queryParameters": { "facetFilters": ["query1"] }, + "fallbackParameters": { "facetFilters": ["fallback1"] } + }, + { + "indexName": "indexName2", + "objectID": "objectID2", + "model": "related-products", + "threshold": 21, + "queryParameters": { "facetFilters": ["query2"] }, + "fallbackParameters": { "facetFilters": ["fallback2"] } + } + ] + } + ], + "request": { + "path": "/1/indexes/*/recommendations", + "method": "POST", + "data": { + "requests": [ + { + "indexName": "indexName1", + "objectID": "objectID1", + "model": "related-products", + "threshold": 21, + "queryParameters": { "facetFilters": ["query1"] }, + "fallbackParameters": { "facetFilters": ["fallback1"] } + }, + { + "indexName": "indexName2", + "objectID": "objectID2", + "model": "related-products", + "threshold": 21, + "queryParameters": { "facetFilters": ["query2"] }, + "fallbackParameters": { "facetFilters": ["fallback2"] } + } + ] + } + } + }, + { + "method": "getRecommendations", + "testName": "get frequently bought together recommendations", + "parameters": [ + { + "requests": [ + { + "indexName": "indexName1", + "objectID": "objectID1", + "model": "bought-together", + "threshold": 42 + } + ] + } + ], + "request": { + "path": "/1/indexes/*/recommendations", + "method": "POST", + "data": { + "requests": [ + { + "indexName": "indexName1", + "objectID": "objectID1", + "model": "bought-together", + "threshold": 42 + } + ] + } + } + } +] diff --git a/tests/CTS/clients/search/batchDictionaryEntries.json b/tests/CTS/clients/search/batchDictionaryEntries.json new file mode 100644 index 00000000000..3a4405c83d1 --- /dev/null +++ b/tests/CTS/clients/search/batchDictionaryEntries.json @@ -0,0 +1,114 @@ +[ + { + "method": "batchDictionaryEntries", + "testName": "get batchDictionaryEntries results with minimal parameters", + "parameters": [ + "dictionaryName", + { + "requests": [ + { + "action": "addEntry", + "body": { + "objectID": "1", + "language": "en" + } + }, + { + "action": "deleteEntry", + "body": { + "objectID": "2", + "language": "fr" + } + } + ] + } + ], + "request": { + "path": "/1/dictionaries/dictionaryName/batch", + "method": "POST", + "data": { + "requests": [ + { + "action": "addEntry", + "body": { + "objectID": "1", + "language": "en" + } + }, + { + "action": "deleteEntry", + "body": { + "objectID": "2", + "language": "fr" + } + } + ] + } + } + }, + { + "method": "batchDictionaryEntries", + "testName": "get batchDictionaryEntries results with all parameters", + "parameters": [ + "dictionaryName", + { + "clearExistingDictionaryEntries": false, + "requests": [ + { + "action": "addEntry", + "body": { + "objectID": "1", + "language": "en", + "word": "yo", + "words": ["yo", "algolia"], + "decomposition": ["yo", "algolia"], + "state": "enabled" + } + }, + { + "action": "deleteEntry", + "body": { + "objectID": "2", + "language": "fr", + "word": "salut", + "words": ["salut", "algolia"], + "decomposition": ["salut", "algolia"], + "state": "enabled" + } + } + ] + } + ], + "request": { + "path": "/1/dictionaries/dictionaryName/batch", + "method": "POST", + "data": { + "clearExistingDictionaryEntries": false, + "requests": [ + { + "action": "addEntry", + "body": { + "objectID": "1", + "language": "en", + "word": "yo", + "words": ["yo", "algolia"], + "decomposition": ["yo", "algolia"], + "state": "enabled" + } + }, + { + "action": "deleteEntry", + "body": { + "objectID": "2", + "language": "fr", + "word": "salut", + "words": ["salut", "algolia"], + "decomposition": ["salut", "algolia"], + "state": "enabled" + } + } + ] + } + } + } +] diff --git a/tests/CTS/clients/search/browse.json b/tests/CTS/clients/search/browse.json new file mode 100644 index 00000000000..8f14ddd4cfa --- /dev/null +++ b/tests/CTS/clients/search/browse.json @@ -0,0 +1,30 @@ +[ + { + "method": "browse", + "testName": "get browse results with minimal parameters", + "parameters": ["indexName"], + "request": { + "path": "/1/indexes/indexName/browse", + "method": "POST" + } + }, + { + "method": "browse", + "testName": "get browse results with all parameters", + "parameters": [ + "indexName", + { + "params": "query=foo&facetFilters=['bar']", + "cursor": "cts" + } + ], + "request": { + "path": "/1/indexes/indexName/browse", + "method": "POST", + "data": { + "params": "query=foo&facetFilters=['bar']", + "cursor": "cts" + } + } + } +] diff --git a/tests/CTS/clients/search/getDictionaryLanguages.json b/tests/CTS/clients/search/getDictionaryLanguages.json new file mode 100644 index 00000000000..ae95478efc9 --- /dev/null +++ b/tests/CTS/clients/search/getDictionaryLanguages.json @@ -0,0 +1,11 @@ +[ + { + "method": "getDictionaryLanguages", + "testName": "get getDictionaryLanguages", + "parameters": [], + "request": { + "path": "/1/dictionaries/*/languages", + "method": "GET" + } + } +] diff --git a/tests/CTS/clients/search/getDictionarySettings.json b/tests/CTS/clients/search/getDictionarySettings.json new file mode 100644 index 00000000000..7363485ac9d --- /dev/null +++ b/tests/CTS/clients/search/getDictionarySettings.json @@ -0,0 +1,11 @@ +[ + { + "method": "getDictionarySettings", + "testName": "get getDictionarySettings results", + "parameters": [], + "request": { + "path": "/1/dictionaries/*/settings", + "method": "GET" + } + } +] diff --git a/tests/CTS/clients/search/searchDictionaryEntries.json b/tests/CTS/clients/search/searchDictionaryEntries.json new file mode 100644 index 00000000000..24c0d7ec385 --- /dev/null +++ b/tests/CTS/clients/search/searchDictionaryEntries.json @@ -0,0 +1,42 @@ +[ + { + "method": "searchDictionaryEntries", + "testName": "get searchDictionaryEntries results with minimal parameters", + "parameters": [ + "dictionaryName", + { + "query": "foo" + } + ], + "request": { + "path": "/1/dictionaries/dictionaryName/search", + "method": "POST", + "data": { + "query": "foo" + } + } + }, + { + "method": "searchDictionaryEntries", + "testName": "get searchDictionaryEntries results with all parameters", + "parameters": [ + "dictionaryName", + { + "query": "foo", + "page": 4, + "hitsPerPage": 2, + "language": "fr" + } + ], + "request": { + "path": "/1/dictionaries/dictionaryName/search", + "method": "POST", + "data": { + "query": "foo", + "page": 4, + "hitsPerPage": 2, + "language": "fr" + } + } + } +] diff --git a/tests/CTS/clients/search/searchForFacetValues.json b/tests/CTS/clients/search/searchForFacetValues.json new file mode 100644 index 00000000000..4e02a47ade3 --- /dev/null +++ b/tests/CTS/clients/search/searchForFacetValues.json @@ -0,0 +1,33 @@ +[ + { + "method": "searchForFacetValues", + "testName": "get searchForFacetValues results with minimal parameters", + "parameters": ["indexName", "facetName"], + "request": { + "path": "/1/indexes/indexName/facets/facetName/query", + "method": "POST" + } + }, + { + "method": "searchForFacetValues", + "testName": "get searchForFacetValues results with all parameters", + "parameters": [ + "indexName", + "facetName", + { + "params": "query=foo&facetFilters=['bar']", + "facetQuery": "foo", + "maxFacetHits": 42 + } + ], + "request": { + "path": "/1/indexes/indexName/facets/facetName/query", + "method": "POST", + "data": { + "params": "query=foo&facetFilters=['bar']", + "facetQuery": "foo", + "maxFacetHits": 42 + } + } + } +] diff --git a/tests/CTS/clients/search/setDictionarySettings.json b/tests/CTS/clients/search/setDictionarySettings.json new file mode 100644 index 00000000000..d2a7c77b4e2 --- /dev/null +++ b/tests/CTS/clients/search/setDictionarySettings.json @@ -0,0 +1,70 @@ +[ + { + "method": "setDictionarySettings", + "testName": "get setDictionarySettings results with minimal parameters", + "parameters": [ + { + "disableStandardEntries": { + "plurals": { + "fr": false, + "en": false, + "ru": true + } + } + } + ], + "request": { + "path": "/1/dictionaries/*/settings", + "method": "PUT", + "data": { + "disableStandardEntries": { + "plurals": { + "fr": false, + "en": false, + "ru": true + } + } + } + } + }, + { + "method": "setDictionarySettings", + "testName": "get setDictionarySettings results with all parameters", + "parameters": [ + { + "disableStandardEntries": { + "plurals": { + "fr": false, + "en": false, + "ru": true + }, + "stopwords": { + "fr": false + }, + "compounds": { + "ru": true + } + } + } + ], + "request": { + "path": "/1/dictionaries/*/settings", + "method": "PUT", + "data": { + "disableStandardEntries": { + "plurals": { + "fr": false, + "en": false, + "ru": true + }, + "stopwords": { + "fr": false + }, + "compounds": { + "ru": true + } + } + } + } + } +] diff --git a/tests/generateCTS.ts b/tests/generateCTS.ts index b7aaa437e05..46033d5d12c 100644 --- a/tests/generateCTS.ts +++ b/tests/generateCTS.ts @@ -79,9 +79,15 @@ async function loadCTSForClient(client: string): Promise { continue; } const operationId = file.name.replace('.json', ''); - const tests: CTSBlock[] = JSON.parse( - (await fsp.readFile(file.path)).toString() - ); + const fileContent = (await fsp.readFile(file.path)).toString(); + + if (!fileContent) { + throw new Error( + `cannot read empty file for operationId ${operationId} - ${client} client` + ); + } + + const tests: CTSBlock[] = JSON.parse(fileContent); // check test validity against spec if (!operations.includes(operationId)) { diff --git a/tests/output/javascript/recommend.test.ts b/tests/output/javascript/recommend.test.ts new file mode 100644 index 00000000000..1912ed7b390 --- /dev/null +++ b/tests/output/javascript/recommend.test.ts @@ -0,0 +1,181 @@ +// @ts-nocheck +import { RecommendApi, EchoRequester } from '@algolia/recommend'; + +describe('Common Test Suite', () => { + const client = new RecommendApi( + process.env.ALGOLIA_APPLICATION_ID, + process.env.ALGOLIA_SEARCH_KEY, + { requester: new EchoRequester() } + ); + + test('get recommendations with minimal parameters', async () => { + const req = await client.getRecommendations({ + requests: [ + { + indexName: 'indexName', + objectID: 'objectID', + model: 'related-products', + threshold: 42, + }, + ], + }); + expect(req).toMatchObject({ + path: '/1/indexes/*/recommendations', + method: 'POST', + data: { + requests: [ + { + indexName: 'indexName', + objectID: 'objectID', + model: 'related-products', + threshold: 42, + }, + ], + }, + }); + }); + + test('get recommendations with all parameters', async () => { + const req = await client.getRecommendations({ + requests: [ + { + indexName: 'indexName', + objectID: 'objectID', + model: 'related-products', + threshold: 42, + queryParameters: { facetFilters: ['query'] }, + fallbackParameters: { facetFilters: ['fallback'] }, + }, + ], + }); + expect(req).toMatchObject({ + path: '/1/indexes/*/recommendations', + method: 'POST', + data: { + requests: [ + { + indexName: 'indexName', + objectID: 'objectID', + model: 'related-products', + threshold: 42, + queryParameters: { facetFilters: ['query'] }, + fallbackParameters: { facetFilters: ['fallback'] }, + }, + ], + }, + }); + }); + + test('get multiple recommendations with minimal parameters', async () => { + const req = await client.getRecommendations({ + requests: [ + { + indexName: 'indexName1', + objectID: 'objectID1', + model: 'related-products', + threshold: 21, + }, + { + indexName: 'indexName2', + objectID: 'objectID2', + model: 'related-products', + threshold: 21, + }, + ], + }); + expect(req).toMatchObject({ + path: '/1/indexes/*/recommendations', + method: 'POST', + data: { + requests: [ + { + indexName: 'indexName1', + objectID: 'objectID1', + model: 'related-products', + threshold: 21, + }, + { + indexName: 'indexName2', + objectID: 'objectID2', + model: 'related-products', + threshold: 21, + }, + ], + }, + }); + }); + + test('get multiple recommendations with all parameters', async () => { + const req = await client.getRecommendations({ + requests: [ + { + indexName: 'indexName1', + objectID: 'objectID1', + model: 'related-products', + threshold: 21, + queryParameters: { facetFilters: ['query1'] }, + fallbackParameters: { facetFilters: ['fallback1'] }, + }, + { + indexName: 'indexName2', + objectID: 'objectID2', + model: 'related-products', + threshold: 21, + queryParameters: { facetFilters: ['query2'] }, + fallbackParameters: { facetFilters: ['fallback2'] }, + }, + ], + }); + expect(req).toMatchObject({ + path: '/1/indexes/*/recommendations', + method: 'POST', + data: { + requests: [ + { + indexName: 'indexName1', + objectID: 'objectID1', + model: 'related-products', + threshold: 21, + queryParameters: { facetFilters: ['query1'] }, + fallbackParameters: { facetFilters: ['fallback1'] }, + }, + { + indexName: 'indexName2', + objectID: 'objectID2', + model: 'related-products', + threshold: 21, + queryParameters: { facetFilters: ['query2'] }, + fallbackParameters: { facetFilters: ['fallback2'] }, + }, + ], + }, + }); + }); + + test('get frequently bought together recommendations', async () => { + const req = await client.getRecommendations({ + requests: [ + { + indexName: 'indexName1', + objectID: 'objectID1', + model: 'bought-together', + threshold: 42, + }, + ], + }); + expect(req).toMatchObject({ + path: '/1/indexes/*/recommendations', + method: 'POST', + data: { + requests: [ + { + indexName: 'indexName1', + objectID: 'objectID1', + model: 'bought-together', + threshold: 42, + }, + ], + }, + }); + }); +}); diff --git a/tests/output/javascript/search.test.ts b/tests/output/javascript/search.test.ts index 1e64e47e2ec..6fd2f9e78ef 100644 --- a/tests/output/javascript/search.test.ts +++ b/tests/output/javascript/search.test.ts @@ -8,6 +8,14 @@ describe('Common Test Suite', () => { { requester: new EchoRequester() } ); + test('get getDictionarySettings results', async () => { + const req = await client.getDictionarySettings(); + expect(req).toMatchObject({ + path: '/1/dictionaries/*/settings', + method: 'GET', + }); + }); + test('searchSynonyms', async () => { const req = await client.searchSynonyms( 'indexName', @@ -66,6 +74,31 @@ describe('Common Test Suite', () => { }); }); + test('get searchForFacetValues results with minimal parameters', async () => { + const req = await client.searchForFacetValues('indexName', 'facetName'); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/facets/facetName/query', + method: 'POST', + }); + }); + + test('get searchForFacetValues results with all parameters', async () => { + const req = await client.searchForFacetValues('indexName', 'facetName', { + params: "query=foo&facetFilters=['bar']", + facetQuery: 'foo', + maxFacetHits: 42, + }); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/facets/facetName/query', + method: 'POST', + data: { + params: "query=foo&facetFilters=['bar']", + facetQuery: 'foo', + maxFacetHits: 42, + }, + }); + }); + test('getSynonym', async () => { const req = await client.getSynonym('indexName', 'id1'); expect(req).toMatchObject({ @@ -83,6 +116,40 @@ describe('Common Test Suite', () => { }); }); + test('get setDictionarySettings results with minimal parameters', async () => { + const req = await client.setDictionarySettings({ + disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, + }); + expect(req).toMatchObject({ + path: '/1/dictionaries/*/settings', + method: 'PUT', + data: { + disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, + }, + }); + }); + + test('get setDictionarySettings results with all parameters', async () => { + const req = await client.setDictionarySettings({ + disableStandardEntries: { + plurals: { fr: false, en: false, ru: true }, + stopwords: { fr: false }, + compounds: { ru: true }, + }, + }); + expect(req).toMatchObject({ + path: '/1/dictionaries/*/settings', + method: 'PUT', + data: { + disableStandardEntries: { + plurals: { fr: false, en: false, ru: true }, + stopwords: { fr: false }, + compounds: { ru: true }, + }, + }, + }); + }); + test('getRule', async () => { const req = await client.getRule('indexName', 'id1'); expect(req).toMatchObject({ @@ -91,6 +158,31 @@ describe('Common Test Suite', () => { }); }); + test('get searchDictionaryEntries results with minimal parameters', async () => { + const req = await client.searchDictionaryEntries('dictionaryName', { + query: 'foo', + }); + expect(req).toMatchObject({ + path: '/1/dictionaries/dictionaryName/search', + method: 'POST', + data: { query: 'foo' }, + }); + }); + + test('get searchDictionaryEntries results with all parameters', async () => { + const req = await client.searchDictionaryEntries('dictionaryName', { + query: 'foo', + page: 4, + hitsPerPage: 2, + language: 'fr', + }); + expect(req).toMatchObject({ + path: '/1/dictionaries/dictionaryName/search', + method: 'POST', + data: { query: 'foo', page: 4, hitsPerPage: 2, language: 'fr' }, + }); + }); + test('batchRules', async () => { const req = await client.batchRules( 'indexName', @@ -146,6 +238,14 @@ describe('Common Test Suite', () => { }); }); + test('get getDictionaryLanguages', async () => { + const req = await client.getDictionaryLanguages(); + expect(req).toMatchObject({ + path: '/1/dictionaries/*/languages', + method: 'GET', + }); + }); + test('deleteApiKey', async () => { const req = await client.deleteApiKey('myTestApiKey'); expect(req).toMatchObject({ @@ -230,6 +330,26 @@ describe('Common Test Suite', () => { }); }); + test('get browse results with minimal parameters', async () => { + const req = await client.browse('indexName'); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/browse', + method: 'POST', + }); + }); + + test('get browse results with all parameters', async () => { + const req = await client.browse('indexName', { + params: "query=foo&facetFilters=['bar']", + cursor: 'cts', + }); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/browse', + method: 'POST', + data: { params: "query=foo&facetFilters=['bar']", cursor: 'cts' }, + }); + }); + test('deleteSynonym', async () => { const req = await client.deleteSynonym('indexName', 'id1'); expect(req).toMatchObject({ @@ -246,6 +366,86 @@ describe('Common Test Suite', () => { }); }); + test('get batchDictionaryEntries results with minimal parameters', async () => { + const req = await client.batchDictionaryEntries('dictionaryName', { + requests: [ + { action: 'addEntry', body: { objectID: '1', language: 'en' } }, + { action: 'deleteEntry', body: { objectID: '2', language: 'fr' } }, + ], + }); + expect(req).toMatchObject({ + path: '/1/dictionaries/dictionaryName/batch', + method: 'POST', + data: { + requests: [ + { action: 'addEntry', body: { objectID: '1', language: 'en' } }, + { action: 'deleteEntry', body: { objectID: '2', language: 'fr' } }, + ], + }, + }); + }); + + test('get batchDictionaryEntries results with all parameters', async () => { + const req = await client.batchDictionaryEntries('dictionaryName', { + clearExistingDictionaryEntries: false, + requests: [ + { + action: 'addEntry', + body: { + objectID: '1', + language: 'en', + word: 'yo', + words: ['yo', 'algolia'], + decomposition: ['yo', 'algolia'], + state: 'enabled', + }, + }, + { + action: 'deleteEntry', + body: { + objectID: '2', + language: 'fr', + word: 'salut', + words: ['salut', 'algolia'], + decomposition: ['salut', 'algolia'], + state: 'enabled', + }, + }, + ], + }); + expect(req).toMatchObject({ + path: '/1/dictionaries/dictionaryName/batch', + method: 'POST', + data: { + clearExistingDictionaryEntries: false, + requests: [ + { + action: 'addEntry', + body: { + objectID: '1', + language: 'en', + word: 'yo', + words: ['yo', 'algolia'], + decomposition: ['yo', 'algolia'], + state: 'enabled', + }, + }, + { + action: 'deleteEntry', + body: { + objectID: '2', + language: 'fr', + word: 'salut', + words: ['salut', 'algolia'], + decomposition: ['salut', 'algolia'], + state: 'enabled', + }, + }, + ], + }, + }); + }); + test('listApiKeys', async () => { const req = await client.listApiKeys(); expect(req).toMatchObject({