1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

resolve test failures, respond to code review feedback

This commit is contained in:
Sean Doyle 2021-08-18 08:08:54 -04:00
parent c625420f0f
commit 689b8cb2fb
4 changed files with 12 additions and 12 deletions

View file

@ -5,11 +5,11 @@ Capybara::SpecHelper.spec '#active_element', requires: [:js] do
@session.visit('/form')
@session.send_keys(:tab)
expect(@session.active_element).to match_selector(:css, '#form_title')
expect(@session.active_element).to match_selector(:css, '[tabindex="1"]')
@session.send_keys(:tab)
expect(@session.active_element).not_to match_selector(:css, '#form_title')
expect(@session.active_element).to match_selector(:css, '[tabindex="2"]')
end
it 'should support reloading' do

View file

@ -110,7 +110,7 @@ Capybara::SpecHelper.spec '#has_field' do
end
end
context 'with focused', requires: [:js] do
context 'with focused:', requires: [:js] do
it 'should be true if a field has focus' do
2.times { @session.send_keys(:tab) }
@ -197,15 +197,15 @@ Capybara::SpecHelper.spec '#has_no_field' do
end
end
context 'with focused', requires: [:js] do
it 'should be true if a field does not have focus' do
expect(@session).to have_field('An Input', focused: true)
context 'with focused:', requires: [:js] do
it 'should be true if a field does not have focus when focused: true' do
expect(@session).to have_no_field('An Input', focused: true)
end
it 'should be false if a field has focus' do
it 'should be false if a field has focus when focused: true' do
2.times { @session.send_keys(:tab) }
expect(@session).to have_field('An Input', focused: false)
expect(@session).not_to have_no_field('An Input', focused: true)
end
end
end

View file

@ -11,7 +11,7 @@
<p>
<label for="form_title">Title</label>
<select name="form[title]" id="form_title" class="title" tabindex=1>
<select name="form[title]" id="form_title" class="title" tabindex="3">
<option class="title">Mrs</option>
<option class="title">Mr</option>
<option>Miss</option>

View file

@ -223,14 +223,14 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
end
describe '#send_keys' do
it 'defaults to sending keys to the document.activeElement' do
it 'defaults to sending keys to the active_element' do
session.visit('/form')
expect(session.evaluate_script('document.activeElement')).to eq(session.find('//body'))
expect(session.active_element).to match_selector(:css, 'body')
session.send_keys(:tab)
expect(session.evaluate_script('document.activeElement')).to eq(session.first(:field))
expect(session.active_element).to match_selector(:css, '[tabindex="1"]')
end
end