Skip to content

Commit

Permalink
Merge pull request opensearch-project#3 from eugenesk24/add-test-data
Browse files Browse the repository at this point in the history
Add before and after specs
  • Loading branch information
kavilla authored Jun 9, 2022
2 parents 5427df2 + 059fe2a commit 950571d
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

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

import { testIndexDataSet, BASE_PATH } from '../../../utils/constants';

describe('Before', () => {
before(() => {
cy.deleteAllIndices();

localStorage.setItem('home:welcome:show', 'true');

cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`);

// Click on "Sample data" tab
cy.contains('Sample data').click({ force: true });
// Load sample flights data
cy.get(`button[data-test-subj="addSampleDataSetflights"]`).click({
force: true,
});

// Verify that sample data is add by checking toast notification
cy.contains('Sample flight data installed', { timeout: 60000 });

const dumpDataSet = (mapping_url, data_url, index) => {
cy.request({
method: 'POST',
failOnStatusCode: false,
url: 'api/console/proxy',
headers: {
'content-type': 'application/json;charset=UTF-8',
'osd-xsrf': true,
},
qs: {
path: `${index}`,
method: 'PUT',
},
});

cy.request(mapping_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}/_mapping`,
method: 'POST',
},
body: response.body,
});
});

cy.request(data_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,
});
});
};

testIndexDataSet.forEach(({ mapping_url, data_url, index }) =>
dumpDataSet(mapping_url, data_url, index)
);
});

it('setup completed', () => {});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,7 @@

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

import { testIndexDataSet, delayTime, setTimeFilter } from '../../../utils/constants';

describe('Dump test data', () => {
it('Indexes test data', () => {
const dumpDataSet = (mapping_url, data_url, index) => {
cy.request({
method: 'POST',
failOnStatusCode: false,
url: 'api/console/proxy',
headers: {
'content-type': 'application/json;charset=UTF-8',
'osd-xsrf': true,
},
qs: {
path: `${index}`,
method: 'PUT',
},
});

cy.request(mapping_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}/_mapping`,
method: 'POST',
},
body: response.body,
});
});

cy.request(data_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,
});
});
};

testIndexDataSet.forEach(({ mapping_url, data_url, index }) =>
dumpDataSet(mapping_url, data_url, index)
);
});
});
import { delayTime, setTimeFilter } from '../../../utils/constants';

describe('Testing dashboard table empty state', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

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

describe('After', () => {
before(() => {
cy.deleteAllIndices();
});

it('clean up complete', () => {});
});

0 comments on commit 950571d

Please sign in to comment.