Flag active element and :focused tests with :active_element rather than :js

This commit is contained in:
Thomas Walpole 2021-08-18 09:41:35 -07:00
parent 9d6153ef0b
commit 8d32979cd9
6 changed files with 9 additions and 8 deletions

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
Capybara::SpecHelper.spec '#active_element', requires: [:js] do
Capybara::SpecHelper.spec '#active_element', requires: [:active_element] do
it 'should return the active element' do
@session.visit('/form')
@session.send_keys(:tab)

View File

@ -66,7 +66,7 @@ Capybara::SpecHelper.spec '#has_button?' do
expect(@session).to have_button('Click me!', enable_aria_role: false)
end
context 'with focused:', requires: [:js] do
context 'with focused:', requires: [:active_element] do
it 'should be true if a field has focus when focused: true' do
@session.send_keys(:tab)
@ -130,7 +130,7 @@ Capybara::SpecHelper.spec '#has_no_button?' do
expect(@session).to have_no_button('Junk button that does not exist', enable_aria_role: false)
end
context 'with focused:', requires: [:js] do
context 'with focused:', requires: [:active_element] do
it 'should be true if a button does not have focus when focused: true' do
expect(@session).to have_no_button('A Button', focused: true)
end

View File

@ -110,7 +110,7 @@ Capybara::SpecHelper.spec '#has_field' do
end
end
context 'with focused:', requires: [:js] do
context 'with focused:', requires: [:active_element] do
it 'should be true if a field has focus' do
2.times { @session.send_keys(:tab) }
@ -197,7 +197,7 @@ Capybara::SpecHelper.spec '#has_no_field' do
end
end
context 'with focused:', requires: [:js] do
context 'with focused:', requires: [:active_element] 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

View File

@ -19,7 +19,7 @@ Capybara::SpecHelper.spec '#has_link?' do
expect(@session).not_to have_link('A link', href: /nonexistent/)
end
context 'with focused:', requires: [:js] do
context 'with focused:', requires: [:active_element] do
it 'should be true if the given link is on the page and has focus' do
@session.send_keys(:tab)
@ -49,7 +49,7 @@ Capybara::SpecHelper.spec '#has_no_link?' do
expect(@session).to have_no_link('A link', href: %r{/nonexistent-href})
end
context 'with focused:', requires: [:js] do
context 'with focused:', requires: [:active_element] do
it 'should be true if the given link is on the page and has focus' do
expect(@session).to have_no_link('labore', focused: true)
end

View File

@ -8,7 +8,7 @@ class TestClass
end
Capybara::SpecHelper.run_specs TestClass.new, 'DSL', capybara_skip: %i[
js modals screenshot frames windows send_keys server hover about_scheme psc download css driver scroll spatial html_validation shadow_dom
js modals screenshot frames windows send_keys server hover about_scheme psc download css driver scroll spatial html_validation shadow_dom active_element
] do |example|
case example.metadata[:full_description]
when /has_css\? should support case insensitive :class and :id options/

View File

@ -22,6 +22,7 @@ skipped_tests = %i[
spatial
html_validation
shadow_dom
active_element
]
Capybara::SpecHelper.run_specs TestSessions::RackTest, 'RackTest', capybara_skip: skipped_tests do |example|
case example.metadata[:full_description]