-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Qingyang(Abby) Hu <[email protected]>
- Loading branch information
1 parent
be1f578
commit b1c51cb
Showing
3 changed files
with
348 additions
and
0 deletions.
There are no files selected for viewing
174 changes: 174 additions & 0 deletions
174
...ards/opensearch-dashboards/apps/data_explorer/query_enhancement/dataset_navigator.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,174 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { | ||
MiscUtils, | ||
TestFixtureHandler, | ||
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; | ||
import { CURRENT_TENANT } from '../../../../../../utils/commands'; | ||
|
||
const miscUtils = new MiscUtils(cy); | ||
const testFixtureHandler = new TestFixtureHandler( | ||
cy, | ||
Cypress.env('openSearchUrl') | ||
); | ||
|
||
const indexSet = [ | ||
'logstash-2015.09.22', | ||
'logstash-2015.09.21', | ||
'logstash-2015.09.20', | ||
]; | ||
|
||
describe('dataset navigator', { scrollBehavior: false }, () => { | ||
before(() => { | ||
CURRENT_TENANT.newTenant = 'global'; | ||
cy.fleshTenantSettings(); | ||
cy.deleteAllIndices(); | ||
cy.deleteSavedObjectByType('index-pattern'); | ||
}); | ||
|
||
describe('empty state', () => { | ||
it('no index pattern', function () { | ||
// Go to the Discover page | ||
miscUtils.visitPage( | ||
`app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` | ||
); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
cy.getElementByTestId('discoverNoIndexPatterns'); | ||
}); | ||
}); | ||
|
||
describe('select indices', () => { | ||
before(() => { | ||
// import logstash functional | ||
testFixtureHandler.importJSONDocIfNeeded( | ||
indexSet, | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' | ||
); | ||
|
||
// Go to the Discover page | ||
miscUtils.visitPage( | ||
`app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` | ||
); | ||
}); | ||
|
||
it('with SQL as default language', function () { | ||
cy.get(`[class~="datasetSelector__button"]`).click(); | ||
cy.get(`[class~="datasetSelector__advancedButton"]`).click(); | ||
cy.get(`[title="Indexes"]`).click(); | ||
cy.get(`[title="Default Cluster"]`).click(); | ||
cy.get(`[title="logstash-2015.09.20"]`).click(); | ||
cy.getElementByTestId('datasetSelectorNext').click(); | ||
|
||
cy.get(`[class="euiModalHeader__title"]`).should( | ||
'contain', | ||
'Step 2: Configure data' | ||
); | ||
// should have two options: SQL and PPL | ||
cy.get('option').should('have.length', 2); | ||
cy.getElementByTestId('advancedSelectorConfirmButton').click(); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
|
||
// Selected language should be SQL | ||
cy.getElementByTestId('queryEditorLanguageSelector').should( | ||
'contain', | ||
'SQL' | ||
); | ||
|
||
// The following steps are needed because when selecting SQL, discover loaded with data but the | ||
// multi-line query editor are not loaded properly(it renders a single line query bar) unless we select SQL again | ||
// This bug only exist in cypress test; can not reproduce manually | ||
cy.get(`[data-test-subj="queryEditorLanguageSelector"]`).click(); | ||
cy.get(`[class~="languageSelector__menuItem"]`) | ||
.should('have.length', 2) | ||
.eq(1) | ||
.click({ | ||
force: true, | ||
}); | ||
cy.waitForLoaderNewHeader(); | ||
cy.get(`[data-test-subj="queryResultCompleteMsg"]`).should('be.visible'); | ||
|
||
// Switch language to PPL | ||
cy.get(`[data-test-subj="queryEditorLanguageSelector"]`).click(); | ||
cy.get(`[class~="languageSelector__menuItem"]`).eq(0).click({ | ||
force: true, | ||
}); | ||
cy.waitForLoaderNewHeader(); | ||
cy.get(`[data-test-subj="queryResultCompleteMsg"]`).should('be.visible'); | ||
}); | ||
|
||
it('with PPL as default language', function () { | ||
cy.get(`[class~="datasetSelector__button"]`).click(); | ||
cy.get(`[class~="datasetSelector__advancedButton"]`).click(); | ||
cy.get(`[title="Indexes"]`).click(); | ||
cy.get(`[title="Default Cluster"]`).click(); | ||
cy.get(`[title="logstash-2015.09.21"]`).click(); | ||
cy.getElementByTestId('datasetSelectorNext').click(); | ||
|
||
cy.get(`[class="euiModalHeader__title"]`).should( | ||
'contain', | ||
'Step 2: Configure data' | ||
); | ||
// should have two options: SQL and PPL; PPL should be selected | ||
cy.getElementByTestId('advancedSelectorTimeFieldSelect').select( | ||
'@timestamp' | ||
); | ||
cy.getElementByTestId('advancedSelectorConfirmButton').click(); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
|
||
// Selected language should be PPL | ||
cy.getElementByTestId('queryEditorLanguageSelector').should( | ||
'contain', | ||
'PPL' | ||
); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
cy.getElementByTestId('queryResultCompleteMsg').should('be.visible'); | ||
cy.getElementByTestId('queryEditorFooterTimestamp').should( | ||
'contain', | ||
'@timestamp' | ||
); | ||
|
||
// Switch language to SQL | ||
cy.getElementByTestId('queryEditorLanguageSelector').click(); | ||
cy.get(`[class~="languageSelector__menuItem"]`).eq(1).click({ | ||
force: true, | ||
}); | ||
cy.waitForLoaderNewHeader(); | ||
cy.getElementByTestId('queryResultCompleteMsg').should('be.visible'); | ||
cy.getElementByTestId('queryEditorFooterTimestamp').should( | ||
'contain', | ||
'@timestamp' | ||
); | ||
}); | ||
}); | ||
|
||
describe('index pattern', () => { | ||
it('create index pattern and select it', function () { | ||
testFixtureHandler.importJSONMapping( | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.mappings.json.txt' | ||
); | ||
|
||
testFixtureHandler.importJSONDoc( | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.json.txt' | ||
); | ||
|
||
// Go to the Discover page | ||
miscUtils.visitPage( | ||
`app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` | ||
); | ||
|
||
cy.get(`[class~="datasetSelector__button"]`).click(); | ||
cy.getElementByTestId(`datasetOption-logstash-*`).click(); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
cy.waitForSearch(); | ||
cy.verifyHitCount('14,004'); | ||
}); | ||
}); | ||
}); |
127 changes: 127 additions & 0 deletions
127
...rch-dashboards/opensearch-dashboards/apps/data_explorer/query_enhancement/queries.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,127 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { | ||
MiscUtils, | ||
TestFixtureHandler, | ||
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; | ||
import { CURRENT_TENANT } from '../../../../../../utils/commands'; | ||
|
||
const miscUtils = new MiscUtils(cy); | ||
const testFixtureHandler = new TestFixtureHandler( | ||
cy, | ||
Cypress.env('openSearchUrl') | ||
); | ||
|
||
const indexSet = [ | ||
'logstash-2015.09.22', | ||
'logstash-2015.09.21', | ||
'logstash-2015.09.20', | ||
]; | ||
|
||
describe('query enhancement queries', { scrollBehavior: false }, () => { | ||
before(() => { | ||
CURRENT_TENANT.newTenant = 'global'; | ||
cy.fleshTenantSettings(); | ||
cy.deleteAllIndices(); | ||
cy.deleteSavedObjectByType('index-pattern'); | ||
// import logstash functional | ||
testFixtureHandler.importJSONDocIfNeeded( | ||
indexSet, | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' | ||
); | ||
|
||
testFixtureHandler.importJSONMapping( | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.mappings.json.txt' | ||
); | ||
|
||
testFixtureHandler.importJSONDoc( | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.json.txt' | ||
); | ||
|
||
// miscUtils.visitPage(`app/import_sample_data`); | ||
// cy.getElementByTestId( | ||
// 'addSampleDataSetecommerce' | ||
// ).click(); | ||
// cy.waitForLoaderNewHeader(); | ||
|
||
cy.setAdvancedSetting({ | ||
defaultIndex: 'logstash-*', | ||
}); | ||
|
||
// Go to the Discover page | ||
miscUtils.visitPage( | ||
`app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` | ||
); | ||
|
||
cy.get(`[class~="datasetSelector__button"]`).click(); | ||
cy.get(`[data-test-subj="datasetOption-logstash-*"]`).click(); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
cy.waitForSearch(); | ||
}); | ||
|
||
describe('send queries', () => { | ||
it('with DQL', function () { | ||
const query = `geo.src:FR`; | ||
cy.setSingleLineQueryEditor(query); | ||
cy.waitForLoaderNewHeader(); | ||
cy.waitForSearch(); | ||
cy.verifyHitCount(119); | ||
|
||
//query should persist across refresh | ||
cy.reload(); | ||
cy.verifyHitCount(119); | ||
}); | ||
|
||
it('with Lucene', function () { | ||
cy.get(`[data-test-subj="queryEditorLanguageSelector"]`).click(); | ||
cy.get(`[class~="languageSelector__menuItem"]`).eq(1).click({ | ||
force: true, | ||
}); | ||
|
||
const query = `geo.src:FR`; | ||
cy.setSingleLineQueryEditor(query); | ||
cy.waitForLoaderNewHeader(); | ||
cy.waitForSearch(); | ||
cy.verifyHitCount(119); | ||
|
||
//query should persist across refresh | ||
cy.reload(); | ||
cy.verifyHitCount(119); | ||
}); | ||
|
||
it('with PPL', function () { | ||
cy.get(`[data-test-subj="queryEditorLanguageSelector"]`).click(); | ||
cy.get(`[class~="languageSelector__menuItem"]`).eq(2).click({ | ||
force: true, | ||
}); | ||
|
||
// default PPL query should be set | ||
cy.waitForLoaderNewHeader(); | ||
cy.waitForSearch(); | ||
cy.verifyHitCount('14,004'); | ||
|
||
//query should persist across refresh | ||
cy.reload(); | ||
cy.verifyHitCount('14,004'); | ||
}); | ||
|
||
it('with SQL', function () { | ||
cy.get(`[data-test-subj="queryEditorLanguageSelector"]`).click(); | ||
cy.get(`[class~="languageSelector__menuItem"]`).eq(3).click({ | ||
force: true, | ||
}); | ||
|
||
// default SQL query should be set | ||
cy.waitForLoaderNewHeader(); | ||
cy.get(`[data-test-subj="queryResultCompleteMsg"]`).should('be.visible'); | ||
|
||
//query should persist across refresh | ||
cy.reload(); | ||
cy.get(`[data-test-subj="queryResultCompleteMsg"]`).should('be.visible'); | ||
}); | ||
}); | ||
}); |
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