Files
nairobi/spec/components/officing/results/form_component_spec.rb
Javi Martín 9308189a00 Use number fields to enter number of votes
This way the fields are easier to use, and we can get rid of the
placeholders.

Note we're simplifying the `answer_result_value` in order to make it
easier to return `0` instead of `nil` when the field is empty.

Also note there's a small change of behavior here; previously, these
fields were empty by default, and now their value is `0` by default, so
blindly clicking the "Save" button would send `0` instead of an empty
value. I don't think it's a big deal, though, but we need to keep that
in mind.
2025-04-03 15:01:01 +02:00

20 lines
768 B
Ruby

require "rails_helper"
describe Officing::Results::FormComponent do
let(:poll) { create(:poll, ends_at: 1.day.ago) }
before { create(:poll_question, :yes_no, poll: poll, title: "Agreed?") }
it "uses number fields with 0 as a default value" do
render_inline Officing::Results::FormComponent.new(poll, Poll::OfficerAssignment.none)
page.find(:fieldset, "Agreed?") do |fieldset|
expect(fieldset).to have_field "Yes", with: 0, type: :number
expect(fieldset).to have_field "No", with: 0, type: :number
end
expect(page).to have_field "Totally blank ballots", with: 0, type: :number
expect(page).to have_field "Invalid ballots", with: 0, type: :number
expect(page).to have_field "Valid ballots", with: 0, type: :number
end
end