Files
grecia/spec/support/common_actions.rb
Javi Martín abec716308 Show "not allowed" message on click
Defining a behavior on hover means making it different for people using
a keyboard or a touchscreen (most of the population, nowadays).

In this case, we had an accessibility issue where the message wouldn't
disappear once it appeared. That meant that, after tabbing through all
the links and buttons in, for instance, the debates index, the page
would be filled with "participation not allowed" messages, and in order
to see the information about how many people have voted, reloading the
page was required.

For touchscreen users the behavior was similar to what we get on hover,
although we've found some inconsistencies when trying to support several
elements on the same page.

We think in proposals it makes sense to hide the "support" button when
users click on it, and the same applies to the buttonsto support and
vote investment projects. However, we aren't hiding the buttons to
agree/disagree with a debate in order to keep the information about the
current number of people agreeing and disagreeing visible.

Note we're removing some support spec methods because after these
changes the duplication isn't as obvious as it was in the past.
2022-02-23 16:43:37 +01:00

80 lines
2.2 KiB
Ruby

Dir["./spec/support/common_actions/*.rb"].each { |f| require f }
module CommonActions
include Budgets
include Comments
include Debates
include Emails
include Notifications
include Polls
include Proposals
include RemoteCensusMock
include Tags
include Translations
include Users
include Verifications
def app_host
"#{Capybara.app_host}:#{Capybara::Server.ports.values.last}"
end
def fill_in_signup_form(email = "manuela@consul.dev", password = "judgementday")
fill_in "user_username", with: "Manuela Carmena #{rand(99999)}"
fill_in "user_email", with: email
fill_in "user_password", with: password
fill_in "user_password_confirmation", with: password
check "user_terms_of_service"
end
def validate_officer
allow_any_instance_of(Officing::BaseController).
to receive(:verify_officer_assignment).and_return(true)
end
def fill_in_proposal
fill_in_new_proposal_title with: "Help refugees"
fill_in "Proposal summary", with: "In summary, what we want is..."
fill_in_ckeditor "Proposal text", with: "This is very important because..."
fill_in "External video URL", with: "https://www.youtube.com/watch?v=yPQfcG-eimk"
fill_in "Full name of the person submitting the proposal", with: "Isabel Garcia"
check "I agree to the Privacy Policy and the Terms and conditions of use"
end
def fill_in_new_proposal_title(with:)
fill_in "Proposal title", with: with
expect(page).to have_css ".suggest-success"
end
def fill_in_new_debate_title(with:)
fill_in "Debate title", with: with
expect(page).to have_css ".suggest-success"
end
def fill_in_new_investment_title(with:)
fill_in "Title", with: with
expect(page).to have_css ".suggest-success"
end
def set_officing_booth(booth = nil)
booth = create(:poll_booth) if booth.blank?
allow_any_instance_of(Officing::BaseController).
to receive(:current_booth).and_return(booth)
end
def click_sdg_goal(code)
within(".sdg-related-list-selector .goals") do
find("[data-code='#{code}'] + label").click
end
end
def remove_sdg_goal_or_target_tag(code)
within "span[data-val='#{code}']" do
click_button "Remove"
end
end
end