From 444dbbe040c414a05771149533987ad847ee7d2d Mon Sep 17 00:00:00 2001 From: Argus Li Date: Wed, 11 Dec 2024 15:27:34 -0800 Subject: [PATCH] Add Exists Filter functionality. Signed-off-by: Argus Li --- ...pec.js => field_display_filtering_spec.js} | 26 ++++++++--- .../data_explorer/data_explorer_page.po.js | 45 +++++++++++++++++-- .../dashboards/data_explorer/elements.js | 1 + 3 files changed, 62 insertions(+), 10 deletions(-) rename cypress/integration/core_opensearch_dashboards/{filter_for_value_spec.js => field_display_filtering_spec.js} (90%) diff --git a/cypress/integration/core_opensearch_dashboards/filter_for_value_spec.js b/cypress/integration/core_opensearch_dashboards/field_display_filtering_spec.js similarity index 90% rename from cypress/integration/core_opensearch_dashboards/filter_for_value_spec.js rename to cypress/integration/core_opensearch_dashboards/field_display_filtering_spec.js index a9a2093165c2..b80de3068da8 100644 --- a/cypress/integration/core_opensearch_dashboards/filter_for_value_spec.js +++ b/cypress/integration/core_opensearch_dashboards/field_display_filtering_spec.js @@ -72,26 +72,34 @@ describe('filter for value spec', () => { DataExplorerPage.selectIndexPatternDataset(INDEX_PATTERN_NAME, 'DQL'); cy.setSearchAbsoluteDateRange(SEARCH_ABSOLUTE_START_DATE, SEARCH_ABSOLUTE_END_DATE); DataExplorerPage.toggleDocTableRow(0); - DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForAndOutButtons(true); + DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons( + true + ); DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForButtonFiltersCorrectField(); DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterOutButtonFiltersCorrectField(); DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior(); + DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowExistsFilterButtonFiltersCorrectField(); }); // filter actions should exist for Lucene it('Lucene', () => { DataExplorerPage.selectIndexPatternDataset(INDEX_PATTERN_NAME, 'Lucene'); cy.setSearchAbsoluteDateRange(SEARCH_ABSOLUTE_START_DATE, SEARCH_ABSOLUTE_END_DATE); DataExplorerPage.toggleDocTableRow(0); - DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForAndOutButtons(true); + DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons( + true + ); DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForButtonFiltersCorrectField(); DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterOutButtonFiltersCorrectField(); DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior(); + DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowExistsFilterButtonFiltersCorrectField(); }); // filter actions should not exist for SQL it('SQL', () => { DataExplorerPage.selectIndexPatternDataset(INDEX_PATTERN_NAME, 'SQL'); DataExplorerPage.toggleDocTableRow(0); - DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForAndOutButtons(false); + DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons( + false + ); DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior(); }); // filter actions should not exist for PPL @@ -99,7 +107,9 @@ describe('filter for value spec', () => { DataExplorerPage.selectIndexPatternDataset(INDEX_PATTERN_NAME, 'PPL'); cy.setSearchAbsoluteDateRange(SEARCH_ABSOLUTE_START_DATE, SEARCH_ABSOLUTE_END_DATE); DataExplorerPage.toggleDocTableRow(0); - DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForAndOutButtons(false); + DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons( + false + ); DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior(); }); }); @@ -108,14 +118,18 @@ describe('filter for value spec', () => { it('SQL', () => { DataExplorerPage.selectIndexDataset(INDEX_CLUSTER_NAME, INDEX_NAME, 'OpenSearch SQL'); DataExplorerPage.toggleDocTableRow(0); - DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForAndOutButtons(false); + DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons( + false + ); DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior(); }); // filter actions should not exist for PPL it('PPL', () => { DataExplorerPage.selectIndexDataset(INDEX_CLUSTER_NAME, INDEX_NAME, 'PPL'); DataExplorerPage.toggleDocTableRow(0); - DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForAndOutButtons(false); + DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons( + false + ); DataExplorerPage.checkDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior(); }); }); diff --git a/cypress/utils/dashboards/data_explorer/data_explorer_page.po.js b/cypress/utils/dashboards/data_explorer/data_explorer_page.po.js index 58809268db8e..03b1e476a370 100644 --- a/cypress/utils/dashboards/data_explorer/data_explorer_page.po.js +++ b/cypress/utils/dashboards/data_explorer/data_explorer_page.po.js @@ -251,6 +251,15 @@ export class DataExplorerPage { ); } + /** + * Get Exists Filter Button in Doc Table Field Expanded Document Row. + */ + static getDocTableExpandedDocRowExistsFilterButton() { + return cy.getElementByTestId( + DATA_EXPLORER_PAGE_ELEMENTS.DOC_TABLE_EXPANDED_DOC_COLUMN_EXISTS_FILTER_BUTTON + ); + } + /** * Open window to select Dataset */ @@ -340,6 +349,17 @@ export class DataExplorerPage { DataExplorerPage.getGlobalQueryEditorFilterValue().should('have.text', expectedFilterText); } + /** + * Check the entire filter pill text matches expectedFilterText. + * @param expectedFilterText expected text in filter pill. + */ + static checkFullFilterPillText(expectedFilterText) { + // GLOBAL_QUERY_EDITOR_FILTER_VALUE gives the inner element, but we may want all the text in the filter pill + DataExplorerPage.getGlobalQueryEditorFilterValue() + .parent() + .should('have.text', expectedFilterText); + } + /** * Check the query hit text matches expectedQueryHitText. * @param expectedQueryHitsText expected text for query hits @@ -399,14 +419,15 @@ export class DataExplorerPage { } /** - * Check if the first expanded Doc Table Field's first row's Filter For and Filter Out button are disabled. + * Check if the first expanded Doc Table Field's first row's Filter For, Filter Out and Exists Filter buttons are disabled. * @param isEnabled Boolean determining if these buttons are disabled */ - static checkDocTableFirstExpandedFieldFirstRowFilterForAndOutButtons(isEnabled) { + static checkDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons(isEnabled) { const shouldText = isEnabled ? 'be.enabled' : 'be.disabled'; DataExplorerPage.getExpandedDocRow(0, 0).within(() => { DataExplorerPage.getDocTableExpandedDocRowFilterForButton().should(shouldText); - DataExplorerPage.getDocTableExpandedDocRowFilterForButton().should(shouldText); + DataExplorerPage.getDocTableExpandedDocRowFilterOutButton().should(shouldText); + DataExplorerPage.getDocTableExpandedDocRowExistsFilterButton().should(shouldText); }); } @@ -447,7 +468,7 @@ export class DataExplorerPage { } /** - * Check the first expanded Doc Table Field's first row's Toggle Column button filters the correct value. + * Check the first expanded Doc Table Field's first row's Toggle Column button has intended behavior. */ static checkDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior() { DataExplorerPage.getExpandedDocRowFieldName(0, 0).then(($expandedDocumentRowFieldText) => { @@ -467,4 +488,20 @@ export class DataExplorerPage { DataExplorerPage.getDocTableHeader(fieldText).should('not.exist'); }); } + + /** + * Check the first expanded Doc Table Field's first row's Exists Filter button filters the correct Field. + */ + static checkDocTableFirstExpandedFieldFirstRowExistsFilterButtonFiltersCorrectField() { + DataExplorerPage.getExpandedDocRowFieldName(0, 0).then(($expandedDocumentRowField) => { + const filterFieldText = $expandedDocumentRowField.text(); + DataExplorerPage.getExpandedDocRow(0, 0).within(() => { + DataExplorerPage.getDocTableExpandedDocRowExistsFilterButton().click(); + }); + DataExplorerPage.checkFullFilterPillText(filterFieldText + ': ' + 'exists'); + DataExplorerPage.checkQueryHitsText('10,000'); + }); + DataExplorerPage.getFilterBar().find('[aria-label="Delete"]').click(); + DataExplorerPage.checkQueryHitsText('10,000'); + } } diff --git a/cypress/utils/dashboards/data_explorer/elements.js b/cypress/utils/dashboards/data_explorer/elements.js index dbed87949ddb..2613b747271c 100644 --- a/cypress/utils/dashboards/data_explorer/elements.js +++ b/cypress/utils/dashboards/data_explorer/elements.js @@ -20,6 +20,7 @@ export const DATA_EXPLORER_PAGE_ELEMENTS = { DOC_TABLE_EXPANDED_DOC_TOGGLE_COLUMN_BUTTON: 'toggleColumnButton', DOC_TABLE_EXPANDED_DOC_COLUMN_ADD_INCLUSIVE_FILTER_BUTTON: 'addInclusiveFilterButton', DOC_TABLE_EXPANDED_DOC_COLUMN_REMOVE_INCLUSIVE_FILTER_BUTTON: 'removeInclusiveFilterButton', + DOC_TABLE_EXPANDED_DOC_COLUMN_EXISTS_FILTER_BUTTON: 'addExistsFilterButton', DOC_TABLE_HEADER_FIELD_PREFIX: 'docTableHeader-', TABLE_FIELD_FILTER_FOR_BUTTON: 'filterForValue', TABLE_FIELD_FILTER_OUT_BUTTON: 'filterOutValue',