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/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": ["**/*.*"] +} 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 +}