import { Then, When } from "@badeball/cypress-cucumber-preprocessor"; Then("the sidebar's main nav should not mention {string}", (text: string) => { cy.get(".app-sidebar__nav a").should("not.contain", text); }); Then("the sidebar should be collapsed", () => { cy.get(".app-sidebar").should("have.class", "collapsed"); }); Then("the sidebar should not be collapsed", () => { cy.get(".app-sidebar").should("not.have.class", "collapsed"); }); When("I toggle the sidebar collapse", () => { cy.get(".app-sidebar__collapse-toggle").click(); }); Then("the nav link {string} should be visible", (text: string) => { cy.contains("nav a", text).should("be.visible"); }); // The label text stays in the DOM (still there for the `title` // tooltip/accessibility) — it's hidden via CSS, not removed, hence // `.should("exist").and("not.be.visible")` rather than `.should("not.exist")`. Then("the nav link {string}'s label should be hidden", (text: string) => { cy.contains("span.label", text).should("exist").and("not.be.visible"); }); Then("the nav link titled {string} should be visible", (title: string) => { cy.get(`nav a[title="${title}"]`).should("be.visible"); }); When("I reload the page", () => { cy.reload(); });