Skip to content

Commit

Permalink
Auto dump cypress test data for workbench
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Li <[email protected]>
  • Loading branch information
joshuali925 committed Sep 1, 2021
1 parent 9ada743 commit b517bee
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
34 changes: 28 additions & 6 deletions workbench/.cypress/integration/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,32 @@

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

import { edit } from "brace";
import { delay, testQueries, verifyDownloadData, files } from "../utils/constants";
import { edit } from 'brace';
import { delay, files, testDataSet, testQueries, verifyDownloadData } from '../utils/constants';

describe('Dump test data', () => {
it('Indexes test data for SQL and PPL', () => {
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));
});
});

describe('Test PPL UI', () => {
beforeEach(() => {
Expand Down Expand Up @@ -183,13 +206,12 @@ describe('Test and verify SQL downloads', () => {
'osd-xsrf': true,
},
body: {
'query': 'select * from accounts where balance > 49500'
}
query: 'select * from accounts where balance > 49500',
},
}).then((response) => {
if (title === 'Download and verify CSV' || title === 'Download and verify Text') {
expect(response.body.data.body).to.have.string(files[file]);
}
else {
} else {
expect(response.body.data.resp).to.have.string(files[file]);
}
});
Expand Down
11 changes: 11 additions & 0 deletions workbench/.cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@

export const delay = 1000;

export const testDataSet = [
{
url: 'https://raw.githubusercontent.com/opensearch-project/sql/main/integ-test/src/test/resources/accounts.json',
index: 'accounts',
},
{
url: 'https://raw.githubusercontent.com/opensearch-project/sql/main/integ-test/src/test/resources/employee_nested.json',
index: 'employee_nested'
}
]

export const verifyDownloadData = [
{
title: 'Download and verify JSON',
Expand Down

0 comments on commit b517bee

Please sign in to comment.