Skip to content

Commit

Permalink
fix: allow filtering using 'Not blank' operator (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
wandering-tales authored Dec 22, 2024
1 parent 4751fc6 commit 4a04d15
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
37 changes: 37 additions & 0 deletions cypress/e2e/ag-grid-data.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,43 @@ describe("ag-grid get data scenarios", () => {

});

it("able to filter by 'Not blank'", () => {
const expectedTableData = [
{ Year: "2020", Make: "Toyota", Model: "Celica", Condition: "fair", Price: "35000" },
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
{ Year: "2020", Make: "Porsche", Model: "Boxter", Condition: "good", Price: "72000" },
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
{ Year: "2020", Make: "Mercedes", Model: "GLC300", Condition: "good", Price: "53000" },
{ Year: "2020", Make: "Honda", Model: "Civic", Condition: "poor", Price: "22000" },
{ Year: "2020", Make: "Honda", Model: "Accord", Condition: "poor", Price: "32000" },
{ Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
{ Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "good", Price: "22000" },
{ Year: "2020", Make: "Toyota", Model: "Celica", Condition: "poor", Price: "5000" },
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "good", Price: "25000" },
{ Year: "2020", Make: "Porsche", Model: "Boxter", Condition: "good", Price: "99000" },
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
{ Year: "2020", Make: "Mercedes", Model: "GLC300", Condition: "excellent", Price: "35000" },
{ Year: "2011", Make: "Honda", Model: "Civic", Condition: "good", Price: "9000" },
{ Year: "2020", Make: "Honda", Model: "Accord", Condition: "good", Price: "34000" },
{ Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
{ Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "fair", Price: "3000" },
{ Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" }
]

cy.get(agGridSelector).agGridColumnFilterTextMenu({
searchCriteria: {
columnName: "Price",
operator: filterOperator.notBlank,
},
hasApplyButton: true,
});
cy.get(agGridSelector)
.getAgGridData()
.then((actualTableData) => {
cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
});
});

it('able to filter by agTextColumnFilter with join operator', () => {
const expectedTableData = [
{ Year: "2020", Make: "Toyota", Model: "Celica", Condition: "fair", Price: "35000" },
Expand Down
15 changes: 10 additions & 5 deletions src/agGrid/agGridInteractions.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,16 @@ function filterBySearchTerm(agGridElement, options) {
.click();
}
// Input filter term and allow grid a moment to render the results
cy.get(agGridElement)
.find(".ag-popup-child")
.find("input")
.filter(":visible")
.as("filterInput");
if (
operator !== filterOperator.blank &&
operator !== filterOperator.notBlank
) {
cy.get(agGridElement)
.find(".ag-popup-child")
.find("input")
.filter(":visible")
.as("filterInput");
}

// If it's a multi filter, de-select the 'select-all' checkbox
if (isMultiFilter) {
Expand Down
2 changes: 1 addition & 1 deletion src/agGrid/filterOperator.enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export const filterOperator = {
greaterThanOrEquals: "Greater than or equal to",
inRange: "Between",
blank: "Blank",
notBlank: "Not Blank"
notBlank: "Not blank"
}

0 comments on commit 4a04d15

Please sign in to comment.