Skip to content

Commit

Permalink
feat(type): Cypport {moveToStart} and {moveToEnd} keyboard shortcuts (#…
Browse files Browse the repository at this point in the history
…679)

closes #653
  • Loading branch information
dmtrKovalenko authored Jun 15, 2024
1 parent f743225 commit f2458b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cypress/e2e/type.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ describe("cy.realType", () => {
});

it("supports cypress's keys shortcuts", () => {
cy.realType("Something{backspace}{backspace}");
cy.get("input[name=q]").should("have.value", "Somethi");
cy.realType("Something{backspace}{moveToStart}{rightarrow}{backspace}");
cy.get("input[name=q]").should("have.value", "omethin");
});

it("can select text", () => {
cy.realType("to replace");
cy.get("input[name=q]").realClick({ clickCount: 3 });
cy.realType("{backspace}something");
cy.get("input[name=q]").should("have.value", "something");
});

it("can clear text input", () => {
Expand Down
2 changes: 2 additions & 0 deletions src/keyCodeDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ export const keyCodeDefinitions = {
'{pagedown}': {'keyCode': 34, 'code': 'PageDown', 'key': 'PageDown'},
'PageDown': {'keyCode': 34, 'code': 'PageDown', 'key': 'PageDown'},
'{end}': {'keyCode': 35, 'code': 'End', 'key': 'End'},
'{moveToEnd}': {'keyCode': 35, 'code': 'End', 'key': 'End'},
'End': {'keyCode': 35, 'code': 'End', 'key': 'End'},
'Numpad1': {'keyCode': 35, 'shiftKeyCode': 97, 'key': 'End', 'code': 'Numpad1', 'shiftKey': '1', 'location': 3},
'{home}': {'keyCode': 36, 'code': 'Home', 'key': 'Home'},
'{moveToStart}': {'keyCode': 36, 'code': 'Home', 'key': 'Home'},
'Home': {'keyCode': 36, 'code': 'Home', 'key': 'Home'},
'Numpad7': {'keyCode': 36, 'shiftKeyCode': 103, 'key': 'Home', 'code': 'Numpad7', 'shiftKey': '7', 'location': 3},
'{leftarrow}': {'keyCode': 37, 'code': 'ArrowLeft', 'key': 'ArrowLeft'},
Expand Down

0 comments on commit f2458b7

Please sign in to comment.