-
-
Notifications
You must be signed in to change notification settings - Fork 328
Description
The PR #526 by @mgrunberg, which was created to resolve issue #523, introduced the assumption that Rails 7 will always render date fields as <input type="date">. However, it's still possible for Rails 7 to render <select> based date inputs.
According to the Rails Form Helpers guide:
If you do not wish to use HTML5 date and time inputs, Rails provides alternative date and time form helpers that render plain select boxes.
There are now two officially supported form helper methods:
form.date_fieldwill output<input type="date">(new in Rails 7)form.date_selectwill output<select>fields (traditional Rails date input)
However when using Rails 7, only <input type="date"> fields are supported because:
cucumber-rails/lib/cucumber/rails/capybara/select_dates_and_times.rb
Lines 11 to 20 in fa07f57
| if ::Rails::VERSION::MAJOR >= 7 | |
| # Rails 7 generates date fields using input type="date". Capybara support's them | |
| fill_in options[:from], with: date | |
| else | |
| base_dom_id = get_base_dom_id_from_label_tag(options[:from]) | |
| find(:xpath, ".//select[@id='#{base_dom_id}_1i']").select(date.year.to_s) | |
| find(:xpath, ".//select[@id='#{base_dom_id}_2i']").select(I18n.l(date, format: '%B')) | |
| find(:xpath, ".//select[@id='#{base_dom_id}_3i']").select(date.day.to_s) | |
| end |
👓 What did you see?
Cucumber no longer knows how to select dates for input fields created with form.date_select in Rails 7.
✅ What did you expect to see?
Cucumber should still be able to select dates, regardless of whether form.date_field or form.date_select was used in Rails 7.
📦 Which version are you using?
- cucumber-rails 2.5.0
- Rails 7
🔬 How could we reproduce it?
- Install Rails 7 with cucumber-rails 2.5.0
- Render a form with a date field created using
form.date_select - Cucumber cannot select a date for this field