Skip to content

Commit 5c3103d

Browse files
test(ui5-calendar): refactor test for selection with space (#12895)
fixes: #12525
1 parent 9b3c752 commit 5c3103d

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

packages/main/cypress/specs/Calendar.cy.tsx

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,35 +1549,43 @@ describe("Calendar accessibility", () => {
15491549
});
15501550

15511551
describe("Day Picker Tests", () => {
1552-
it.skip("Select day with Space", () => {
1552+
it("Select day with Space", () => {
1553+
const today = new Date();
1554+
const tomorrow = Math.floor(Date.UTC(today.getFullYear(), today.getMonth(), today.getDate() + 1, 0, 0, 0, 0) / 1000);
1555+
15531556
cy.mount(<Calendar id="calendar1"></Calendar>);
15541557

15551558
cy.get<Calendar>("#calendar1")
15561559
.shadow()
15571560
.find("[ui5-daypicker]")
15581561
.shadow()
15591562
.find(".ui5-dp-item--now")
1560-
.as("today");
1563+
.realClick();
15611564

1562-
cy.get("@today")
1563-
.realClick()
1564-
.should("be.focused")
1565-
.realPress("ArrowRight")
1566-
.realPress("Space");
1565+
cy.get<Calendar>("#calendar1")
1566+
.shadow()
1567+
.find("[ui5-daypicker]")
1568+
.shadow()
1569+
.find("[tabindex='0']")
1570+
.should("have.focus");
15671571

1568-
cy.focused()
1569-
.invoke("attr", "data-sap-timestamp")
1570-
.then(timestampAttr => {
1571-
const timestamp = parseInt(timestampAttr!);
1572-
const selectedDate = new Date(timestamp * 1000).getDate();
1573-
const expectedDate = new Date(Date.now() + 24 * 3600 * 1000).getDate();
1574-
expect(selectedDate).to.eq(expectedDate);
1575-
});
1572+
cy.get<Calendar>("#calendar1")
1573+
.realPress("ArrowRight");
1574+
1575+
cy.get<Calendar>("#calendar1")
1576+
.shadow()
1577+
.find("[ui5-daypicker]")
1578+
.shadow()
1579+
.find(`[data-sap-timestamp='${tomorrow}']`)
1580+
.should("have.focus");
1581+
1582+
cy.get<Calendar>("#calendar1")
1583+
.realPress("Space");
15761584

15771585
cy.get<Calendar>("#calendar1")
15781586
.should(($calendar) => {
15791587
const selectedDates = $calendar.prop("selectedDates");
1580-
expect(selectedDates).to.have.length.greaterThan(0);
1588+
expect(selectedDates).to.include(tomorrow);
15811589
});
15821590
});
15831591

0 commit comments

Comments
 (0)