5.1.0 changes wrong input when using querySelector and multiple select#47
Closed
fonji wants to merge 2 commits intoromgain:masterfrom
Closed
5.1.0 changes wrong input when using querySelector and multiple select#47fonji wants to merge 2 commits intoromgain:masterfrom
fonji wants to merge 2 commits intoromgain:masterfrom
Conversation
fonji
commented
Oct 6, 2020
| expect(form).toHaveFormValues({ foodForMonday: "", foodForTuesday: "" }); | ||
| await selectEvent.select(mondayInput, /Chocolate/); | ||
| await selectEvent.select(tuesdayInput, /Chocolate/); | ||
| expect(form).toHaveFormValues({ foodForMonday: "chocolate", foodForTuesday: "chocolate" }); |
Author
There was a problem hiding this comment.
this will fail, as foodForTuesday is ""
Owner
|
Hey @fonji ! Sorry for taking so long to come back to you. The issue in this case is that you're not targeting the right input field with your const tuesdayInput = container.querySelector('input[name="foodForTuesday"]');
debug(tuesdayInput);
// prints out:
<input
name="foodForTuesday"
type="hidden"
value=""
/>That's a hidden input created under the hood by That's why we recommend using const tuesdayInput = getByLabelText('Food for tuesday');
debug(tuesdayInput);
// prints out:
<input
aria-autocomplete="list"
autocapitalize="none"
autocomplete="off"
autocorrect="off"
id="food-for-tuesday"
spellcheck="false"
style="box-sizing: content-box; width: 2px; border: 0px; opacity: 1; outline: 0; padding: 0px;"
tabindex="0"
type="text"
value=""
/>^ That one is the correct element, and the test passes just fine. I know it's been a while, but let me know if you have any questions! |
Author
Owner
|
No probs! Have a great day 😄 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Since 5.1.0, using querySelector fails when having multiple inputs with the same options.
.selectwill change the first select that have the option available.I couldn't debug it, but here's a test case hoping it will help.
Thank you for the awesome work and have a nice day!