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

@@ -241,7 +241,7 @@ describe "Commenting Budget::Investments" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "Reply update parent comment responses count", :js do
@@ -357,7 +357,7 @@ describe "Commenting Budget::Investments" do
expect(page).to have_css "img.moderator-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as an administrator" do
@@ -456,7 +456,7 @@ describe "Commenting Budget::Investments" do
expect(page).to have_css "img.admin-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
expect(page).to have_css "div.is-admin"
end

View File

@@ -210,7 +210,7 @@ describe "Internal valuation comments on Budget::Investments" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
visit budget_investment_path(investment.budget, investment)
expect(page).not_to have_content("It will be done next week.")
@@ -328,7 +328,7 @@ describe "Internal valuation comments on Budget::Investments" do
expect(page).to have_css "img.admin-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
end

View File

@@ -254,7 +254,7 @@ describe "Commenting debates" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "Reply to reply", :js do
@@ -408,7 +408,7 @@ describe "Commenting debates" do
expect(page).to have_css "img.moderator-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as an administrator" do
@@ -464,7 +464,7 @@ describe "Commenting debates" do
expect(page).to have_css "img.admin-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as a moderator" do

View File

@@ -277,7 +277,7 @@ describe "Commenting legislation questions" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "Reply update parent comment responses count", :js do
@@ -430,7 +430,7 @@ describe "Commenting legislation questions" do
expect(page).to have_css "img.moderator-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as an administrator" do
@@ -493,7 +493,7 @@ describe "Commenting legislation questions" do
expect(page).to have_css "img.admin-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as a moderator" do

View File

@@ -258,7 +258,7 @@ describe "Commenting legislation questions" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "Reply update parent comment responses count", :js do
@@ -387,7 +387,7 @@ describe "Commenting legislation questions" do
expect(page).to have_css "img.moderator-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as an administrator" do
@@ -443,7 +443,7 @@ describe "Commenting legislation questions" do
expect(page).to have_css "img.admin-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as a moderator" do

View File

@@ -237,7 +237,7 @@ describe "Commenting polls" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "Reply update parent comment responses count", :js do
@@ -357,7 +357,7 @@ describe "Commenting polls" do
expect(page).to have_css "img.moderator-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as an administrator" do
@@ -419,7 +419,7 @@ describe "Commenting polls" do
expect(page).to have_css "img.admin-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as a moderator" do

View File

@@ -237,7 +237,7 @@ describe "Commenting proposals" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "Reply update parent comment responses count", :js do
@@ -353,7 +353,7 @@ describe "Commenting proposals" do
expect(page).to have_css "img.moderator-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as an administrator" do
@@ -409,7 +409,7 @@ describe "Commenting proposals" do
expect(page).to have_css "img.admin-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as a moderator" do

View File

@@ -263,7 +263,7 @@ describe "Commenting topics from proposals" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "Reply update parent comment responses count", :js do
@@ -393,7 +393,7 @@ describe "Commenting topics from proposals" do
expect(page).to have_css "img.moderator-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as an administrator" do
@@ -455,7 +455,7 @@ describe "Commenting topics from proposals" do
expect(page).to have_css "img.admin-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as a moderator" do
@@ -807,7 +807,7 @@ describe "Commenting topics from budget investments" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "Errors on reply", :js do
@@ -901,7 +901,7 @@ describe "Commenting topics from budget investments" do
expect(page).to have_css "img.moderator-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as an administrator" do
@@ -963,7 +963,7 @@ describe "Commenting topics from budget investments" do
expect(page).to have_css "img.admin-avatar"
end
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}")
end
scenario "can not comment as a moderator" do