Skip to content

Commit 1201138

Browse files
authored
test(input-date-picker): add test for no longer closing date-picker when using arrow and page keys. (#9097)
**Related Issue:** #9082 ## Summary No longer closes `date-picker` in `input-date-picker` when user interacts with arrowKeys (arrowDown/arrowUp) or pageKeys (pageUp/pageDown).
1 parent 1602070 commit 1201138

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

packages/calcite-components/src/components/input-date-picker/input-date-picker.e2e.ts

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,4 +1145,117 @@ describe("calcite-input-date-picker", () => {
11451145
expect(changeEvent).toHaveReceivedEventTimes(2);
11461146
});
11471147
});
1148+
1149+
describe("ArrowKeys and PageKeys", () => {
1150+
it("should be able to navigate between months using arrow keys and page keys", async () => {
1151+
const page = await newE2EPage();
1152+
await page.setContent(html`<calcite-input-date-picker value="2024-01-01"></calcite-input-date-picker>`);
1153+
await page.waitForChanges();
1154+
await skipAnimations(page);
1155+
1156+
const input = await page.find("calcite-input-date-picker >>> calcite-input-text");
1157+
const calendar = await page.find(`calcite-input-date-picker >>> .${CSS.calendarWrapper}`);
1158+
1159+
expect(await calendar.isVisible()).toBe(false);
1160+
await input.click();
1161+
expect(await calendar.isVisible()).toBe(true);
1162+
1163+
await page.keyboard.press("Tab");
1164+
await page.waitForChanges();
1165+
await page.keyboard.press("Tab");
1166+
await page.waitForChanges();
1167+
await page.keyboard.press("Tab");
1168+
await page.waitForChanges();
1169+
await page.keyboard.press("Tab");
1170+
await page.waitForChanges();
1171+
1172+
await page.keyboard.press("ArrowUp");
1173+
await page.waitForChanges();
1174+
expect(await calendar.isVisible()).toBe(true);
1175+
1176+
await page.keyboard.press("PageUp");
1177+
await page.waitForChanges();
1178+
expect(await calendar.isVisible()).toBe(true);
1179+
1180+
await page.keyboard.press("ArrowDown");
1181+
await page.waitForChanges();
1182+
expect(await calendar.isVisible()).toBe(true);
1183+
1184+
await page.keyboard.press("PageDown");
1185+
await page.waitForChanges();
1186+
expect(await calendar.isVisible()).toBe(true);
1187+
1188+
await page.keyboard.press("PageDown");
1189+
await page.waitForChanges();
1190+
expect(await calendar.isVisible()).toBe(true);
1191+
1192+
await page.keyboard.press("Enter");
1193+
await page.waitForChanges();
1194+
expect(await calendar.isVisible()).toBe(false);
1195+
expect(await getActiveMonth(page)).toBe("February");
1196+
});
1197+
1198+
it("should be able to navigate between months using arrow keys and page keys in range", async () => {
1199+
const page = await newE2EPage();
1200+
await page.setContent(html`<calcite-input-date-picker range></calcite-input-date-picker>`);
1201+
await page.waitForChanges();
1202+
await skipAnimations(page);
1203+
1204+
await page.evaluate(() => {
1205+
const inputDatePicker = document.querySelector("calcite-input-date-picker");
1206+
inputDatePicker.value = ["2024-01-01", "2024-02-10"];
1207+
});
1208+
1209+
const inputDatePicker = await page.find("calcite-input-date-picker");
1210+
const [inputStart, inputEnd] = await page.findAll("calcite-input-date-picker >>> calcite-input-text");
1211+
const calendar = await page.find(`calcite-input-date-picker >>> .${CSS.calendarWrapper}`);
1212+
expect(await calendar.isVisible()).toBe(false);
1213+
1214+
await inputStart.click();
1215+
expect(await calendar.isVisible()).toBe(true);
1216+
1217+
await page.keyboard.press("Tab");
1218+
await page.waitForChanges();
1219+
await page.keyboard.press("Tab");
1220+
await page.waitForChanges();
1221+
await page.keyboard.press("Tab");
1222+
await page.waitForChanges();
1223+
await page.keyboard.press("Tab");
1224+
await page.waitForChanges();
1225+
1226+
await page.keyboard.press("ArrowUp");
1227+
await page.waitForChanges();
1228+
await page.keyboard.press("PageUp");
1229+
await page.waitForChanges();
1230+
await page.keyboard.press("Enter");
1231+
await page.waitForChanges();
1232+
1233+
expect(await calendar.isVisible()).toBe(false);
1234+
expect(await inputDatePicker.getProperty("value")).toEqual(["2023-11-25", "2024-02-10"]);
1235+
1236+
await inputEnd.click();
1237+
expect(await calendar.isVisible()).toBe(true);
1238+
1239+
await page.keyboard.press("Tab");
1240+
await page.waitForChanges();
1241+
await page.keyboard.press("Tab");
1242+
await page.waitForChanges();
1243+
await page.keyboard.press("Tab");
1244+
await page.waitForChanges();
1245+
await page.keyboard.press("Tab");
1246+
await page.waitForChanges();
1247+
await page.keyboard.press("ArrowDown");
1248+
await page.waitForChanges();
1249+
expect(await calendar.isVisible()).toBe(true);
1250+
1251+
await page.keyboard.press("PageDown");
1252+
await page.waitForChanges();
1253+
expect(await calendar.isVisible()).toBe(true);
1254+
1255+
await page.keyboard.press("Enter");
1256+
await page.waitForChanges();
1257+
expect(await calendar.isVisible()).toBe(false);
1258+
expect(await inputDatePicker.getProperty("value")).not.toEqual(["2024-01-01", "2024-03-17"]);
1259+
});
1260+
});
11481261
});

0 commit comments

Comments
 (0)