diff --git a/doc/CTS.md b/doc/CTS.md index 7abc99681e..b5fb67e974 100644 --- a/doc/CTS.md +++ b/doc/CTS.md @@ -23,7 +23,7 @@ The test generation script requires a JSON file name from the `operationId` (e.g ```json [ { - "testName": "the name of the test (e.g. test('search endpoint'))", + "testName": "the name of the test (e.g. test('search endpoint')) (default: 'method')", "method": "the method to call (e.g. search)", "parameters": [ "indexName", diff --git a/tests/CTS/clients/search/clearAllSynonyms.json b/tests/CTS/clients/search/clearAllSynonyms.json index a1d6dbb09e..aef6c4f841 100644 --- a/tests/CTS/clients/search/clearAllSynonyms.json +++ b/tests/CTS/clients/search/clearAllSynonyms.json @@ -1,6 +1,5 @@ [ { - "testName": "clearAllSynonyms", "method": "clearAllSynonyms", "parameters": [ "indexName" diff --git a/tests/CTS/clients/search/deleteSynonym.json b/tests/CTS/clients/search/deleteSynonym.json index 7e0d7d698b..dd4ded6712 100644 --- a/tests/CTS/clients/search/deleteSynonym.json +++ b/tests/CTS/clients/search/deleteSynonym.json @@ -1,6 +1,5 @@ [ { - "testName": "deleteSynonym", "method": "deleteSynonym", "parameters": [ "indexName", diff --git a/tests/CTS/clients/search/getSynonym.json b/tests/CTS/clients/search/getSynonym.json index 53a36a3f2a..d9744d14e6 100644 --- a/tests/CTS/clients/search/getSynonym.json +++ b/tests/CTS/clients/search/getSynonym.json @@ -1,6 +1,5 @@ [ { - "testName": "getSynonym", "method": "getSynonym", "parameters": [ "indexName", diff --git a/tests/CTS/clients/search/saveSynonym.json b/tests/CTS/clients/search/saveSynonym.json index ecec571c2e..b09dac23cd 100644 --- a/tests/CTS/clients/search/saveSynonym.json +++ b/tests/CTS/clients/search/saveSynonym.json @@ -1,14 +1,17 @@ [ { - "testName": "saveSynonym", "method": "saveSynonym", "parameters": [ "indexName", "id1", { - "objectID" : "id1", + "objectID": "id1", "type": "synonym", - "synonyms": ["car", "vehicule", "auto"] + "synonyms": [ + "car", + "vehicule", + "auto" + ] }, true ], @@ -16,9 +19,13 @@ "path": "/1/indexes/indexName/synonyms/id1", "method": "PUT", "data": { - "objectID" : "id1", + "objectID": "id1", "type": "synonym", - "synonyms": ["car", "vehicule", "auto"] + "synonyms": [ + "car", + "vehicule", + "auto" + ] } } } diff --git a/tests/CTS/clients/search/saveSynonyms.json b/tests/CTS/clients/search/saveSynonyms.json index 531ed9e517..3823d93b44 100644 --- a/tests/CTS/clients/search/saveSynonyms.json +++ b/tests/CTS/clients/search/saveSynonyms.json @@ -1,20 +1,27 @@ [ { - "testName": "saveSynonyms", "method": "saveSynonyms", "parameters": [ "indexName", [ { - "objectID" : "id1", + "objectID": "id1", "type": "synonym", - "synonyms": ["car", "vehicule", "auto"] + "synonyms": [ + "car", + "vehicule", + "auto" + ] }, { - "objectID" : "id2", + "objectID": "id2", "type": "onewaysynonym", "input": "iphone", - "synonyms": ["ephone", "aphone", "yphone"] + "synonyms": [ + "ephone", + "aphone", + "yphone" + ] } ], true, @@ -25,15 +32,23 @@ "method": "POST", "data": [ { - "objectID" : "id1", + "objectID": "id1", "type": "synonym", - "synonyms": ["car", "vehicule", "auto"] + "synonyms": [ + "car", + "vehicule", + "auto" + ] }, { - "objectID" : "id2", + "objectID": "id2", "type": "onewaysynonym", "input": "iphone", - "synonyms": ["ephone", "aphone", "yphone"] + "synonyms": [ + "ephone", + "aphone", + "yphone" + ] } ] } diff --git a/tests/CTS/clients/search/search.json b/tests/CTS/clients/search/search.json index 8e0eac0e92..0ce82a8ef1 100644 --- a/tests/CTS/clients/search/search.json +++ b/tests/CTS/clients/search/search.json @@ -1,6 +1,5 @@ [ { - "testName": "search", "method": "search", "parameters": [ "indexName", diff --git a/tests/CTS/clients/search/searchSynonyms.json b/tests/CTS/clients/search/searchSynonyms.json index 3836ec7860..758967861f 100644 --- a/tests/CTS/clients/search/searchSynonyms.json +++ b/tests/CTS/clients/search/searchSynonyms.json @@ -1,6 +1,5 @@ [ { - "testName": "searchSynonyms", "method": "searchSynonyms", "parameters": [ "indexName", diff --git a/tests/CTS/templates/javascript.mustache b/tests/CTS/templates/javascript.mustache index a9279f15c4..68fdf74ac2 100644 --- a/tests/CTS/templates/javascript.mustache +++ b/tests/CTS/templates/javascript.mustache @@ -10,7 +10,7 @@ describe('Common Test Suite', () => { expect(req).toMatchObject({ path: '{{{request.path}}}', method: '{{{request.method}}}', - {{#request.data}}data: {{{request.data}}},{{/request.data}} + {{#request.data}}data: {{{.}}},{{/request.data}} }) }); diff --git a/tests/generateCTS.ts b/tests/generateCTS.ts index de22b9180e..b7aaa437e0 100644 --- a/tests/generateCTS.ts +++ b/tests/generateCTS.ts @@ -12,13 +12,13 @@ const availableLanguages = ['javascript'] as const; type Language = typeof availableLanguages[number]; type CTSBlock = { - name: string; + testName?: string; method: string; parameters: any[]; request: { path: string; method: string; - data: string; + data?: string; }; }; @@ -90,8 +90,12 @@ async function loadCTSForClient(client: string): Promise { ); } - // for now we stringify all params for mustache to render them properly for (const test of tests) { + if (test.testName === undefined) { + test.testName = test.method; + } + + // for now we stringify all params for mustache to render them properly for (let i = 0; i < test.parameters.length; i++) { // delete the object name for now, but it could be use for `new $objectName(params)` delete test.parameters[i].$objectName; diff --git a/tests/output/javascript/search.test.ts b/tests/output/javascript/search.test.ts index fee71e30f6..30891f9aca 100644 --- a/tests/output/javascript/search.test.ts +++ b/tests/output/javascript/search.test.ts @@ -42,23 +42,19 @@ describe('Common Test Suite', () => { expect(req).toMatchObject({ path: '/1/indexes/indexName/synonyms/batch', method: 'POST', - data: { - synonymHit: [ - { - objectID: 'id1', - type: 'synonym', - synonyms: ['car', 'vehicule', 'auto'], - }, - { - objectID: 'id2', - type: 'onewaysynonym', - input: 'iphone', - synonyms: ['ephone', 'aphone', 'yphone'], - }, - ], - ForwardToReplicas: true, - ReplaceExistingSynonyms: false, - }, + data: [ + { + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }, + { + objectID: 'id2', + type: 'onewaysynonym', + input: 'iphone', + synonyms: ['ephone', 'aphone', 'yphone'], + }, + ], }); }); @@ -110,12 +106,9 @@ describe('Common Test Suite', () => { path: '/1/indexes/indexName/synonyms/id1', method: 'PUT', data: { - synonymHit: { - objectID: 'id1', - type: 'synonym', - synonyms: ['car', 'vehicule', 'auto'], - }, - ForwardToReplicas: true, + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], }, }); });