diff --git a/spec/support/fill_in_case_contact_fields.rb b/spec/support/fill_in_case_contact_fields.rb index 26da177cbf..bc462f336e 100644 --- a/spec/support/fill_in_case_contact_fields.rb +++ b/spec/support/fill_in_case_contact_fields.rb @@ -15,14 +15,16 @@ def fill_in_contact_details(case_numbers: [], contact_types: [], contact_made: t all(:element, "a", title: "Remove this item").each(&:click) end - find(".ts-control").click + if case_numbers.present? + find(".ts-control").click - Array.wrap(case_numbers).each_with_index do |case_number, index| - checkbox_for_case_number = first("span", text: case_number).sibling("input") - checkbox_for_case_number.click unless checkbox_for_case_number.checked? - end + Array.wrap(case_numbers).each_with_index do |case_number, index| + checkbox_for_case_number = first("span", text: case_number).sibling("input") + checkbox_for_case_number.click unless checkbox_for_case_number.checked? + end - find(".ts-control").click + find(".ts-control").click + end end fill_in "case_contact_occurred_at", with: occurred_on if occurred_on diff --git a/spec/system/case_contacts/new_spec.rb b/spec/system/case_contacts/new_spec.rb index e5bbc0d14b..fee199c2c9 100644 --- a/spec/system/case_contacts/new_spec.rb +++ b/spec/system/case_contacts/new_spec.rb @@ -431,16 +431,21 @@ context "when multiple cases selected" do let(:volunteer) { create(:volunteer, :with_casa_cases, casa_org:) } - let!(:casa_case) { volunteer.casa_cases.first } - let!(:casa_case_two) { volunteer.casa_cases.second } + let(:casa_case) { volunteer.casa_cases.first } + let(:casa_case_two) { volunteer.casa_cases.second } let(:case_number_two) { casa_case_two.case_number } let!(:draft_case_ids) { [casa_case.id, casa_case_two.id] } it "redirects to the new CaseContact form with the same cases selected" do - expect { subject }.to change(CaseContact.started, :count).by(1) + expect { + visit new_case_contact_path(casa_case, {draft_case_ids:}) + }.to change(CaseContact.started, :count).by(1) this_case_contact = CaseContact.started.last - complete_details_page(case_numbers: [case_number, case_number_two], contact_types: %w[School]) + expect(page).to have_select('case_contact_draft_case_ids', selected: [case_number, case_number_two]) + complete_details_page(case_numbers: []) + expect(page).to have_select('case_contact_draft_case_ids', selected: [case_number, case_number_two]) + check "Create Another" expect {