Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

fill_in does not populate text fields appropriately for empty strings #867

Closed
RochesterinNYC opened this issue Dec 17, 2015 · 2 comments
Closed

Comments

@RochesterinNYC
Copy link
Contributor

We have a short feature spec that is essentially trying to fill in a form's text field as an empty string using fill_in, submitting it, and expecting a validation error to be returned from our server and rendered on the form. We're doing the following to fill in the empty string:

fill_in('Version Name', with: '')

Through looking at the form params received by our server controller, it seems that the text field does not actually get changed to a blank value. (1.0 was the initial value the text field was loaded with).

{"version"=>"1.0"}

It doesn't seem like there is a warning or description of an inability to pass in empty strings (just that a string must be passed as the value to the with key) for fill_in. Is this functionality supposed to be working?

Also, for context, we're using Rails and our form is built using React and Flux. Although, we've verified that using fill_in with a normal string like so does work:

fill_in('Version Name', with: 'New Name')

-- James && Marc (mmagruder@pivotal.io)

Verbose feature spec log and Capybara debug logs:
In the feature spec that this log portrays, we're going to two different pages, the page with the form, and then filling in that text field. We can try to produce a reproducible test suite/app and logs if necessary.

test.txt

@RochesterinNYC RochesterinNYC changed the title fill_in does not seem to fill in empty strings appropriately fill_in does not seem to populate text fields appropriately for empty strings Dec 17, 2015
@RochesterinNYC RochesterinNYC changed the title fill_in does not seem to populate text fields appropriately for empty strings fill_in does not populate text fields appropriately for empty strings Dec 17, 2015
@mhoran
Copy link
Collaborator

mhoran commented Dec 22, 2015

Hey @RochesterinNYC. A quick look at the implementation shows that blank strings should be supported. However, you'll need to ensure that you're not filling in a readonly field. Also, are you sure something else is not modifying the text? Finally, if you're loading the form field into some sort of object via JS and expecting the data to be sent via Ajax, it's quite possible that we're not firing the correct events for your JS to pick up the change. Right now, we only fire the change event. Given the field is being set to empty, we do not fire any keypress events.

This behavior has changed over time and we've struggled to find the best behavior across browsers (Chrome and Firefox via Selenium, capybara-webkit, etc). The current implementation is the best we've come up with.

If you could put together a simple test suite that replicates the issue, that'd be great. We can then pull it in to our test suite, or push it upstream to capybara for further discussion.

@RochesterinNYC
Copy link
Contributor Author

Closing as I've lost the original context of this issue. Cheers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants