Skip to content

Commit

Permalink
feat(canary-react): add the ability to backspace through a date input…
Browse files Browse the repository at this point in the history
… to delete the date

Add the ability to backspace through a date input to delete the date, using moveToPreviousInput
after the last character has been deleted

. #2244
  • Loading branch information
GCHQ-Developer-530 committed Feb 21, 2025
1 parent 4c890b0 commit d362b32
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,24 @@ describe("IcDateInput end-to-end, visual regression and a11y tests", () => {
cy.findShadowEl(DATE_INPUT, YEAR_INPUT_ARIA_LABEL).should(HAVE_VALUE, "");
});

it("should test deleting the date using backspace", () => {
mount(<IcDateInput label="Test Label" />);

cy.checkHydrated(DATE_INPUT);

cy.findShadowEl(DATE_INPUT, DAY_INPUT_ARIA_LABEL).type("30");
cy.findShadowEl(DATE_INPUT, MONTH_INPUT_ARIA_LABEL).type("04");
cy.findShadowEl(DATE_INPUT, YEAR_INPUT_ARIA_LABEL).type("2000");

cy.findShadowEl(DATE_INPUT, YEAR_INPUT_ARIA_LABEL).type("{Backspace}{Backspace}{Backspace}{Backspace}");
cy.findShadowEl(DATE_INPUT, MONTH_INPUT_ARIA_LABEL).type("{Backspace}{Backspace}");
cy.findShadowEl(DATE_INPUT, DAY_INPUT_ARIA_LABEL).type("{Backspace}{Backspace}");

cy.findShadowEl(DATE_INPUT, DAY_INPUT_ARIA_LABEL).should(HAVE_VALUE, "");
cy.findShadowEl(DATE_INPUT, MONTH_INPUT_ARIA_LABEL).should(HAVE_VALUE, "");
cy.findShadowEl(DATE_INPUT, YEAR_INPUT_ARIA_LABEL).should(HAVE_VALUE, "");
});

it("should enter complete date and check for accessibility", () => {
mount(
<div style={{ padding: "10px" }}>
Expand Down

0 comments on commit d362b32

Please sign in to comment.