From 2575fb316b94a4589151d485c1a882ec78d69829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 13 Mar 2025 12:29:53 +0100 Subject: [PATCH] Simplify test checking multiple officing sessions We can reuse the `officing_verify_residence` method to make the test easier to read. We're also removing the final visit to final_officing_polls_path because it doesn't really add anything to the test. --- spec/support/common_actions/verifications.rb | 4 ++-- spec/system/officing_spec.rb | 18 ++---------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/spec/support/common_actions/verifications.rb b/spec/support/common_actions/verifications.rb index 6dad2584c..99e295950 100644 --- a/spec/support/common_actions/verifications.rb +++ b/spec/support/common_actions/verifications.rb @@ -11,9 +11,9 @@ module Verifications expect(page).to have_content I18n.t("verification.residence.create.flash.success") end - def officing_verify_residence + def officing_verify_residence(document_number: "12345678Z") select "DNI", from: "residence_document_type" - fill_in "residence_document_number", with: "12345678Z" + fill_in "residence_document_number", with: document_number fill_in "residence_year_of_birth", with: "1980" click_button "Validate document" diff --git a/spec/system/officing_spec.rb b/spec/system/officing_spec.rb index 7dbbecec7..ba054901b 100644 --- a/spec/system/officing_spec.rb +++ b/spec/system/officing_spec.rb @@ -130,12 +130,8 @@ describe "Poll Officing" do in_browser(:one) do visit new_officing_residence_path - select "DNI", from: "residence_document_type" - fill_in "residence_document_number", with: "12345678Z" - fill_in "residence_year_of_birth", with: "1980" - click_button "Validate document" + officing_verify_residence(document_number: "12345678Z") - expect(page).to have_content "Document verified with Census" click_button "Confirm vote" expect(page).to have_content "Vote introduced!" expect(Poll::Voter.where(document_number: "12345678Z", @@ -143,19 +139,12 @@ describe "Poll Officing" do origin: "booth", officer_id: officer1) .count).to be(1) - - visit final_officing_polls_path - expect(page).to have_content("Polls ready for final recounting") end in_browser(:two) do visit new_officing_residence_path - select "DNI", from: "residence_document_type" - fill_in "residence_document_number", with: "12345678Y" - fill_in "residence_year_of_birth", with: "1980" - click_button "Validate document" + officing_verify_residence(document_number: "12345678Y") - expect(page).to have_content "Document verified with Census" click_button "Confirm vote" expect(page).to have_content "Vote introduced!" expect(Poll::Voter.where(document_number: "12345678Y", @@ -163,9 +152,6 @@ describe "Poll Officing" do origin: "booth", officer_id: officer2) .count).to be(1) - - visit final_officing_polls_path - expect(page).to have_content("Polls ready for final recounting") end end end