testing-library / testing-playground

Simple and complete DOM testing playground that encourage good testing practices.

Home Page:https://testing-playground.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In develop environment role queries not appear in ResultQueries

delca85 opened this issue Β· comments

Bug Report πŸ›

On https://develop.testing-playground.com/, clicking on an input element, the getByRole query is rightly inserted (and evaluated) in QueryEditor but it does not appear in ResultQueries.
Clicking on a button element does not reproduce this bug, the role query appears in ResultQueries.

Screenshot 2020-07-05 at 16 01 56

To Reproduce βœ”οΈ

  1. inserted markup
  2. select an input element

Expected behavior πŸ€”

I expected the getByRole query would appear in ResultQueries as it happens in the button case.

Suggested solution πŸ”¦

Your Environment πŸ’»

  • browser: Chrome
  • os: Mac

I just found this comment. The inserted markup indeed had the type attribute specified (it was email) but it does not work anyway while if I set it to textbox the query is rightly suggested in ResultQueries.

I feel like not all the parts of the playground are using suggestions generated by testing-library/dom. That should make cases like these impossible.

Ok, I got your point but I think that maybe we could improve the playground suggestion in case of input with a defined type even if it is not text.

If I am not wrong, this is where we create the role suggestion.
In case of we are evaluating an input element the getRole by dom-accessibility-api is called only if the type attribute is text. I think that we could call getRole anyway because dom-accessibility-api manages every possible value of an input element (an undefined value too).

If it sounds reasonable to you I could open a PR.

Sounds good to me.