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:
@@ -115,7 +115,7 @@ describe "Home" do
|
||||
)
|
||||
|
||||
visit root_path
|
||||
expect(page).to have_xpath(ie_alert_box_xpath, visible: false)
|
||||
expect(page).to have_xpath(ie_alert_box_xpath)
|
||||
expect(page.driver.request.cookies["ie_alert_closed"]).to be_nil
|
||||
|
||||
# faking close button, since a normal find and click
|
||||
@@ -123,13 +123,13 @@ describe "Home" do
|
||||
page.driver.browser.set_cookie("ie_alert_closed=true")
|
||||
|
||||
visit root_path
|
||||
expect(page).not_to have_xpath(ie_alert_box_xpath, visible: false)
|
||||
expect(page).not_to have_xpath(ie_alert_box_xpath)
|
||||
expect(page.driver.request.cookies["ie_alert_closed"]).to eq("true")
|
||||
end
|
||||
|
||||
scenario "non-IE visitors are not bothered with IE alerts", :page_driver do
|
||||
visit root_path
|
||||
expect(page).not_to have_xpath(ie_alert_box_xpath, visible: false)
|
||||
expect(page).not_to have_xpath(ie_alert_box_xpath)
|
||||
expect(page.driver.request.cookies["ie_alert_closed"]).to be_nil
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user