Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover 2.0 Testing] Create View List of Saved Queries Test (Test-Id 124: View list of Saved query) #9166

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cypress_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
options: --user 1001
env:
START_CMD: ${{ matrix.config == 'query_enhanced' &&
'node scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true --csp.warnLegacyBrowsers=false --uiSettings.overrides["query:enhancements:enabled"]=true --uiSettings.overrides[''home:useNewHomePage'']=true --data_source.enabled=true --workspace.enabled=true --opensearch.ignoreVersionMismatch=true' ||
'node scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true --csp.warnLegacyBrowsers=false --uiSettings.overrides["query:enhancements:enabled"]=true --uiSettings.overrides[''home:useNewHomePage'']=true --data_source.enabled=true --workspace.enabled=true --opensearch.ignoreVersionMismatch=true --data.savedQueriesNewUI.enabled=true' ||
matrix.config == 'dashboard' &&
'node scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true' ||
'node ../scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true --csp.warnLegacyBrowsers=false --uiSettings.overrides["query:enhancements:enabled"]=false' }}
Expand Down
2 changes: 2 additions & 0 deletions changelogs/fragments/9166.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
- Add cypress integration test for the old and new UI view saved queries. ([#9166](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9166))
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
END_TIME,
DATASET_CONFIGS,
} from '../../../../../utils/apps/constants';
import * as dataExplorer from '../../../../../integration/core-opensearch-dashboards/opensearch-dashboards/apps/query_enhancements/utils/field_display_filtering.js';
import * as dataExplorer from '../../../../../utils/apps/query_enhancements/field_display_filtering.js';
import { SECONDARY_ENGINE, BASE_PATH } from '../../../../../utils/constants';
import { NEW_SEARCH_BUTTON } from '../../../../../utils/dashboards/data_explorer/elements.js';

Expand Down Expand Up @@ -223,7 +223,7 @@ describe('filter for value spec', () => {
});

after(() => {
cy.deleteWorkspaceByName(`${WORKSPACE_NAME}`);
cy.deleteWorkspaceByName(`${workspace}`);
cy.deleteDataSourceByName(`${DATASOURCE_NAME}`);
// TODO: Modify deleteIndex to handle an array of index and remove hard code
cy.deleteIndex(INDEX_PATTERN_NAME);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
INDEX_PATTERN_WITH_TIME,
INDEX_WITH_TIME_1,
INDEX_WITH_TIME_2,
SECONDARY_ENGINE,
} from '../../../../../utils/constants';

import {
workspaceName,
datasourceName,
setSearchConfigurations,
setDatePickerDatesAndSearchIfRelevant,
verifyDiscoverPageState,
} from '../../../../../utils/apps/query_enhancements/saved_search';

import { generateAllTestConfigurations } from '../../../../../utils/apps/query_enhancements/saved_queries';

// This spec assumes data.savedQueriesNewUI.enabled is true.

export const runSavedQueriesFlyoutUITests = () => {
describe('saved queries flyout UI', () => {
before(() => {
// Load test data
cy.setupTestData(
SECONDARY_ENGINE.url,
[
`cypress/fixtures/query_enhancements/data-logs-1/${INDEX_WITH_TIME_1}.mapping.json`,
`cypress/fixtures/query_enhancements/data-logs-2/${INDEX_WITH_TIME_2}.mapping.json`,
],
[
`cypress/fixtures/query_enhancements/data-logs-1/${INDEX_WITH_TIME_1}.data.ndjson`,
`cypress/fixtures/query_enhancements/data-logs-2/${INDEX_WITH_TIME_2}.data.ndjson`,
]
);
// Add data source
cy.addDataSource({
name: datasourceName,
url: SECONDARY_ENGINE.url,
authType: 'no_auth',
});

// Create workspace
cy.deleteWorkspaceByName(workspaceName);
cy.visit('/app/home');
cy.createInitialWorkspaceWithDataSource(datasourceName, workspaceName);
cy.createWorkspaceIndexPatterns({
workspaceName: workspaceName,
indexPattern: INDEX_PATTERN_WITH_TIME.replace('*', ''),
timefieldName: 'timestamp',
dataSource: datasourceName,
isEnhancement: true,
});
});

after(() => {
// No need to explicitly delete all saved queries as deleting the workspace will delete associated saved queries
cy.deleteWorkspaceByName(workspaceName);
// // TODO: Modify deleteIndex to handle an array of index and remove hard code
cy.deleteDataSourceByName(datasourceName);
cy.deleteIndex(INDEX_WITH_TIME_1);
cy.deleteIndex(INDEX_WITH_TIME_2);
});

const testConfigurations = generateAllTestConfigurations();
testConfigurations.forEach((config) => {
it(`should successfully create a saved query for ${config.testName}`, () => {
cy.navigateToWorkSpaceSpecificPage({
workspaceName,
page: 'discover',
isEnhancement: true,
});

cy.setDataset(config.dataset, datasourceName, config.datasetType);

cy.setQueryLanguage(config.language);
setDatePickerDatesAndSearchIfRelevant(config.language);

setSearchConfigurations(config);
verifyDiscoverPageState(config);
cy.saveQuery(config.saveName);
});
});

it('should see all saved queries', () => {
cy.getElementByTestId('saved-query-management-popover-button').click();

cy.getElementByTestId('saved-query-management-open-button').click();

testConfigurations.forEach((config) => {
cy.getElementByTestId('euiFlyoutCloseButton')
.parent()
.contains(config.saveName)
.should('exist');
});
});
});
};

runSavedQueriesFlyoutUITests();
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
INDEX_PATTERN_WITH_TIME,
INDEX_WITH_TIME_1,
INDEX_WITH_TIME_2,
SECONDARY_ENGINE,
} from '../../../../../utils/constants';

import {
workspaceName,
datasourceName,
setSearchConfigurations,
setDatePickerDatesAndSearchIfRelevant,
verifyDiscoverPageState,
} from '../../../../../utils/apps/query_enhancements/saved_search';

import { generateAllTestConfigurations } from '../../../../../utils/apps/query_enhancements/saved_queries';

// This spec assumes data.savedQueriesNewUI.enabled is false.
// These tests will not be run until the older legacy tests are migrated https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9166#discussion_r1913687440

export const runSavedQueriesPopoverUITests = () => {
describe.skip('saved queries popover UI', () => {
before(() => {
// Load test data
cy.setupTestData(
SECONDARY_ENGINE.url,
[
`cypress/fixtures/query_enhancements/data-logs-1/${INDEX_WITH_TIME_1}.mapping.json`,
`cypress/fixtures/query_enhancements/data-logs-2/${INDEX_WITH_TIME_2}.mapping.json`,
],
[
`cypress/fixtures/query_enhancements/data-logs-1/${INDEX_WITH_TIME_1}.data.ndjson`,
`cypress/fixtures/query_enhancements/data-logs-2/${INDEX_WITH_TIME_2}.data.ndjson`,
]
);
// Add data source
cy.addDataSource({
name: datasourceName,
url: SECONDARY_ENGINE.url,
authType: 'no_auth',
});

// Create workspace
cy.deleteWorkspaceByName(workspaceName);
cy.visit('/app/home');
cy.createInitialWorkspaceWithDataSource(datasourceName, workspaceName);
cy.createWorkspaceIndexPatterns({
workspaceName: workspaceName,
indexPattern: INDEX_PATTERN_WITH_TIME.replace('*', ''),
timefieldName: 'timestamp',
dataSource: datasourceName,
isEnhancement: true,
});
});

after(() => {
// No need to explicitly delete all saved queries as deleting the workspace will delete associated saved queries
cy.deleteWorkspaceByName(workspaceName);
// // TODO: Modify deleteIndex to handle an array of index and remove hard code
cy.deleteDataSourceByName(datasourceName);
cy.deleteIndex(INDEX_WITH_TIME_1);
cy.deleteIndex(INDEX_WITH_TIME_2);
});

const testConfigurations = generateAllTestConfigurations();
testConfigurations.forEach((config) => {
it(`should successfully create a saved query for ${config.testName}`, () => {
cy.navigateToWorkSpaceSpecificPage({
workspaceName,
page: 'discover',
isEnhancement: true,
});

cy.setDataset(config.dataset, datasourceName, config.datasetType);

cy.setQueryLanguage(config.language);
setDatePickerDatesAndSearchIfRelevant(config.language);

setSearchConfigurations(config);
verifyDiscoverPageState(config);
cy.saveQuery(config.saveName, ' ', false);
});
});

it('should see all saved queries', () => {
cy.getElementByTestId('saved-query-management-popover-button').click();

testConfigurations.forEach((config) => {
cy.getElementByTestId('saved-query-management-popover')
.contains(config.saveName)
.should('exist');
});
});
});
};

runSavedQueriesPopoverUITests();
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
verifySavedSearchInAssetsPage,
postRequestSaveSearch,
updateSavedSearchAndSaveAndVerify,
} from './utils/saved_search';
} from '../../../../../utils/apps/query_enhancements/saved_search';

export const runSavedSearchTests = () => {
describe('saved search', () => {
Expand Down
6 changes: 5 additions & 1 deletion cypress/utils/apps/data_explorer/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,18 @@ Cypress.Commands.add(
}
);

Cypress.Commands.add('saveQuery', (name, description) => {
// eslint-disable-next-line no-unused-vars
Cypress.Commands.add('saveQuery', (name, description = ' ', savedQueriesNewUIEnabled = true) => {
cy.whenTestIdNotFound('saved-query-management-popover', () => {
cy.getElementByTestId('saved-query-management-popover-button').click();
});
cy.getElementByTestId('saved-query-management-save-button').click();

cy.getElementByTestId('saveQueryFormTitle').type(name);
cy.getElementByTestId('saveQueryFormDescription').type(description);

cy.getElementByTestId('savedQueryFormSaveButton').click();
cy.getElementByTestId('euiToastHeader').contains('was saved').should('be.visible');
});

Cypress.Commands.add('loadSaveQuery', (name) => {
Expand Down
Loading
Loading