-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opensearch-project#3 from eugenesk24/add-test-data
Add before and after specs
- Loading branch information
Showing
3 changed files
with
99 additions
and
59 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
cypress/integration/plugins/observability-dashboards/0_before.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', () => {}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
cypress/integration/plugins/observability-dashboards/8_after.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', () => {}); | ||
}); |