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

FillIn acceptance helper works only on the first matched input #14018

Closed
piotrpalek opened this issue Aug 4, 2016 · 5 comments
Closed

FillIn acceptance helper works only on the first matched input #14018

piotrpalek opened this issue Aug 4, 2016 · 5 comments
Labels

Comments

@piotrpalek
Copy link

piotrpalek commented Aug 4, 2016

I tried to fillIn multiple inputs in an acceptance test with one selector. So let's say my template was:

{{input value=someVal}}
{{input value=otherVal}}

And I was using fillIn like this: fillIn('input', 'someval')

The result would be that visually it would seem as if both inputs are filled in with the same value (html was updated), but the data binding would only be updated on someVal.

Replicated here: https://ember-twiddle.com/63d30b6cde4d82491c0def9bcc36ef28

(sidenote: I couldn't use Ember 2.7 due to a twiddle bug, but the same thing is happening in an app using Ember 2.7)

@piotrpalek
Copy link
Author

Ok so the issue seems to be that the fillIn helper uses the first element of the collection it finds for most of the work, but uses the whole collection to set the value:

Question is what's the expected behavior, to only work on the first element or to work on all found elements?

@pixelhandler
Copy link
Contributor

pixelhandler commented Aug 4, 2016

@piotrpalek I'm curious if you are more explicit with the selector you use with fillIn to only find one input does the helper work as expected?

See: this twiddle it uses a more specific selected to fillIn https://ember-twiddle.com/053b51712bc76076ec1200645b813b17?fileTreeShown=false&openFiles=tests.acceptance.my-acceptance-test.js%2C

I think that the expectation is that the fillIn helper should use a specific selector for a single input.

I do not think this is a bug.

@piotrpalek
Copy link
Author

piotrpalek commented Aug 4, 2016

@pixelhandler being able to make the selector more specific isn't the issue. The issue is that the behavior is inconsistent when having a selector that matches multiple inputs. It should either only work for the first element in case of multiple inputs, or work consistently for all of them.

Right now when you try to fillIn multiple inputs it seems as if it's working but actually isn't, that is very clearly a bug in my opinion.

As for the question if it should work for multiple elements. I think that if the guides say that it expects a selector for the input, without specifying that it will only work for the first matched element, then it would be expected that it can work on all of the elements that the selector finds, not only for the first item. But that's something that can be agreed on.

Serabe added a commit to Serabe/ember.js that referenced this issue Aug 5, 2016
Currently, `fillIn` sets the new value to all matches, though the events are
only fired for the first one, making Ember only aware of that one.

This can cause a problem while trying to _debug_ a test.

Fixes emberjs#14018
@Serabe Serabe added the Has PR label Aug 5, 2016
rwjblue pushed a commit that referenced this issue Aug 5, 2016
Currently, `fillIn` sets the new value to all matches, though the events are
only fired for the first one, making Ember only aware of that one.

This can cause a problem while trying to _debug_ a test.

Fixes #14018

(cherry picked from commit 7e9176d)
@Serabe
Copy link
Member

Serabe commented Aug 5, 2016

Thank you, @piotrpalek! The PR has just been merged and there is a comment in the Grand Testing Unification RFC you might be interested in.

Thank you!

@piotrpalek
Copy link
Author

@Serabe np 👍

toddjordan pushed a commit to toddjordan/ember.js that referenced this issue Sep 9, 2016
Currently, `fillIn` sets the new value to all matches, though the events are
only fired for the first one, making Ember only aware of that one.

This can cause a problem while trying to _debug_ a test.

Fixes emberjs#14018
webark pushed a commit to webark/ember.js that referenced this issue Oct 6, 2016
Currently, `fillIn` sets the new value to all matches, though the events are
only fired for the first one, making Ember only aware of that one.

This can cause a problem while trying to _debug_ a test.

Fixes emberjs#14018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants