Files
grecia/spec/components/debates/votes_component_spec.rb
Javi Martín eecaf5876e Move result percentages out of the voting buttons
Having buttons (previously links) with the text "I agree 75%" is
confusing; people might believe they're saying they only partially agree
with the content. Besides, the results percentages is a different piece
of information which shouldn't be related to whether one person
agrees/disagrees with the content.

This problem might be solved for people using screen readers since we
added the aria-label attribute. However, for sighted keyboard users, the
percentage was being outlined on focus as part of the button, which
might be confusing.
2022-02-21 18:47:37 +01:00

44 lines
1.5 KiB
Ruby

require "rails_helper"
describe Debates::VotesComponent do
let(:debate) { create(:debate, title: "What about the 2030 agenda?") }
let(:component) { Debates::VotesComponent.new(debate) }
describe "Agree and disagree buttons" do
it "is disabled to anonymous users" do
render_inline component
expect(page).to have_button "I agree", disabled: true
expect(page).to have_button "I disagree", disabled: true
expect(page).to have_content "You must sign in or sign up to continue."
end
it "is shown to identified users" do
sign_in(create(:user))
render_inline component
expect(page).to have_button count: 2
expect(page).to have_button "I agree", title: "I agree"
expect(page).to have_button "I agree with What about the 2030 agenda?"
expect(page).to have_button "I disagree", title: "I disagree"
expect(page).to have_button "I don't agree with What about the 2030 agenda?"
expect(page).not_to have_content "You must sign in or sign up to continue."
end
it "does not include result percentages" do
create(:vote, votable: debate)
sign_in(create(:user))
render_inline component
expect(page).to have_button count: 2
expect(page).to have_button "I agree"
expect(page).to have_button "I disagree"
expect(page).not_to have_button text: "%"
expect(page).not_to have_button text: "100"
expect(page).not_to have_button text: "0"
end
end
end