Skip to content

Commit 5a52ad1

Browse files
authored
Merge pull request #6305 from dmcarmo/fix-race-condition-system-tests
Wait for page load before database load
2 parents 2434ac2 + fcba993 commit 5a52ad1

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

spec/system/case_contacts/edit_spec.rb

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@
2727

2828
click_on "Submit"
2929

30-
case_contact.reload
3130
expect(page).to have_text "Case contact created at #{case_contact.created_at.strftime("%-I:%-M %p on %m-%e-%Y")}, was successfully updated."
31+
case_contact.reload
3232
expect(case_contact.casa_case_id).to eq casa_case.id
3333
expect(case_contact.duration_minutes).to eq 105
3434
expect(case_contact.medium_type).to eq "letter"
3535
expect(case_contact.contact_made).to be true
3636
end
3737

38-
# TODO: Fix this test
39-
xit "admin successfully edits case contact with mileage reimbursement" do
38+
it "admin successfully edits case contact with mileage reimbursement" do
4039
visit edit_case_contact_path(case_contact)
4140

4241
complete_details_page(case_numbers: [], contact_types: [], contact_made: true, medium: "In Person", hours: 1, minutes: 45, occurred_on: "04/04/2020")
4342
complete_notes_page
4443
fill_in_expenses_page(miles: 10, want_reimbursement: true, address: "123 str")
4544

4645
click_on "Submit"
47-
case_contact.reload
4846
expect(page).to have_text "Case contact created at #{case_contact.created_at.strftime("%-I:%-M %p on %m-%e-%Y")}, was successfully updated."
47+
case_contact.reload
48+
volunteer.address&.reload
4949
expect(case_contact.casa_case.volunteers[0]).to eq volunteer
5050
expect(volunteer.address&.content).to eq "123 str"
5151
expect(case_contact.casa_case_id).to eq casa_case.id
@@ -63,14 +63,10 @@
6363
visit edit_case_contact_path(case_contact)
6464

6565
complete_details_page(case_numbers: [], contact_types: [], contact_made: true, medium: "In Person", hours: 1, minutes: 45, occurred_on: "04/04/2020")
66-
complete_notes_page
6766

6867
check "Request travel or other reimbursement"
6968
expect(page).to have_field("case_contact_volunteer_address", disabled: true)
7069
expect(page).to have_text("There are two or more volunteers assigned to this case and you are trying to set the address for both of them. This is not currently possible.")
71-
72-
click_on "Submit"
73-
expect(case_contact.reload.volunteer_address).to be_blank
7470
end
7571

7672
context "when user is part of a different organization" do
@@ -112,8 +108,9 @@
112108
fill_in_expenses_page(miles: 50, want_reimbursement: true, address: "123 Form St")
113109
click_on "Submit"
114110

115-
case_contact.reload
116111
expect(page).to have_text "Case contact created at #{case_contact.created_at.strftime("%-I:%-M %p on %m-%e-%Y")}, was successfully updated."
112+
case_contact.reload
113+
case_contact.contact_topic_answers&.reload
117114
expect(case_contact.duration_minutes).to eq 65
118115
expect(case_contact.medium_type).to eq "letter"
119116
expect(case_contact.contact_made).to be true
@@ -128,7 +125,7 @@
128125
expect(case_contact.volunteer_address).to eq "123 Form St"
129126
end
130127

131-
xit "is successful with mileage reimbursement on" do # TODO make test not flaky
128+
it "is successful with mileage reimbursement on" do
132129
visit edit_case_contact_path(case_contact)
133130

134131
complete_details_page(contact_made: true, medium: "In Person", hours: 1, minutes: 45, occurred_on: "04/04/2020")
@@ -137,9 +134,9 @@
137134

138135
click_on "Submit"
139136

137+
expect(page).to have_text "Case contact created at #{case_contact.created_at.strftime("%-I:%-M %p on %m-%e-%Y")}, was successfully updated."
140138
case_contact.reload
141139
volunteer.reload
142-
expect(page).to have_text "Case contact created at #{case_contact.created_at.strftime("%-I:%-M %p on %m-%e-%Y")}, was successfully updated."
143140
expect(volunteer.address.content).to eq "123 str"
144141
expect(case_contact.casa_case_id).to eq casa_case.id
145142
expect(case_contact.duration_minutes).to eq 105

0 commit comments

Comments
 (0)