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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check type with special characters #31

Closed
Gpx opened this issue Oct 21, 2018 · 11 comments 路 Fixed by #308
Closed

Check type with special characters #31

Gpx opened this issue Oct 21, 2018 · 11 comments 路 Fixed by #308
Labels

Comments

@Gpx
Copy link
Member

Gpx commented Oct 21, 2018

userEvent.type writes text correctly. But I'm not sure how it behaves with special characters like or 馃憤 .

It would be good to have tests covering these cases

@Gpx Gpx added help wanted good first issue Good for newcomers labels Oct 21, 2018
@weyert
Copy link

weyert commented Oct 21, 2018

First of all thank you for merging my PR.

Yes, I have been thinking about this today. I think the behaviour of entering special character differ per language of keyboard being used. Do we just want to restrict this to the probably most used American keyboard?

Beside of that do we want to enter capital letters correctly too? E.g. Shift + Letter? What about the enter key for a \n?

@Gpx
Copy link
Member Author

Gpx commented Oct 23, 2018

That's a good point. I think supporting every possible keyboard layout out there is too much work and out of the scope of this project. I would just assume that if a character is typed, it's because it was somewhere on the keyboard. That includes uppercase letters.

Cypress has support for special characters like enter. We could think to do the same https://docs.cypress.io/api/commands/type.html#Arguments

@weyert
Copy link

weyert commented Oct 23, 2018

Yes, that's true. I will have a closer look at the Cypress command for type. Maybe we can borrow some ideas. Wondering how Cypress supports uppercase letters at the moment, though

@weyert
Copy link

weyert commented Oct 25, 2018

While looking into a react-testing-library issue I discovered this package https://github.com/eventualbuddha/keysim.js . Maybe it's interesting to leverage for the type-behaviour?

@Gpx
Copy link
Member Author

Gpx commented Oct 25, 2018

The thing is this library is based on fireEvent, I don't know how that would fit with keysim

@weyert
Copy link

weyert commented Oct 25, 2018

Yeah, that's a good point. Maybe I borrow some ideas from that library :)

@weyert
Copy link

weyert commented Dec 4, 2018

Sorry, I haven't had a need yet to support special characters. I might consider with adding support {backspace} / {ctrl} {meta} etc first. I will have a closer look at how it works in Cypress again.

@hatched-danny
Copy link

Hi, is there any progress on this? What have people been doing to simulate enter key presses if userEvent.type(textArea, "Testing!{enter}"); doesn't work?

@weyert
Copy link

weyert commented Oct 17, 2019

Yes, I have some of it in a local branch at work

@duranmla
Copy link

duranmla commented Feb 11, 2020

There is no on going work related to support "press enter" action? I will be happy to contribute if there is nothing in place yet, nevertheless, looks odd because it should be a very common usage case. Isn't? What does the people do now?

I have tried with:

           fireEvent.keyDown(searchInput, {
                charCode: 13,
                code: 13,
                key: 'Enter',
                keyCode: 13,
            })

And it doesn't work to trigger the submit of the form I have

UPDATE: there is a submit event fireEvent.submit(searchInput) check all events at https://github.com/testing-library/dom-testing-library/blob/master/src/events.js

kentcdodds added a commit that referenced this issue Jun 4, 2020
kentcdodds added a commit that referenced this issue Jun 4, 2020
@kentcdodds
Copy link
Member

馃帀 This issue has been resolved in version 11.1.0 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

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 a pull request may close this issue.

5 participants