Skip to content
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

feat: Add shiftKey modifier to keyboard events #514

Merged
merged 6 commits into from
Jul 17, 2023

Conversation

Minilfat
Copy link
Contributor

@Minilfat Minilfat commented Jul 9, 2023

Motivation

I faced issue that it wasn't possible to do smth like:

cy.realPress('ShiftLeft', {pressDelay: 1000})
cy.get('#some-id').realClick() // <-- the shift key already released 
// then unpress it somehow

Cypress synthetic events come with shiftKey: boolean property in some events where it makes sense.
I think it's useful to have the same option for real events too.

Notes

I decided to write test cases in separate file for 2 main reasons:

  • there are few more modifiers that can be added in future and it makes sense to test them in the same modifiers test suite imho
  • I couldn't find any events that would react differently when shift key was pressed when event occurred, so had to write simple cases myself

@what-the-diff
Copy link

what-the-diff bot commented Jul 9, 2023

PR Summary

  • Introduced Key Modifier Bit Mappings
    A new file named keyToModifierBitMap.ts was introduced. This file makes sure to map specific keys to its respective function.

  • Enhancements in 'mouseDown.ts', 'mouseMove.ts', 'realClick.ts', 'realHover.ts', & 'realPress.ts'
    There were modifications made in several files related to actions like clicking, moving the mouse, and pressing keys.

    • Import statement for the newly created keyToModifierBitMap was added in each file.
    • A new optional property named shiftKey was introduced in the interfaces related to the files.
    • An extra property named modifiers has been included in the log object for Cypress, a testing tool, helping to track whether the Shift key was used in these actions.
  • Optimization in 'realPress.ts
    The keyToModifierBitMap object was moved from the realPress.ts file to its own file keyToModifierBitMap.ts, enhancing code structure and organization.

@Minilfat Minilfat changed the title [Feat] Add shiftKey modifier to some events feat: Add shiftKey modifier to some events Jul 9, 2023
Copy link
Owner

@dmtrKovalenko dmtrKovalenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this. Couple comments

  • I don’t see that you modified real mouse up
  • please revert all the unrelated style changes

@Minilfat
Copy link
Contributor Author

@dmtrKovalenko thanks for review! I addressed all comments you left, let me know if I need to change something else

@dmtrKovalenko dmtrKovalenko changed the title feat: Add shiftKey modifier to some events feat: Add shiftKey modifier to keyboard events Jul 17, 2023
@dmtrKovalenko dmtrKovalenko merged commit 769273d into dmtrKovalenko:develop Jul 17, 2023
dmtrKovalenko added a commit that referenced this pull request Jul 17, 2023
* add shiftKey option to some events

* add test cases

* revert unrelated formatting changes

* add shiftKey option for mouseUp event

* one more formatting revert

---------

Co-authored-by: Dmitriy <dmtr.kovalenko@outlook.com>
@dmtrKovalenko
Copy link
Owner

🎉 This PR is included in version 1.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

dmtrKovalenko added a commit that referenced this pull request Sep 10, 2023
* chore(deps-dev): bump cypress from 12.1.0 to 12.13.0 (#483)

Bumps [cypress](https://github.com/cypress-io/cypress) from 12.1.0 to 12.13.0.
- [Release notes](https://github.com/cypress-io/cypress/releases)
- [Changelog](https://github.com/cypress-io/cypress/blob/develop/CHANGELOG.md)
- [Commits](cypress-io/cypress@v12.1.0...v12.13.0)

---
updated-dependencies:
- dependency-name: cypress
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump typedoc from 0.23.22 to 0.24.8 (#489)

* chore(deps-dev): bump eslint from 8.29.0 to 8.42.0 (#488)

* chore(deps-dev): bump @typescript-eslint/parser from 5.46.1 to 5.59.8 (#485)

* chore(deps-dev): bump typescript from 4.9.4 to 5.1.3 (#493)

* chore(deps-dev): bump typedoc-plugin-markdown from 3.14.0 to 3.15.3 (#492)

* chore(deps-dev): bump @typescript-eslint/parser from 5.59.8 to 5.59.9 (#491)

* chore(deps-dev): bump cypress from 12.13.0 to 12.14.0 (#494)

* chore(ci): Update browsers (#519)

* Update browsers

* Config validate

* Skip install

* Use js config

* Add checkout

* Make cypress config cjs

* Fix config

* Fix executor

* Cache binary

* Cache binary

* Cache binary

* Copy binary

* Fix executor

* Fix executor

* Fix executor

* cp instead of mv

* cp instead of mv

* --chrome browser

* install browsers inside job

* install browsers inside job

* feat: Add shiftKey modifier to keyboard events  (#514)

* add shiftKey option to some events

* add test cases

* revert unrelated formatting changes

* add shiftKey option for mouseUp event

* one more formatting revert

---------

Co-authored-by: Dmitriy <dmtr.kovalenko@outlook.com>

* feat: add x & y options for mouseDown and moustUp events (#486)

* Update mouseDown.ts

Add X & Y coordinates to mouseDown

* Update src/commands/mouseDown.ts

* Update mouseUp as well

---------

Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>

* chore(style): Format whole codebase with prettier and enforce it on CI (#520)

* v1.8.2

* v1.9.1

* fix: Remove prettier dependency (#532)

* fix(realType): add an escape sequence for a left brace (#547)

* fix: add an escape sequence for a left brace

* chore: add an e2e test

* chore(deps-dev): bump cypress from 12.14.0 to 13.1.0

Bumps [cypress](https://github.com/cypress-io/cypress) from 12.14.0 to 13.1.0.
- [Release notes](https://github.com/cypress-io/cypress/releases)
- [Changelog](https://github.com/cypress-io/cypress/blob/develop/CHANGELOG.md)
- [Commits](cypress-io/cypress@v12.14.0...v13.1.0)

---
updated-dependencies:
- dependency-name: cypress
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump circleci orb version

* fix typo

* Skip failing test

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ilfat Mindubaev <yagarantuz@gmail.com>
Co-authored-by: Adam Robinson <30032798+adamistheanswer@users.noreply.github.com>
Co-authored-by: Josh Wooding <12938082+joshwooding@users.noreply.github.com>
Co-authored-by: Lev Chelyadinov <leva181777@gmail.com>
dmtrKovalenko added a commit that referenced this pull request Sep 10, 2023
* chore(deps-dev): bump cypress from 12.1.0 to 12.13.0 (#483)

Bumps [cypress](https://github.com/cypress-io/cypress) from 12.1.0 to 12.13.0.
- [Release notes](https://github.com/cypress-io/cypress/releases)
- [Changelog](https://github.com/cypress-io/cypress/blob/develop/CHANGELOG.md)
- [Commits](cypress-io/cypress@v12.1.0...v12.13.0)

---
updated-dependencies:
- dependency-name: cypress
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump typedoc from 0.23.22 to 0.24.8 (#489)

* chore(deps-dev): bump eslint from 8.29.0 to 8.42.0 (#488)

* chore(deps-dev): bump @typescript-eslint/parser from 5.46.1 to 5.59.8 (#485)

* chore(deps-dev): bump typescript from 4.9.4 to 5.1.3 (#493)

* chore(deps-dev): bump typedoc-plugin-markdown from 3.14.0 to 3.15.3 (#492)

* chore(deps-dev): bump @typescript-eslint/parser from 5.59.8 to 5.59.9 (#491)

* chore(deps-dev): bump cypress from 12.13.0 to 12.14.0 (#494)

* chore(ci): Update browsers (#519)

* Update browsers

* Config validate

* Skip install

* Use js config

* Add checkout

* Make cypress config cjs

* Fix config

* Fix executor

* Cache binary

* Cache binary

* Cache binary

* Copy binary

* Fix executor

* Fix executor

* Fix executor

* cp instead of mv

* cp instead of mv

* --chrome browser

* install browsers inside job

* install browsers inside job

* feat: Add shiftKey modifier to keyboard events  (#514)

* add shiftKey option to some events

* add test cases

* revert unrelated formatting changes

* add shiftKey option for mouseUp event

* one more formatting revert

---------

Co-authored-by: Dmitriy <dmtr.kovalenko@outlook.com>

* feat: add x & y options for mouseDown and moustUp events (#486)

* Update mouseDown.ts

Add X & Y coordinates to mouseDown

* Update src/commands/mouseDown.ts

* Update mouseUp as well

---------

Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>

* chore(style): Format whole codebase with prettier and enforce it on CI (#520)

* v1.8.2

* v1.9.1

* fix: Remove prettier dependency (#532)

* fix(realType): add an escape sequence for a left brace (#547)

* fix: add an escape sequence for a left brace

* chore: add an e2e test

* chore(deps-dev): bump cypress from 12.14.0 to 13.1.0

Bumps [cypress](https://github.com/cypress-io/cypress) from 12.14.0 to 13.1.0.
- [Release notes](https://github.com/cypress-io/cypress/releases)
- [Changelog](https://github.com/cypress-io/cypress/blob/develop/CHANGELOG.md)
- [Commits](cypress-io/cypress@v12.14.0...v13.1.0)

---
updated-dependencies:
- dependency-name: cypress
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump circleci orb version

* fix typo

* Skip failing test

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ilfat Mindubaev <yagarantuz@gmail.com>
Co-authored-by: Adam Robinson <30032798+adamistheanswer@users.noreply.github.com>
Co-authored-by: Josh Wooding <12938082+joshwooding@users.noreply.github.com>
Co-authored-by: Lev Chelyadinov <leva181777@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants