diff --git a/packages/main/cypress/specs/Calendar.cy.tsx b/packages/main/cypress/specs/Calendar.cy.tsx index baf3992bfc8c..2b57bb8aca1b 100644 --- a/packages/main/cypress/specs/Calendar.cy.tsx +++ b/packages/main/cypress/specs/Calendar.cy.tsx @@ -1549,7 +1549,10 @@ describe("Calendar accessibility", () => { }); describe("Day Picker Tests", () => { - it.skip("Select day with Space", () => { + it("Select day with Space", () => { + const today = new Date(); + const tomorrow = Math.floor(Date.UTC(today.getFullYear(), today.getMonth(), today.getDate() + 1, 0, 0, 0, 0) / 1000); + cy.mount(); cy.get("#calendar1") @@ -1557,27 +1560,32 @@ describe("Day Picker Tests", () => { .find("[ui5-daypicker]") .shadow() .find(".ui5-dp-item--now") - .as("today"); + .realClick(); - cy.get("@today") - .realClick() - .should("be.focused") - .realPress("ArrowRight") - .realPress("Space"); + cy.get("#calendar1") + .shadow() + .find("[ui5-daypicker]") + .shadow() + .find("[tabindex='0']") + .should("have.focus"); - cy.focused() - .invoke("attr", "data-sap-timestamp") - .then(timestampAttr => { - const timestamp = parseInt(timestampAttr!); - const selectedDate = new Date(timestamp * 1000).getDate(); - const expectedDate = new Date(Date.now() + 24 * 3600 * 1000).getDate(); - expect(selectedDate).to.eq(expectedDate); - }); + cy.get("#calendar1") + .realPress("ArrowRight"); + + cy.get("#calendar1") + .shadow() + .find("[ui5-daypicker]") + .shadow() + .find(`[data-sap-timestamp='${tomorrow}']`) + .should("have.focus"); + + cy.get("#calendar1") + .realPress("Space"); cy.get("#calendar1") .should(($calendar) => { const selectedDates = $calendar.prop("selectedDates"); - expect(selectedDates).to.have.length.greaterThan(0); + expect(selectedDates).to.include(tomorrow); }); });