Remove redundant visibility matcher usages
By default, Capybara only finds visible elements, so adding the `visible: true` option is usually redundant. We were using it sometimes to make it an obvious contrast with another test using `visible: false`. However, from the user's perspective, we don't care whether the element has been removed from the DOM or has been hidden, so we can just test that the visible selector can't be found. Besides, using `visible: false` means the test will also pass if the element is present and visible. However, we want the test to fail if the element is visible. That's why a couple of JavaScript-dependant tests were passing even when JavaScript was disabled.
This commit is contained in:
@@ -17,16 +17,16 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
|
||||
login_as user
|
||||
visit send(path, arguments)
|
||||
|
||||
expect(page).to have_selector "#new_image_link", visible: true
|
||||
expect(page).to have_selector "#new_image_link"
|
||||
end
|
||||
|
||||
scenario "Should hide new image link after adding one image" do
|
||||
scenario "Should hide new image link after adding one image", :js do
|
||||
login_as user
|
||||
visit send(path, arguments)
|
||||
|
||||
click_on "Add image"
|
||||
|
||||
expect(page).to have_selector "#new_image_link", visible: false
|
||||
expect(page).not_to have_selector "#new_image_link"
|
||||
end
|
||||
|
||||
scenario "Should update nested image file name after choosing any file", :js do
|
||||
@@ -226,7 +226,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
|
||||
login_as user
|
||||
visit send(path, arguments)
|
||||
|
||||
expect(page).to have_css "a#new_image_link", visible: false
|
||||
expect(page).not_to have_css "a#new_image_link"
|
||||
end
|
||||
|
||||
scenario "Should remove nested field after remove image", :js do
|
||||
@@ -244,7 +244,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
|
||||
visit send(path, arguments)
|
||||
click_on "Remove image"
|
||||
|
||||
expect(page).to have_css "a#new_image_link", visible: true
|
||||
expect(page).to have_css "a#new_image_link"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user