Skip to content

Commit 0445b8d

Browse files
committed
fix: more deflaking
1 parent d1d929a commit 0445b8d

File tree

3 files changed

+49
-20
lines changed

3 files changed

+49
-20
lines changed

spec/system/casa_cases/edit_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ def sign_in_and_assign_volunteer
324324
context "when a volunteer is assigned to a case" do
325325
it "marks the volunteer as assigned and shows the start date of the assignment", :js do
326326
sign_in_and_assign_volunteer
327+
expect(page).to have_content("Volunteer assigned to case")
328+
327329
expect(casa_case.case_assignments.count).to eq 1
328330

329331
unassign_button = page.find("button.btn-outline-danger")

spec/system/case_contacts/contact_topic_answers_spec.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ def notes_section
4848
{question: topic_two.question, answer: "Second discussion topic answer."}
4949
])
5050

51-
expect { click_on "Submit" }
52-
.to change(CaseContact.active, :count).by(1)
51+
click_on "Submit"
52+
expect(page).to have_content("Case contact successfully created.")
53+
expect(CaseContact.active.size).to eq 1
5354

5455
case_contact = CaseContact.active.last
5556
expect(case_contact.reload.contact_topic_answers).to be_present
@@ -64,7 +65,7 @@ def notes_section
6465
subject
6566
fill_in_contact_details(contact_types: [contact_type.name])
6667

67-
expect {
68+
expect do
6869
using_wait_time 6 do # autosave debounce may be longer than capybara's wait time
6970
answer_topic contact_topics.first.question, "First discussion topic answer."
7071
within notes_section do
@@ -76,8 +77,8 @@ def notes_section
7677
end
7778

7879
click_on "Submit"
79-
}
80-
.to change(CaseContact.active, :count).by(1)
80+
expect(page).to have_content("Case contact successfully created.")
81+
end.to change(CaseContact.active, :count).by(1)
8182
.and change(ContactTopicAnswer, :count).by(0) # answer already exists on page load
8283

8384
case_contact = CaseContact.active.last
@@ -122,7 +123,10 @@ def notes_section
122123
fill_in_contact_details
123124
fill_in "Additional Notes", with: "This is a note."
124125

125-
expect { click_on "Submit" }.to change(CaseContact.active, :count).by(1)
126+
expect do
127+
click_on "Submit"
128+
expect(page).to have_content("Case contact successfully created.")
129+
end.to change(CaseContact.active, :count).by(1)
126130

127131
contact = CaseContact.active.last
128132
expect(contact.contact_topic_answers).to be_empty
@@ -188,6 +192,7 @@ def notes_section
188192
expect(notes_section).to have_select(class: topic_select_class, count: 1, visible: :all)
189193

190194
click_on "Submit"
195+
expect(page).to have_content(/Case contact .* was successfully updated./)
191196
}
192197
.to change(ContactTopicAnswer, :count).by(-1)
193198

spec/system/case_contacts/new_spec.rb

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@
7070
hours: 1, minutes: 45
7171
)
7272

73-
expect { click_on "Submit" }.not_to change(CaseContact, :count)
74-
75-
expect(page).to have_text("Medium type can't be blank")
73+
expect do
74+
click_on "Submit"
75+
expect(page).to have_text("Medium type can't be blank")
76+
end.not_to change(CaseContact, :count)
7677

7778
expect(page).to have_field("case_contact_duration_hours", with: 1)
7879
expect(page).to have_field("case_contact_duration_minutes", with: 45)
@@ -83,15 +84,21 @@
8384

8485
describe "contact types" do
8586
# TODO: Fix this test
86-
xit "requires a contact type" do
87+
it "requires a contact type" do
8788
subject
8889

8990
fill_in_contact_details(contact_types: nil)
9091

91-
expect { click_on "Submit" }.to not_change(CaseContact.active, :count)
92-
expect(page).to have_text("Contact Type must be selected")
92+
expect do
93+
click_on "Submit"
94+
expect(page).to have_text("Contact Type must be selected")
95+
end.to not_change(CaseContact.active, :count)
96+
9397
check contact_types.first.name
94-
expect { click_on "Submit" }.to change(CaseContact.active, :count).by(1)
98+
expect do
99+
click_on "Submit"
100+
expect(page).to have_text("Case contact successfully created.")
101+
end.to change(CaseContact.active, :count).by(1)
95102
end
96103

97104
it "does not display empty contact groups or hidden contact types" do
@@ -180,7 +187,7 @@
180187

181188
context "when org has no contact topics" do
182189
# TODO: Fix this test
183-
xit "allows entering contact notes" do
190+
it "allows entering contact notes" do
184191
expect(casa_org.contact_topics.size).to eq 0
185192
subject
186193

@@ -190,6 +197,7 @@
190197

191198
expect {
192199
click_on "Submit"
200+
expect(page).to have_text("Case contact successfully created.")
193201
}.to change(CaseContact.active, :count).by(1)
194202

195203
case_contact = CaseContact.active.last
@@ -268,14 +276,17 @@
268276
fill_in volunteer_address_input, with: "123 Example St"
269277
uncheck reimbursement_checkbox
270278

271-
expect { click_on "Submit" }.to change(CaseContact.active, :count).by(1)
279+
expect {
280+
click_on "Submit"
281+
expect(page).to have_text("Case contact successfully created.")
282+
}.to change(CaseContact.active, :count).by(1)
272283
case_contact = CaseContact.active.last
273284

274285
expect(case_contact.want_driving_reimbursement).to be false
275286
expect(case_contact.miles_driven).to be_zero
276287
end
277288

278-
xit "saves mileage and address information" do # TODO make test not flaky
289+
it "saves mileage and address information" do # TODO make test not flaky
279290
subject
280291
fill_in_contact_details contact_types: %w[School]
281292

@@ -284,7 +295,10 @@
284295
fill_in miles_driven_input, with: 50
285296
fill_in volunteer_address_input, with: "123 Example St"
286297

287-
expect { click_on "Submit" }.to change(CaseContact.active, :count).by(1)
298+
expect {
299+
click_on "Submit"
300+
expect(page).to have_text("Case contact successfully created.")
301+
}.to change(CaseContact.active, :count).by(1)
288302
case_contact = CaseContact.active.last
289303

290304
expect(case_contact.want_driving_reimbursement).to be true
@@ -310,8 +324,10 @@
310324

311325
check reimbursement_checkbox
312326

313-
expect { click_on "Submit" }.not_to change(CaseContact.active, :count)
314-
expect(page).to have_text("Must enter a valid mailing address for the reimbursement")
327+
expect {
328+
click_on "Submit"
329+
expect(page).to have_text("Must enter a valid mailing address for the reimbursement")
330+
}.not_to change(CaseContact.active, :count)
315331
expect(page).to have_text("Must enter miles driven to receive driving reimbursement")
316332
end
317333

@@ -391,7 +407,10 @@
391407
)
392408

393409
check "Create Another"
394-
expect { click_on "Submit" }
410+
expect {
411+
click_on "Submit"
412+
expect(page).to have_text "Case contact successfully created."
413+
}
395414
.to change(CaseContact, :count).by(1)
396415
# .to change(CaseContact.active, :count).by(1)
397416
# .and change(CaseContact.started, :count).by(1)
@@ -441,6 +460,7 @@
441460
it "redirects to the new CaseContact form with the same cases selected" do
442461
expect {
443462
visit new_case_contact_path(casa_case, {draft_case_ids:})
463+
expect(page).to have_content("Record New Case Contact")
444464
}.to change(CaseContact.started, :count).by(1)
445465
this_case_contact = CaseContact.started.last
446466

@@ -452,6 +472,7 @@
452472

453473
expect {
454474
click_on "Submit"
475+
expect(page).to have_text "Case contacts successfully created."
455476
}.to change(CaseContact.active, :count).by(2)
456477

457478
expect(page).to have_text "New Case Contact"
@@ -516,6 +537,7 @@
516537

517538
expect {
518539
click_on "Submit"
540+
expect(page).to have_text "Case contact successfully created."
519541
}.to change(CaseContact.active, :count).by(1)
520542
contact = CaseContact.active.last
521543
expect(contact.casa_case_id).to eq casa_case.id

0 commit comments

Comments
 (0)