Skip to content

Commit

Permalink
Auto dump cypress test data (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuali925 authored Sep 3, 2021
1 parent 9916a25 commit c5e7bfe
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
43 changes: 42 additions & 1 deletion gantt-chart/.cypress/integration/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,48 @@

/// <reference types="cypress" />

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(() => {
Expand Down
8 changes: 8 additions & 0 deletions gantt-chart/.cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "../node_modules",
"types": ["cypress"]
},
"include": ["**/*.*"]
}
7 changes: 7 additions & 0 deletions gantt-chart/.cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion gantt-chart/cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"baseUrl": "http://localhost:5601",
"video": true,
"fixturesFolder": ".cypress/fixtures",
"integrationFolder": ".cypress/integration",
Expand All @@ -16,4 +17,4 @@
"opensearchDashboards": "localhost:5601",
"security_enabled": true
}
}
}

0 comments on commit c5e7bfe

Please sign in to comment.