From aa53ec24b886844e185443a719d0d970e6f1b785 Mon Sep 17 00:00:00 2001 From: Lucia Sarni Date: Thu, 8 Oct 2020 22:52:56 +0200 Subject: [PATCH] fix(filter): avoid filtering by the strings "true/false" when enabled (#6477) --- src/core/components/operations.jsx | 2 +- src/core/containers/filter.jsx | 2 +- test/e2e-cypress/tests/bugs/6276.js | 43 +++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 test/e2e-cypress/tests/bugs/6276.js diff --git a/src/core/components/operations.jsx b/src/core/components/operations.jsx index 505217ff..b50e2afb 100644 --- a/src/core/components/operations.jsx +++ b/src/core/components/operations.jsx @@ -48,7 +48,7 @@ export default class Operations extends React.Component { let filter = layoutSelectors.currentFilter() if (filter) { - if (filter !== true) { + if (filter !== true && filter !== "true" && filter !== "false") { taggedOps = fn.opsFilter(taggedOps, filter) } } diff --git a/src/core/containers/filter.jsx b/src/core/containers/filter.jsx index 24a668ca..872297f0 100644 --- a/src/core/containers/filter.jsx +++ b/src/core/containers/filter.jsx @@ -29,7 +29,7 @@ export default class FilterContainer extends React.Component { return (
- {filter === null || filter === false ? null : + {filter === null || filter === false || filter === "false" ? null :
{ + describe("With filter=true", () => { + it("should display the filter bar", () => { + cy.visit("/?url=/documents/petstore.swagger.yaml&filter=true") + .get(".operation-filter-input") + .should("exist") + .should("be.empty") + .get(".opblock-tag[data-tag='pet']") + .should("exist") + .get(".opblock-tag[data-tag='store']") + .should("exist") + .get(".opblock-tag[data-tag='user']") + .should("exist") + }) + }) + describe("With filter=false", () => { + it("should not display the filter bar", () => { + cy.visit("/?url=/documents/petstore.swagger.yaml&filter=false") + .get(".operation-filter-input") + .should("not.exist") + .get(".opblock-tag[data-tag='pet']") + .should("exist") + .get(".opblock-tag[data-tag='store']") + .should("exist") + .get(".opblock-tag[data-tag='user']") + .should("exist") + }) + }) + describe("With filter=pet", () => { + it("should display the filter bar and only show the operations tagged with pet", () => { + cy.visit("/?url=/documents/petstore.swagger.yaml&filter=pet") + .get(".operation-filter-input") + .should("exist") + .should("have.value", "pet") + .get(".opblock-tag[data-tag='pet']") + .should("exist") + .get(".opblock-tag[data-tag='store']") + .should("not.exist") + .get(".opblock-tag[data-tag='user']") + .should("not.exist") + }) + }) +})