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] TestId-69: Filtering #9047

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2b6cce4
Update Cypress to v12 (#8926)
d-rowe Nov 27, 2024
fab8612
fix: support imports without extensions in cypress webpack build (#8993)
d-rowe Dec 2, 2024
1d8ad94
Add utils to select a data source.
ArgusLi Dec 3, 2024
af1fd47
Add support for different languages when creating dataset. Filter Out…
ArgusLi Dec 4, 2024
a19ec29
Reformat to match OSD-functional-tests.
ArgusLi Dec 4, 2024
9877480
Upgrade Cypress to v12 (#8995)
d-rowe Dec 3, 2024
ea46542
Complete test suite filter actions in table field.
ArgusLi Dec 5, 2024
aa22a2c
Address comments.
ArgusLi Dec 5, 2024
72a6cb0
Reformat to use POM.
ArgusLi Dec 5, 2024
bd63276
Add support for expanded row filters.
ArgusLi Dec 10, 2024
5bc51cc
Change constants to discussed constants.
ArgusLi Dec 10, 2024
5c1a664
Refactor to use absolute dates, move the constants to the spec and us…
ArgusLi Dec 10, 2024
8f80b00
Fix Buttons not detecting if disabled.
ArgusLi Dec 10, 2024
d079a1c
Add support for expanded table toggleColumnButton Checks.
ArgusLi Dec 11, 2024
4b8d816
Add Exists Filter functionality.
ArgusLi Dec 11, 2024
f4b27c2
Remove conflicting Cypress config file.
ArgusLi Dec 11, 2024
d71b64b
Reorganize tests within spec to reduce code duplication. Make small c…
ArgusLi Dec 13, 2024
3aec4ec
Remove reverted main changes.
ArgusLi Dec 17, 2024
d906614
Changeset file for PR #9047 created/updated
opensearch-changeset-bot[bot] Dec 17, 2024
ae8dae4
Address comments and fix test after rebasing.
ArgusLi Dec 18, 2024
60ede88
Address comments and fix test after rebasing.
ArgusLi Dec 19, 2024
cad9a58
Remove files added by commit https://github.com/opensearch-project/Op…
ArgusLi Dec 19, 2024
9589aed
sidebar.md
silva-qa Dec 20, 2024
c37777c
add helper and modify spec
silva-qa Dec 20, 2024
fca8e6a
fix imports
silva-qa Dec 20, 2024
b91eb09
fix more imports
silva-qa Dec 20, 2024
004139f
Fix toggleDocTableRow helper function.
ArgusLi Dec 22, 2024
ab7a186
Refactor test framework to address review comment.
ArgusLi Dec 22, 2024
ad24614
Fix rebase.
ArgusLi Dec 23, 2024
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: 0 additions & 2 deletions changelogs/fragments/8611.yml

This file was deleted.

2 changes: 0 additions & 2 deletions changelogs/fragments/8935.yml

This file was deleted.

2 changes: 2 additions & 0 deletions changelogs/fragments/9047.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
- Add cypress integration test for the new Data Explorer UI's Filtering. ([#9047](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9047))
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = defineConfig({
},
e2e: {
baseUrl: 'http://localhost:5601',
supportFile: 'cypress/support/e2e.{js,jsx,ts,tsx}',
specPattern: 'cypress/integration/**/*.spec.{js,jsx,ts,tsx}',
testIsolation: false,
setupNodeEvents,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,31 @@
* SPDX-License-Identifier: Apache-2.0
*/

export const DATASOURCE_NAME = 'query-cluster';
export const WORKSPACE_NAME = 'query-workspace';
export const DATASOURCE_NAME = 'data-logs-1';
export const INDEX_NAME = 'data_logs_small_time_1';
export const DEFAULT_TIME_INDEX_PATTERN_NAME = 'data_logs_small_time_1*';
export const DEFAULT_NO_TIME_INDEX_PATTERN_NAME = 'data_logs_small_no_time_1*';
export const INDEX_PATTERN_NAME = `${DATASOURCE_NAME}::${DEFAULT_TIME_INDEX_PATTERN_NAME}`;
export const SEARCH_ABSOLUTE_START_DATE = 'Jan 1, 2020 @ 00:00:00.000';
export const SEARCH_ABSOLUTE_END_DATE = 'Jan 1, 2024 @ 00:00:00.000';

export const DATASET_CONFIGS = {
index_pattern: {
type: 'index_pattern',
name: INDEX_PATTERN_NAME,
languages: [
{ name: 'DQL', isEnabled: true },
{ name: 'Lucene', isEnabled: true },
{ name: 'OpenSearch SQL', isEnabled: false },
{ name: 'PPL', isEnabled: false },
],
},
index: {
type: 'index',
name: INDEX_NAME,
languages: [
{ name: 'OpenSearch SQL', isEnabled: false },
{ name: 'PPL', isEnabled: false },
],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import {
DATASOURCE_NAME,
DATASET_CONFIGS,
INDEX_NAME,
INDEX_PATTERN_NAME,
SEARCH_ABSOLUTE_START_DATE,
SEARCH_ABSOLUTE_END_DATE,
} from './constants.js';
import * as dataExplorer from './helpers.js';

const miscUtils = new MiscUtils(cy);

function selectDataset(datasetType, language) {
switch (datasetType) {
case 'index':
dataExplorer.selectIndexDataset(DATASOURCE_NAME, INDEX_NAME, language);
break;
case 'index_pattern':
dataExplorer.selectIndexPatternDataset(INDEX_PATTERN_NAME, language);
break;
}
}

function setDateRange(datasetType, language) {
switch (datasetType) {
case 'index_pattern':
if (language !== 'OpenSearch SQL') {
cy.setSearchAbsoluteDateRange(SEARCH_ABSOLUTE_START_DATE, SEARCH_ABSOLUTE_END_DATE);
}
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this function selectDataSet does more than select dataset (ie it can also set the abs date range). I think the the setting the date range shouldn't be part of this function, as that can lead to confusion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me to decouple and have the function do one function. I was trying to reduce the number of compares by 1, but that's needless optimization.


function verifyTableFieldFilterActions(datasetType, language, shouldExist) {
selectDataset(datasetType, language);
setDateRange(datasetType, language);

cy.getElementByTestId('discoverQueryHits').should('not.exist'); // To ensure it waits until a full table is loaded into the DOM, instead of a bug where table only has 1 hit.

dataExplorer.verifyDocTableRowFilterForAndOutButton(0, shouldExist);

if (shouldExist) {
dataExplorer.verifyDocTableFilterAction(0, 'filterForValue', '10,000', '1', true);
dataExplorer.verifyDocTableFilterAction(0, 'filterOutValue', '10,000', '9,999', false);
}
}

function verifyExpandedTableFilterActions(datasetType, language, isEnabled) {
selectDataset(datasetType, language);
setDateRange(datasetType, language);

cy.getElementByTestId('discoverQueryHits').should('not.exist'); // To ensure it waits until a full table is loaded into the DOM, instead of a bug where table only has 1 hit.
dataExplorer.toggleDocTableRow(0);
dataExplorer.verifyDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons(
isEnabled
);
dataExplorer.verifyDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior();

if (isEnabled) {
dataExplorer.verifyDocTableFirstExpandedFieldFirstRowFilterForButtonFiltersCorrectField(
0,
0,
'10,000',
'1'
);
dataExplorer.verifyDocTableFirstExpandedFieldFirstRowFilterOutButtonFiltersCorrectField(
0,
0,
'10,000',
'9,999'
);
dataExplorer.verifyDocTableFirstExpandedFieldFirstRowExistsFilterButtonFiltersCorrectField(
0,
0,
'10,000',
'10,000'
);
}
}

describe('filter for value spec', () => {
beforeEach(() => {
cy.localLogin(Cypress.env('username'), Cypress.env('password'));
miscUtils.visitPage('app/data-explorer/discover');
cy.getNewSearchButton().click();
});

const testCases = [
{ name: 'table field', verifyFn: verifyTableFieldFilterActions },
{ name: 'expanded table', verifyFn: verifyExpandedTableFilterActions },
];

testCases.forEach(({ name, verifyFn }) => {
describe(`filter actions in ${name}`, () => {
Object.entries(DATASET_CONFIGS).forEach(([type, config]) => {
describe(`${type} dataset`, () => {
config.languages.forEach(({ name: language, isEnabled }) => {
it(`${language}`, () => {
verifyFn(type, language, isEnabled);
});
});
});
});
});
});
});
Loading