forked from opensearch-project/OpenSearch-Dashboards
-
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.
[TESTID-77] Index Patterns Caching functionality for Discover (opense…
…arch-project#9331) * Create caching test. Signed-off-by: Argus Li <contactme@chunkeili.com> * Changeset file for PR opensearch-project#9331 created/updated * Create caching test. Signed-off-by: Argus Li <contactme@chunkeili.com> * Changeset file for PR opensearch-project#9331 created/updated * Refactor based on opensearch-project#9319 Signed-off-by: Argus Li <contactme@chunkeili.com> * Update package.json Signed-off-by: Suchit Sahoo <38322563+LDrago27@users.noreply.github.com> * Remove element.js Signed-off-by: Argus Li <contactme@chunkeili.com> --------- Signed-off-by: Argus Li <contactme@chunkeili.com> Signed-off-by: Suchit Sahoo <38322563+LDrago27@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Co-authored-by: Suchit Sahoo <38322563+LDrago27@users.noreply.github.com> Co-authored-by: Anan Zhuang <ananzh@amazon.com>
- Loading branch information
1 parent
cb7bcc0
commit 4da33a1
Showing
4 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
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,2 @@ | ||
test: | ||
- Add cypress integration test for the inspect functionality in the Discover and Dashboards pages. ([#9331](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9331)) |
93 changes: 93 additions & 0 deletions
93
.../core_opensearch_dashboards/opensearch_dashboards/apps/query_enhancements/caching.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,93 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { INDEX_PATTERN_WITH_TIME, INDEX_WITH_TIME_1 } from '../../../../../utils/apps/constants.js'; | ||
import { PATHS, BASE_PATH, DATASOURCE_NAME } from '../../../../../utils/constants.js'; | ||
import { DatasetTypes } from '../../../../../utils/apps/query_enhancements/constants.js'; | ||
import { getRandomizedWorkspaceName } from '../../../../../utils/apps/query_enhancements/shared.js'; | ||
import { prepareTestSuite } from '../../../../../utils/helpers'; | ||
|
||
const workspaceName = getRandomizedWorkspaceName(); | ||
|
||
const cachingTestSuite = () => { | ||
describe('caching spec', () => { | ||
beforeEach(() => { | ||
// Load test data | ||
cy.osd.setupTestData( | ||
PATHS.SECONDARY_ENGINE, | ||
['cypress/fixtures/query_enhancements/data_logs_1/data_logs_small_time_1.mapping.json'], | ||
['cypress/fixtures/query_enhancements/data_logs_1/data_logs_small_time_1.data.ndjson'] | ||
); | ||
|
||
// Add data source | ||
cy.osd.addDataSource({ | ||
name: DATASOURCE_NAME, | ||
url: PATHS.SECONDARY_ENGINE, | ||
authType: 'no_auth', | ||
}); | ||
// Create workspace | ||
cy.deleteWorkspaceByName(workspaceName); | ||
cy.visit('/app/home'); | ||
cy.osd.createInitialWorkspaceWithDataSource(DATASOURCE_NAME, workspaceName); | ||
cy.wait(2000); | ||
cy.createWorkspaceIndexPatterns({ | ||
workspaceName: workspaceName, | ||
indexPattern: INDEX_PATTERN_WITH_TIME.replace('*', ''), | ||
timefieldName: 'timestamp', | ||
indexPatternHasTimefield: true, | ||
dataSource: DATASOURCE_NAME, | ||
isEnhancement: true, | ||
}); | ||
|
||
cy.navigateToWorkSpaceSpecificPage({ | ||
url: BASE_PATH, | ||
workspaceName: workspaceName, | ||
page: 'discover', | ||
isEnhancement: true, | ||
}); | ||
cy.getElementByTestId('discoverNewButton').click(); | ||
}); | ||
|
||
afterEach(() => { | ||
cy.deleteWorkspaceByName(workspaceName); | ||
cy.osd.deleteDataSourceByName(DATASOURCE_NAME); | ||
// TODO: Modify deleteIndex to handle an array of index and remove hard code | ||
cy.osd.deleteIndex(INDEX_WITH_TIME_1); | ||
}); | ||
|
||
it('should validate index pattern refresh', () => { | ||
const alternativeIndexPatternName = 'data'; | ||
const alternativeIndexPattern = alternativeIndexPatternName + '*'; | ||
|
||
cy.setDataset(INDEX_PATTERN_WITH_TIME, DATASOURCE_NAME, DatasetTypes.INDEX_PATTERN.name); | ||
cy.createWorkspaceIndexPatterns({ | ||
workspaceName: workspaceName, | ||
indexPattern: alternativeIndexPatternName, | ||
timefieldName: 'timestamp', | ||
indexPatternHasTimefield: true, | ||
dataSource: DATASOURCE_NAME, | ||
isEnhancement: true, | ||
}); | ||
cy.navigateToWorkSpaceSpecificPage({ | ||
url: BASE_PATH, | ||
workspaceName: workspaceName, | ||
page: 'discover', | ||
isEnhancement: true, | ||
}); | ||
|
||
cy.getElementByTestId('datasetSelectorButton').should('be.visible').click(); | ||
cy.getElementByTestId('datasetSelectorAdvancedButton').click(); | ||
cy.intercept('GET', '**/api/saved_objects/_find?fields*').as('getIndexPatternRequest'); | ||
cy.get(`[title="Index Patterns"]`).click(); | ||
|
||
cy.wait('@getIndexPatternRequest').then((interceptedResponse) => { | ||
const secondIndexPattern = interceptedResponse.response.body.saved_objects[1]; | ||
cy.wrap(secondIndexPattern.attributes.title).should('eq', alternativeIndexPattern); | ||
}); | ||
}); | ||
}); | ||
}; | ||
|
||
prepareTestSuite('Caching', cachingTestSuite); |
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,16 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export const navigateToSelectDataAdvancedSelector = () => { | ||
cy.navigateToWorkSpaceSpecificPage({ | ||
url: BASE_PATH, | ||
workspaceName: workspaceName, | ||
page: 'discover', | ||
isEnhancement: true, | ||
}); | ||
|
||
cy.getElementByTestId('datasetSelectorButton').should('be.visible').click(); | ||
cy.getElementByTestId(`datasetSelectorAdvancedButton`).click(); | ||
}; |
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