I have two datetime
inputs that have a change event (through stimulus) that trigger a function when values change. If the dates (whatever times are) are the same in both fields, it removes d-none
class from a below div to allow user to fill a complementary field.
The feature perfectly works and all my tests on local passe as well. The problem is when I push my branch on production: my test fails because the text within the div that is supposed to been shown, is still hidden.
Here my stimulus event on each input:
action: "change->client-timeslots-repeat#toggleRepeatContainer"
The part of test that fails:
within "#proposal-timeslots-creation-form" do
fill_in "timeslots_proposal[client_timeslots_attributes][0][starts_at]", with: "15022022\t1800"
fill_in "timeslots_proposal[client_timeslots_attributes][0][ends_at]", with: "15022022\t2000"
expect(page).to have_content "Répéter ce créneau horaire"
end
And the error:
expected to find text "Répéter ce créneau horaire" in "Début de la dispo\nFin". (However, it was found 1 time including non-visible text.)
For a reason I don't know, the event is not triggered, probably because the environment is different but what the exact part of it... I don't know if you need more infos to target my issue?
Thanks for your help!
CodePudding user response:
When attempting to fill in datetime controls via string values, the order necessary is dependent on the locale the browser is set to. Judging by the order you're specifying the string in I'm guessing you're in europe somewhere while Herokus servers are most likely configured to the US. This would cause your strings to be invalid (no 15th month) and therefore fail changing the date/time. Instead try something like
fill_in "timeslots_proposal[client_timeslots_attributes][0][starts_at]", with: "02152022\t1800"
or
fill_in "timeslots_proposal[client_timeslots_attributes][0][starts_at]", with: "02/15/2022\t06:00P"