-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: extend Cypress.Keyboard.Keys and cy.press to support (almost) all keyboard keys #31496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
efabb5a
feat: extend Cypress.Keyboard.Keys and cy.press to support all keyboa…
jennifer-shehane 88b8f76
Update cli/types/cypress.d.ts
jennifer-shehane c4af6b6
reference urls for codepoints
cacieprins 70ecad0
type defs for expanded keys; tests
cacieprins 4a84ff3
Merge branch 'develop' into feat-all-keys
cacieprins 2485043
changelog
cacieprins 935d766
rm modifier keys temporarily - see WIP @ feat/key-press-modifier-keys
cacieprins 6df79a8
Add pr link to changelog
cacieprins bb031ba
reduce repetition with key codes; remove unsupported capslock keycode
cacieprins e9abde8
only "key" special function keys in Cypress.Keyboard.Keys - otherwise…
cacieprins bde74b4
do not refocus on f6 - f6 behavior keyup is indeterminate, so do not …
cacieprins eddde62
Merge branch 'develop' into feat-all-keys
cacieprins 6109992
clean up keyboard key types, clean up duplicate def from merge
cacieprins 385ecc9
various cleanup - wip - need multi-codepoint fix
cacieprins 54f4f26
support multi-codepoint characters
cacieprins 16a44f2
Merge branch 'develop' into feat-all-keys
cacieprins bad947c
properly dispatch each part of a multipart utf-8 character
cacieprins 9656b4c
fix import
cacieprins f5fb925
fix dtslint
cacieprins 8bf80af
tscheck
cacieprins 32cc334
fix spacing
cacieprins df6ef92
Merge branch 'develop' into feat-all-keys
cacieprins aa9a386
Apply suggestions from code review
cacieprins 88d776c
Merge branch 'develop' into feat-all-keys
cacieprins 0944c46
changelog
cacieprins 485e7d6
changelog
cacieprins af4c50c
ensure input actions are released in bidi; add test for keypress and …
cacieprins 166e305
fix keypress & input events in chrome
cacieprins 707adf0
consistent debug
cacieprins 869912a
rm debug logging from input fixture
cacieprins f63b212
Merge branch 'develop' into feat-all-keys
cacieprins cb9d042
some typos, changelog version
cacieprins d43600b
fix toSupportedKey guard fn to properly reject non-strings
cacieprins d9085ff
add Space as named key, remove warnings re legacy firefox
cacieprins 47ed81f
fix space
cacieprins 311dc66
support single-digit number keys
cacieprins 03a840e
remove support for F-keys
cacieprins 3878191
add test cmd to types pkg
cacieprins 58d7804
rm failing vitest project config
cacieprins e413eda
fix changelog
cacieprins 764a438
clean up types a bit for single digit numbers
cacieprins fd8fd80
more updates
cacieprins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,58 @@ | ||
import type { KeyPressSupportedKeys } from '@packages/types' | ||
|
||
describe('src/cy/commands/actions/press', () => { | ||
it('dispatches the tab keypress to the AUT', () => { | ||
// Non-BiDi firefox is not supported | ||
if (Cypress.browser.family === 'firefox' && Cypress.browserMajorVersion() < 135) { | ||
return | ||
} | ||
// Non-BiDi firefox is not supported | ||
if (Cypress.browser.family === 'firefox' && Cypress.browserMajorVersion() < 135) { | ||
|
||
return | ||
} | ||
|
||
// TODO: Webkit is not supported. https://github.com/cypress-io/cypress/issues/31054 | ||
if (Cypress.isBrowser('webkit')) { | ||
return | ||
} | ||
// TODO: Webkit is not supported. https://github.com/cypress-io/cypress/issues/31054 | ||
if (Cypress.isBrowser('webkit')) { | ||
return | ||
} | ||
|
||
beforeEach(() => { | ||
cy.visit('/fixtures/input_events.html') | ||
}) | ||
|
||
cy.press(Cypress.Keyboard.Keys.TAB) | ||
const testKeyPress = (key: KeyPressSupportedKeys) => { | ||
it(`dispatches ${key} keypress to the AUT`, () => { | ||
cy.press(key) | ||
cy.get('#keydown').should('have.value', key) | ||
cy.get('#keyup').should('have.value', key) | ||
}) | ||
} | ||
|
||
cy.get('#keydown').should('have.value', 'Tab') | ||
// Numbers | ||
;['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'].forEach(testKeyPress) | ||
|
||
cy.get('#keyup').should('have.value', 'Tab') | ||
}) | ||
// Letters | ||
;['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', | ||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', | ||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', | ||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'].forEach(testKeyPress) | ||
|
||
// Special characters | ||
;['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', | ||
'+', '[', ']', '{', '}', '\\', '|', ';', ':', '\'', '"', ',', '.', | ||
'<', '>', '/', '?', '`', '~', ' '].forEach(testKeyPress) | ||
|
||
// Control keys | ||
;['Enter', 'Tab', 'Backspace', 'Delete', 'Insert', 'Home', 'End', | ||
'PageUp', 'PageDown', 'Escape', 'CapsLock', 'Shift', 'Control', | ||
'Alt', 'Meta'].forEach(testKeyPress) | ||
|
||
cacieprins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Arrow keys | ||
;['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].forEach(testKeyPress) | ||
|
||
// Function keys | ||
;['F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12'].forEach(testKeyPress) | ||
|
||
// Media keys | ||
;['AudioVolumeMute', 'AudioVolumeDown', 'AudioVolumeUp', | ||
'MediaTrackNext', 'MediaTrackPrevious', 'MediaStop', | ||
'MediaPlayPause'].forEach(testKeyPress) | ||
|
||
// Other keys | ||
;['NumLock', 'ScrollLock', 'Pause'].forEach(testKeyPress) | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.