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

[TESTID-125,126,127,128,129] Saved Query Test Scope #9229

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
02bb7d4
add spec for old ui
ArgusLi Jan 9, 2025
af1352d
Add comment about cleaning up saved queries
ArgusLi Jan 9, 2025
d6a713b
Add data-test-subj for save query new ui
ArgusLi Jan 9, 2025
d6e0785
Add data-test-subj for save query button for new ui
ArgusLi Jan 9, 2025
a15bba2
Add data-test-subj for open query button in query management popover
ArgusLi Jan 9, 2025
47fe9a7
Add new ui spec to test list saved queries
ArgusLi Jan 9, 2025
49a9352
Fix DataSource url
ArgusLi Jan 9, 2025
61112c8
Merge branch 'main' into testid-124-list-saved-queries
ArgusLi Jan 9, 2025
00b3f60
Changeset file for PR #9166 created/updated
opensearch-changeset-bot[bot] Jan 9, 2025
edb8f9f
Address Justin's comments.
ArgusLi Jan 10, 2025
4ae05a4
Remove final force.
ArgusLi Jan 10, 2025
b411dd0
Fix final force.
ArgusLi Jan 11, 2025
eeb0c63
Move utils to Suchit's suggested location, fix comments
ArgusLi Jan 13, 2025
3c2b2ec
Rename specs, change cypress workflow to use new save query ui, merge…
ArgusLi Jan 13, 2025
59de88e
Merge main
ArgusLi Jan 13, 2025
6297366
fix import
ArgusLi Jan 14, 2025
bef2e77
Load query
ArgusLi Jan 16, 2025
2cff1df
Complete load query popover and flyout
ArgusLi Jan 16, 2025
2abb5de
Modularize view and load query popover and flyout
ArgusLi Jan 17, 2025
454ac70
Complete valid Saved Queries shown across Visualize Pages
ArgusLi Jan 17, 2025
4ecaf80
Complete Popover delete saved query
ArgusLi Jan 17, 2025
1746c6f
Add data-test-subj for flyoutbody and delete button.
ArgusLi Jan 17, 2025
58251de
Complete flyout delete saved query
ArgusLi Jan 17, 2025
3bac756
Add data-test-subj for saveAsNewQueryCheckbox
ArgusLi Jan 17, 2025
0d98d74
Complete Flyout Update Saved Query
ArgusLi Jan 21, 2025
51e9ce3
Complete Flyout Save as New Saved Query
ArgusLi Jan 21, 2025
7061a43
Complete Popout Save as New Saved Query
ArgusLi Jan 21, 2025
45f8096
Changeset file for PR #9229 created/updated
opensearch-changeset-bot[bot] Jan 21, 2025
4126d79
Merge remote-tracking branch 'origin/main' into discover-tests-saved-…
ArgusLi Jan 21, 2025
965d16a
Fix merge
ArgusLi Jan 21, 2025
71e935a
Merge remote-tracking branch 'origin/main' into discover-tests-saved-…
ArgusLi Jan 21, 2025
cc38990
Move data-test-subj changes to another PR.
ArgusLi Jan 21, 2025
a0e09b2
Remove savedQueriesNewUI
ArgusLi Jan 22, 2025
00351f9
Address all comments.
ArgusLi Jan 22, 2025
2ff0473
Merge branch 'main' into discover-tests-saved-queries
ArgusLi Jan 22, 2025
7e80e64
Fix cypress command namespacing.
ArgusLi Jan 23, 2025
2d2c081
Rename saved queries spec.
ArgusLi Jan 24, 2025
57c2ade
Merge remote-tracking branch 'origin/main' into discover-tests-saved-…
ArgusLi Jan 24, 2025
7e21348
Remove references to flyout
ArgusLi Jan 24, 2025
d193d64
Refactor tests to work with beforeEach and afterEach
ArgusLi Jan 24, 2025
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: 2 additions & 0 deletions changelogs/fragments/9229.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. ([#9229](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9229))
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
* 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 {
verifyDiscoverPageState,
verifyQueryDoesNotExistInSavedQueries,
setQueryConfigurations,
updateAndVerifySavedQuery,
SAVE_AS_NEW_QUERY_SUFFIX,
validateSaveAsNewQueryMatchingNameHasError,
} from '../../../../../utils/apps/query_enhancements/saved_queries';

import {
getRandomizedWorkspaceName,
getRandomizedDatasourceName,
setDatePickerDatesAndSearchIfRelevant,
generateAllTestConfigurations,
} from '../../../../../utils/apps/query_enhancements/shared';

import { generateSavedTestConfiguration } from '../../../../../utils/apps/query_enhancements/saved';

const workspaceName = getRandomizedWorkspaceName();
const datasourceName = getRandomizedDatasourceName();

const createSavedQuery = (config) => {
cy.navigateToWorkSpaceSpecificPage({
workspaceName,
page: 'discover',
isEnhancement: true,
});

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

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

setQueryConfigurations(config);
verifyDiscoverPageState(config);

cy.saveQuery(config.saveName, ' ', true, true);
};

const loadSavedQuery = (config) => {
cy.navigateToWorkSpaceSpecificPage({
workspaceName,
page: 'discover',
isEnhancement: true,
});

cy.getElementByTestId('discoverNewButton').click();
setDatePickerDatesAndSearchIfRelevant(
config.language,
'Aug 29, 2020 @ 00:00:00.000',
'Aug 30, 2020 @ 00:00:00.000'
);

cy.loadSaveQuery(config.saveName);
// wait for saved queries to load.
cy.getElementByTestId('docTable').should('be.visible');
verifyDiscoverPageState(config);
};

const modifyAndVerifySavedQuery = (config, saveAsNewQueryName) => {
if (config.filters) {
cy.deleteAllFilters();
}
setDatePickerDatesAndSearchIfRelevant(config.language);

setQueryConfigurations(config);
verifyDiscoverPageState(config);
validateSaveAsNewQueryMatchingNameHasError(config.saveName);
cy.updateSaveQuery(saveAsNewQueryName, true, true, true);

cy.reload();
cy.loadSaveQuery(saveAsNewQueryName);
// wait for saved query to load
cy.getElementByTestId('docTable').should('be.visible');
verifyDiscoverPageState(config);
};

const deleteSavedQuery = (saveAsNewQueryName) => {
cy.navigateToWorkSpaceSpecificPage({
workspaceName,
page: 'discover',
isEnhancement: true,
});

cy.deleteSaveQuery(saveAsNewQueryName);
verifyQueryDoesNotExistInSavedQueries(saveAsNewQueryName);
};

// This spec assumes data.savedQueriesNewUI.enabled is true.
export const runSavedQueriesUITests = () => {
describe('saved queries UI', () => {
beforeEach(() => {
// 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.osd.createInitialWorkspaceWithDataSource(datasourceName, workspaceName);
cy.createWorkspaceIndexPatterns({
workspaceName: workspaceName,
indexPattern: INDEX_PATTERN_WITH_TIME.replace('*', ''),
timefieldName: 'timestamp',
dataSource: datasourceName,
isEnhancement: true,
});
});

afterEach(() => {
// 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(generateSavedTestConfiguration);

testConfigurations.forEach((config) => {
it(`should create, load, update, modify and delete the saved query: ${config.testName}`, () => {
createSavedQuery(config);
loadSavedQuery(config);
updateAndVerifySavedQuery(config);

const saveAsNewQueryName = config.testName + SAVE_AS_NEW_QUERY_SUFFIX;
modifyAndVerifySavedQuery(config, saveAsNewQueryName);
deleteSavedQuery(saveAsNewQueryName);
});
});
});
};

runSavedQueriesUITests();

This file was deleted.

This file was deleted.

Loading
Loading