fix: use data-cy selector for sidebar backdrop in e2e tests

The aria-hidden="true" selector matched 27 elements (icons, etc.)
causing cy.click() to fail. Add data-cy="sidebar-backdrop" to the
overlay div and target that specifically in tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
0xjjjjjj
2026-03-08 10:01:31 -07:00
parent fab19ed5aa
commit 7adadd5c88
2 changed files with 3 additions and 2 deletions

View File

@@ -102,7 +102,7 @@ describe("/dashboard - mobile sidebar", () => {
cy.get("[data-sidebar]").should("have.attr", "data-sidebar", "open"); cy.get("[data-sidebar]").should("have.attr", "data-sidebar", "open");
cy.get("aside").should("be.visible"); cy.get("aside").should("be.visible");
cy.get('[aria-hidden="true"]').should("exist"); cy.get('[data-cy="sidebar-backdrop"]').should("exist");
}); });
it("mobile: click backdrop closes sidebar", () => { it("mobile: click backdrop closes sidebar", () => {
@@ -114,7 +114,7 @@ describe("/dashboard - mobile sidebar", () => {
cy.get("[data-sidebar]").should("have.attr", "data-sidebar", "open"); cy.get("[data-sidebar]").should("have.attr", "data-sidebar", "open");
// Click the backdrop overlay // Click the backdrop overlay
cy.get('[aria-hidden="true"]').click({ force: true }); cy.get('[data-cy="sidebar-backdrop"]').click({ force: true });
cy.get("[data-sidebar]").should("have.attr", "data-sidebar", "closed"); cy.get("[data-sidebar]").should("have.attr", "data-sidebar", "closed");
cy.get("aside").should("not.be.visible"); cy.get("aside").should("not.be.visible");

View File

@@ -136,6 +136,7 @@ export function DashboardShell({ children }: { children: ReactNode }) {
className="fixed inset-0 z-40 bg-black/30 md:hidden" className="fixed inset-0 z-40 bg-black/30 md:hidden"
onClick={toggleSidebar} onClick={toggleSidebar}
aria-hidden="true" aria-hidden="true"
data-cy="sidebar-backdrop"
/> />
) : null} ) : null}