ChrisCPO
ChrisCPO

Reputation: 463

Rails simple_simple form, feature test failing to populate field/sometimes

I have a finicky test(s).

I'm using simple_form and rails to create a pretty standard job/college type application for users to fill out.

Issue is: Sometimes in the feature test, when a user is editing the application(created via Factoryfirl), rails/simple_form fails to populate a datefield with some of the variables of the date. This also seems to only happen when include_blank: is true.

I know it's being created with a date. The field is failing to be populated with the date, sometimes and only the year column.

I don't think this is an issue with anything I wrote as the tests do work sometimes. Could be a config issue so:

the call to the field:

= required_field_on_submit(f, :profile, :birthdate, as: :date, start_year: years_ago(100), end_year: years_ago(Application::MINIMUM_AGE - 1), include_blank: true, order: order(:m, :d, :y))

required_field_on_submit is just a custom wrapper for f.input, bc of the way applications are being validated. Nothing funky happening there, already checked.

Upvotes: 0

Views: 125

Answers (2)

Sarabjit Singh
Sarabjit Singh

Reputation: 790

Are you able to select the value for which is given by (years_ago(100)) from front end manually? If yes then make sure that the page is loaded properly, before passing the values. You can wait for an element or verify a message on the page. You can also try debugging the failing cases, by adding "puts" statement to print the date in the console, so that it can be verified that whether the date is in correct range or not.

Upvotes: 0

Thomas Walpole
Thomas Walpole

Reputation: 49890

As I mentioned in the comments - A usual cause of a date select not being correctly filled by a page during tests is the data being generated (factory, etc) being outside the acceptable range of the date select

Upvotes: 1

Related Questions