Fix matchers checking elements are obscured

These tests were supposed to check the link to vote is hidden when users
don't have permission to vote. However, they aren't testing that, since
the `visible: false` option also matches visible elements. The links are
actually considered visible since they're displayed by the browser;
there's just another element on top of them.

Using `obscured: true` instead of `visible: false` solves the issue.
However, while the `obscured` option is true when the element is hidden
by another element, it's also true when the element is not currently
visible in the browser window, so in some cases we need to scroll so the
condition is effective.
This commit is contained in:
Javi Martín
2020-10-13 17:59:40 +02:00
parent 11b8561ed8
commit 202fe2953b
4 changed files with 48 additions and 30 deletions

View File

@@ -1,7 +1,12 @@
module Budgets
def expect_message_organizations_cannot_vote
expect(page).to have_content "Organization"
expect(page).to have_selector(".in-favor a", visible: false)
expect(page).to have_selector(".in-favor a", obscured: true)
end
def hover_over_ballot
scroll_to find("div.ballot"), align: :bottom
find("div.ballot").hover
end
def add_to_ballot(investment_title)

View File

@@ -1,7 +1,7 @@
module Votes
def expect_message_you_need_to_sign_in
expect(page).to have_content "You must sign in or sign up to continue"
expect(page).to have_selector(".in-favor", visible: false)
expect(page).to have_selector(".in-favor", obscured: true)
end
def expect_message_you_need_to_sign_in_to_vote_comments
@@ -12,11 +12,11 @@ module Votes
def expect_message_to_many_anonymous_votes
expect(page).to have_content "Too many anonymous votes to admit vote"
expect(page).to have_selector(".in-favor a", visible: false)
expect(page).to have_selector(".in-favor a", obscured: true)
end
def expect_message_only_verified_can_vote_proposals
expect(page).to have_content "Only verified users can vote on proposals"
expect(page).to have_selector(".in-favor", visible: false)
expect(page).to have_selector(".in-favor", obscured: true)
end
end