Files
grecia/spec/components/officing/menu_component_spec.rb
Javi Martín 985d3da032 Move officing menu partial to a component
This way we can move some system tests to component tests and stop
creating records after starting the browser with a `visit`.

We could also split the system test in two, but since these tests
aren't checking any user interactions, moving the to component tests we
check the same things while making the tests faster.

Since the partial was using an instance variable, we're passing it to
the component. We're naming it `voter_user` instead of `user` because
passing something named `user` could make us think that we're passing
the `current_user`. I wasn't sure about naming it `voter` because it's a
`User` record and not a `Poll::Voter` record, but naming it `voter`
would definitely be an option.
2025-04-01 15:08:55 +02:00

38 lines
1.2 KiB
Ruby

require "rails_helper"
describe Officing::MenuComponent do
let(:booth) { create(:poll_booth) }
let(:officer) { create(:poll_officer) }
let(:component) { Officing::MenuComponent.new(voter_user: nil) }
before do
create(:poll_booth_assignment, booth: booth)
sign_in(officer.user)
end
it "shows the validate document link when there are vote collection shifts assigned" do
create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :vote_collection)
render_inline component
expect(page).to have_content "Validate document"
expect(page).not_to have_content "Total recounts and results"
end
it "shows the total recounts link when there are recount scrutinity shifts assigned" do
create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :recount_scrutiny)
render_inline component
expect(page).not_to have_content "Validate document"
expect(page).to have_content "Total recounts and results"
end
it "does not show any links when there are no shifts assigned" do
render_inline component
expect(page).not_to have_content "Validate document"
expect(page).not_to have_content "Total recounts and results"
end
end