Skip to content

Commit

Permalink
Add Exists Filter functionality.
Browse files Browse the repository at this point in the history
Signed-off-by: Argus Li <[email protected]>
  • Loading branch information
ArgusLi committed Dec 11, 2024
1 parent 825d88a commit 444dbbe
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,44 @@ 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
it('PPL', () => {
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();
});
});
Expand All @@ -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();
});
});
Expand Down
45 changes: 41 additions & 4 deletions cypress/utils/dashboards/data_explorer/data_explorer_page.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
});
}

Expand Down Expand Up @@ -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) => {
Expand All @@ -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');
}
}
1 change: 1 addition & 0 deletions cypress/utils/dashboards/data_explorer/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 444dbbe

Please sign in to comment.