Skip to content

Commit

Permalink
fix flaky spec
Browse files Browse the repository at this point in the history
  • Loading branch information
thejonroberts committed Oct 18, 2024
1 parent 1513c4e commit b6e73f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
14 changes: 8 additions & 6 deletions spec/support/fill_in_case_contact_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions spec/system/case_contacts/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b6e73f9

Please sign in to comment.