Skip to content

Commit

Permalink
[TESTID-77] Index Patterns Caching functionality for Discover (#9331)
Browse files Browse the repository at this point in the history
* Create caching test.

Signed-off-by: Argus Li <[email protected]>

* Changeset file for PR #9331 created/updated

* Create caching test.

Signed-off-by: Argus Li <[email protected]>

* Changeset file for PR #9331 created/updated

* Refactor based on #9319

Signed-off-by: Argus Li <[email protected]>

* Update package.json

Signed-off-by: Suchit Sahoo <[email protected]>

* Remove element.js

Signed-off-by: Argus Li <[email protected]>

---------

Signed-off-by: Argus Li <[email protected]>
Signed-off-by: Suchit Sahoo <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Suchit Sahoo <[email protected]>
Co-authored-by: Anan Zhuang <[email protected]>
  • Loading branch information
4 people authored Feb 12, 2025
1 parent cb7bcc0 commit 4da33a1
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/9331.yml
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))
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);
16 changes: 16 additions & 0 deletions cypress/utils/apps/query_enhancements/caching.js
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();
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"osd:ciGroup10": "BASE_PATH='cypress/integration/core_opensearch_dashboards/opensearch_dashboards/apps/query_enhancements' && echo \"$BASE_PATH/saved_search.spec.js,$BASE_PATH/queries.spec.js,$BASE_PATH/a_check.spec.js,$BASE_PATH/dataset_selector.spec.js,$BASE_PATH/s3_dataset.spec.js,$BASE_PATH/simple_dataset_selector.spec.js\"",
"osd:ciGroup11": "echo \"cypress/integration/dashboard_sanity_test.spec.ts\"",
"osd:ciGroup12": "BASE_PATH='cypress/integration/core_opensearch_dashboards/opensearch_dashboards/apps/query_enhancements' && echo \"$BASE_PATH/time_range_selection.spec.js,$BASE_PATH/saved_queries.spec.js,$BASE_PATH/language_specific_display.spec.js,$BASE_PATH/saved_search_in_dashboards.spec.js\"",
"osd:ciGroup13": "BASE_PATH='cypress/integration/core_opensearch_dashboards/opensearch_dashboards/apps/query_enhancements' && echo \"$BASE_PATH/sidebar.spec.js,$BASE_PATH/shared_links.spec.js,$BASE_PATH/table.spec.js,$BASE_PATH/field_display_filtering.spec.js,$BASE_PATH/inspect.spec.js\"",
"osd:ciGroup13": "BASE_PATH='cypress/integration/core_opensearch_dashboards/opensearch_dashboards/apps/query_enhancements' && echo \"$BASE_PATH/sidebar.spec.js,$BASE_PATH/shared_links.spec.js,$BASE_PATH/table.spec.js,$BASE_PATH/field_display_filtering.spec.js,$BASE_PATH/inspect.spec.js,$BASE_PATH/caching.spec.js\"",
"generate:opensearchsqlantlr": "./node_modules/antlr4ng-cli/index.js -Dlanguage=TypeScript -o ./src/plugins/data/public/antlr/opensearch_sql/.generated -visitor -no-listener -Xexact-output-dir ./src/plugins/data/public/antlr/opensearch_sql/grammar/OpenSearchSQLLexer.g4 ./src/plugins/data/public/antlr/opensearch_sql/grammar/OpenSearchSQLParser.g4",
"generate:opensearchpplantlr": "./node_modules/antlr4ng-cli/index.js -Dlanguage=TypeScript -o ./src/plugins/data/public/antlr/opensearch_ppl/.generated -visitor -no-listener -Xexact-output-dir ./src/plugins/data/public/antlr/opensearch_ppl/grammar/OpenSearchPPLLexer.g4 ./src/plugins/data/public/antlr/opensearch_ppl/grammar/OpenSearchPPLParser.g4"
},
Expand Down

0 comments on commit 4da33a1

Please sign in to comment.