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 keystrokeDelay #15683

Merged
merged 19 commits into from
Jun 16, 2021
Merged

Conversation

herecydev
Copy link
Contributor

@herecydev herecydev commented Mar 28, 2021

User facing changelog

PR Tasks

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 28, 2021

Thanks for taking the time to open a PR!

@jennifer-shehane jennifer-shehane marked this pull request as ready for review April 22, 2021 13:14
@jennifer-shehane jennifer-shehane requested a review from a team as a code owner April 22, 2021 13:14
@jennifer-shehane jennifer-shehane requested review from kuceb and removed request for a team April 22, 2021 13:14
Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

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

@herecydev Thanks! Can you add tests around this new behavior?

We need tests that:

  • the default keystroke still works
  • setting a new config value increases the keystroke delay
  • setting a global config value overwrites a delay value set in the type command
  • setting an invalid value to keystrokeDelay (like 'foo') will error
  • setting keystroke to false or 0 disables keystroke delay
  • the types are correctly tested
  • etc

There is a Contributing Guide that covers how to contribute and get Cypress running locally in generally here: https://github.com/cypress-io/cypress/blob/develop/.github/CONTRIBUTING.md

To run the tests:

  • within cypress root, run yarn
  • run yarn workspace @packages/driver cypress:open
  • click on the test you're writing to run it within Cypress

Instructions for running the driver tests can always be found here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/README.md

@herecydev
Copy link
Contributor Author

@jennifer-shehane Yep, I'll find some time to add those, I think I kept it as draft to garner some feedback initially. If you're happy in principal that the implementation is reasonable, I'll add some tests to prove it.

@herecydev
Copy link
Contributor Author

@jennifer-shehane Some initial tests added which I believe covers this:

  • the default keystroke still works
  • setting a new config value increases the keystroke delay
  • setting a global config value overwrites a delay value set in the type command
  • setting keystroke to false or 0 disables keystroke delay

Can you link some existing tests that cover the following, would be really helpful to follow along how these are already covered;

  • setting an invalid value to keystrokeDelay (like 'foo') will error
  • the types are correctly tested

Also, I'm getting some issues with the CI failing around missing percy tokens, which seems totally unrelated to the changes. How do I approach CI failures, given I can't rerun them?

@jennifer-shehane
Copy link
Member

Yah, I'm looking into the percy token. That shouldn't error like that, so ignore that for now.

Testing the error on an option that's of the wrong type would be similar to this structure: https://github.com/cypress-io/cypress/blob/develop/packages/driver/cypress/integration/commands/actions/type_spec.js#L2535:L2535

Testing the types would be something like this: https://github.com/cypress-io/cypress/blob/develop/cli/types/tests/actions.ts#L85:L85

@jennifer-shehane
Copy link
Member

Hey @herecydev, will you have time to add the extra tests?

@herecydev
Copy link
Contributor Author

Hey @herecydev, will you have time to add the extra tests?

I will and I haven't forgotten. Just on holiday at the moment, but will endeavour to finish those up next week. Sorry for the delay.

@herecydev
Copy link
Contributor Author

@jennifer-shehane I think all the correct tests have now been written. I'm still a little hesistant about the extent of testing invalid types. You can see my efforts to validate an invalid delay, but I can't see other configuration going through similar testing. Take waitForAnimations as an example, should that also not throw a reasonable error if misconfigured?

In addition, after rereading this test criteria "setting a global config value overwrites a delay value set in the type command". I disagree with that behavior. I think it's meant to be flipped, and have written a test on that assumption.

@jennifer-shehane jennifer-shehane self-requested a review June 1, 2021 17:55
@chrisbreiding
Copy link
Contributor

Hey @herecydev, appreciate the work on this.

The team discussed this and decided we'd like this to work through a method like Cypress.Keyboard.defaults(), similar to how Cypress.Screenshot.defaults() works, instead of being a cypress.json setting. We also want the per-test configuration for this setting to work, but we don't currently have the infrastructure in place for it to work with the Cypress.Keyboard.defaults() method. We're planning to add that in the near future and then we can revisit this.

There's nothing further you need to do. Just wanted to let you know, since this won't be getting merged immediately. We'll take it from here and get this in as soon as we can.

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

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

Needs some minor changes. I think this also needs to be included in the test config types: https://github.com/cypress-io/cypress/blob/develop/cli/types/cypress.d.ts#L2794:L2794

I think we should discuss the final implementation in our team touchpoint to get some feedback from the whole team on the test config + Keyboard.defaults usage.

I know test config is not a 1to1 reflection of only configuration values, but currently the only exception is 'browser'. That's probably the only thing to go over.

* @see https://on.cypress.io/keyboard-api
*/
Keyboard: {
defaults(options: Partial<ScreenshotDefaultsOptions>): void
Copy link
Member

Choose a reason for hiding this comment

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

Think you mistyped this

Suggested change
defaults(options: Partial<ScreenshotDefaultsOptions>): void
defaults(options: Partial<KeyboardDefaultsOptions>): void

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

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

I manually tested this and looked over the code. Looks good. Everyone seems satisfied with the API for now. Thanks again @herecydev!

@jennifer-shehane
Copy link
Member

These tests passed - looks like the Cypress checks are stuck running for some reason and are not up to date with latest reruns. Going to merge in.

@jennifer-shehane jennifer-shehane merged commit ce5abe4 into cypress-io:develop Jun 16, 2021
Calyhre pushed a commit to Calyhre/cypress that referenced this pull request Jun 22, 2021
* Add keystrokeDelay

* Config tests

* Add proper comments

* Add some tests for configuring timeout

* Add tests for false values

* Few additional tests

* Rename test

* feat: add Cypress.Keyboard.defaults() for specifying default keystrokeDelay

* use test-configuration on link

* remove obsolete error message

* fix types and add type tests

* fix types tests

* fix type test

Co-authored-by: Chris Breiding <chrisbreiding@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add keystrokeDelay configuration option
4 participants