From 0ef0e4dcf8a1a0d6835a798035d34e259040f494 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Thu, 2 Sep 2021 11:27:41 -0700 Subject: [PATCH 1/2] Auto dump cypress test data Signed-off-by: Joshua Li --- gantt-chart/.cypress/integration/ui.spec.js | 43 ++++++++++++++++++++- gantt-chart/.cypress/utils/constants.js | 7 ++++ gantt-chart/cypress.json | 3 +- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/gantt-chart/.cypress/integration/ui.spec.js b/gantt-chart/.cypress/integration/ui.spec.js index ae8f179..7c74f51 100644 --- a/gantt-chart/.cypress/integration/ui.spec.js +++ b/gantt-chart/.cypress/integration/ui.spec.js @@ -26,7 +26,48 @@ /// -import { delay, GANTT_VIS_NAME, Y_LABEL, X_LABEL, DEFAULT_SIZE } from '../utils/constants'; +import { + testDataSet, + delay, + GANTT_VIS_NAME, + Y_LABEL, + X_LABEL, + DEFAULT_SIZE, +} from '../utils/constants'; + +describe('Dump test data', () => { + it('Indexes test data for gantt chart', () => { + const dumpDataSet = (url, index) => + cy.request(url).then((response) => { + cy.request({ + method: 'POST', + form: true, + url: 'api/console/proxy', + headers: { + 'content-type': 'application/json;charset=UTF-8', + 'osd-xsrf': true, + }, + qs: { + path: `${index}/_bulk`, + method: 'POST', + }, + body: response.body, + }); + }); + testDataSet.forEach(({ url, index }) => dumpDataSet(url, index)); + + cy.request({ + method: 'POST', + failOnStatusCode: false, + url: 'api/saved_objects/index-pattern/jaeger', + headers: { + 'content-type': 'application/json', + 'osd-xsrf': true, + }, + body: JSON.stringify({ attributes: { title: 'jaeger' } }), + }); + }); +}); describe('Save a gantt chart', () => { beforeEach(() => { diff --git a/gantt-chart/.cypress/utils/constants.js b/gantt-chart/.cypress/utils/constants.js index 516eb04..938facf 100644 --- a/gantt-chart/.cypress/utils/constants.js +++ b/gantt-chart/.cypress/utils/constants.js @@ -24,6 +24,13 @@ * permissions and limitations under the License. */ +export const testDataSet = [ + { + url: 'https://raw.githubusercontent.com/opensearch-project/dashboards-visualizations/main/gantt-chart/.cypress/utils/jaeger-sample.json', + index: 'jaeger', + }, +]; + export const delay = 1000; export const GANTT_VIS_NAME = 'A test gantt chart ' + Math.random().toString(36).substring(2); export const Y_LABEL = 'A unique label for Y-axis'; diff --git a/gantt-chart/cypress.json b/gantt-chart/cypress.json index 3f598a7..968159c 100644 --- a/gantt-chart/cypress.json +++ b/gantt-chart/cypress.json @@ -1,4 +1,5 @@ { + "baseUrl": "http://localhost:5601", "video": true, "fixturesFolder": ".cypress/fixtures", "integrationFolder": ".cypress/integration", @@ -16,4 +17,4 @@ "opensearchDashboards": "localhost:5601", "security_enabled": true } -} \ No newline at end of file +} From 3826f3d972915f029aa9bf3d3c1cfbbb87f22581 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Thu, 2 Sep 2021 12:03:14 -0700 Subject: [PATCH 2/2] Add tsconfig Signed-off-by: Joshua Li --- gantt-chart/.cypress/tsconfig.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 gantt-chart/.cypress/tsconfig.json diff --git a/gantt-chart/.cypress/tsconfig.json b/gantt-chart/.cypress/tsconfig.json new file mode 100644 index 0000000..36de33d --- /dev/null +++ b/gantt-chart/.cypress/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "allowJs": true, + "baseUrl": "../node_modules", + "types": ["cypress"] + }, + "include": ["**/*.*"] +}