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:
Javi Martín
2020-10-13 18:11:39 +02:00
parent 202fe2953b
commit 6088334dbf
15 changed files with 54 additions and 50 deletions

View File

@@ -23,13 +23,13 @@ shared_examples "relationable" do |relationable_model_name|
expect(page).not_to have_css("#related-content-list")
end
scenario "related contents can be added" do
scenario "related contents can be added", :js do
login_as(user)
visit relationable.url
expect(page).to have_selector("#related_content", visible: false)
expect(page).not_to have_selector("#related_content")
click_on("Add related content")
expect(page).to have_selector("#related_content", visible: true)
within("#related_content") do
fill_in "url", with: "#{Setting["url"] + related1.url}"
@@ -46,6 +46,8 @@ shared_examples "relationable" do |relationable_model_name|
expect(page).to have_content(relationable.title)
end
click_on("Add related content")
within("#related_content") do
fill_in "url", with: "#{Setting["url"] + related2.url}"
click_button "Add"