Add firefox date/time inputs being set via string tests

This commit is contained in:
Thomas Walpole 2019-03-07 13:50:59 -08:00
parent d60a0ee010
commit 0d2932d1d9
2 changed files with 30 additions and 1 deletions

View File

@ -398,7 +398,7 @@ private
end
def to_date_str
value.to_date.strftime('%Y-%m-%d')
value.to_date.iso8601
end
def timeable?

View File

@ -73,6 +73,35 @@ RSpec.describe 'Capybara::Session with firefox' do # rubocop:disable RSpec/Multi
include Capybara::SpecHelper
include_examples 'Capybara::Session', TestSessions::SeleniumFirefox, :selenium_firefox
include_examples Capybara::RSpecMatchers, TestSessions::SeleniumFirefox, :selenium_firefox
describe 'filling in Firefox-specific date and time fields with keystrokes' do
let(:datetime) { Time.new(1983, 6, 19, 6, 30) }
let(:session) { TestSessions::SeleniumFirefox }
before do
session.visit('/form')
end
it 'should fill in a date input with a String' do
session.fill_in('form_date', with: datetime.to_date.iso8601)
session.click_button('awesome')
expect(Date.parse(extract_results(session)['date'])).to eq datetime.to_date
end
it 'should fill in a time input with a String' do
session.fill_in('form_time', with: datetime.to_time.strftime('%T'))
session.click_button('awesome')
results = extract_results(session)['time']
expect(Time.parse(results).strftime('%r')).to eq datetime.strftime('%r')
end
it 'should fill in a datetime input with a String' do
# FF doesn't currently support datetime-local so this is really just a text input
session.fill_in('form_datetime', with: datetime.iso8601)
session.click_button('awesome')
expect(Time.parse(extract_results(session)['datetime'])).to eq datetime
end
end
end
RSpec.describe Capybara::Selenium::Driver do