Skip to content

Commit 2e7e930

Browse files
committed
fix: more deflaking
1 parent d1d929a commit 2e7e930

File tree

3 files changed

+49
-19
lines changed

3 files changed

+49
-19
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 successfully created.")
191196
}
192197
.to change(ContactTopicAnswer, :count).by(-1)
193198

spec/system/case_contacts/new_spec.rb

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

73-
expect { click_on "Submit" }.not_to change(CaseContact, :count)
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)
7477

75-
expect(page).to have_text("Medium type can't be blank")
7678

7779
expect(page).to have_field("case_contact_duration_hours", with: 1)
7880
expect(page).to have_field("case_contact_duration_minutes", with: 45)
@@ -83,15 +85,21 @@
8385

8486
describe "contact types" do
8587
# TODO: Fix this test
86-
xit "requires a contact type" do
88+
it "requires a contact type" do
8789
subject
8890

8991
fill_in_contact_details(contact_types: nil)
9092

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

97105
it "does not display empty contact groups or hidden contact types" do
@@ -180,7 +188,7 @@
180188

181189
context "when org has no contact topics" do
182190
# TODO: Fix this test
183-
xit "allows entering contact notes" do
191+
it "allows entering contact notes" do
184192
expect(casa_org.contact_topics.size).to eq 0
185193
subject
186194

@@ -190,6 +198,7 @@
190198

191199
expect {
192200
click_on "Submit"
201+
expect(page).to have_text("Case contact successfully created.")
193202
}.to change(CaseContact.active, :count).by(1)
194203

195204
case_contact = CaseContact.active.last
@@ -268,14 +277,17 @@
268277
fill_in volunteer_address_input, with: "123 Example St"
269278
uncheck reimbursement_checkbox
270279

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

274286
expect(case_contact.want_driving_reimbursement).to be false
275287
expect(case_contact.miles_driven).to be_zero
276288
end
277289

278-
xit "saves mileage and address information" do # TODO make test not flaky
290+
it "saves mileage and address information" do # TODO make test not flaky
279291
subject
280292
fill_in_contact_details contact_types: %w[School]
281293

@@ -284,7 +296,10 @@
284296
fill_in miles_driven_input, with: 50
285297
fill_in volunteer_address_input, with: "123 Example St"
286298

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

290305
expect(case_contact.want_driving_reimbursement).to be true
@@ -310,8 +325,10 @@
310325

311326
check reimbursement_checkbox
312327

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")
328+
expect {
329+
click_on "Submit"
330+
expect(page).to have_text("Must enter a valid mailing address for the reimbursement")
331+
}.not_to change(CaseContact.active, :count)
315332
expect(page).to have_text("Must enter miles driven to receive driving reimbursement")
316333
end
317334

@@ -391,7 +408,10 @@
391408
)
392409

393410
check "Create Another"
394-
expect { click_on "Submit" }
411+
expect {
412+
click_on "Submit"
413+
expect(page).to have_text "Case contact successfully created."
414+
}
395415
.to change(CaseContact, :count).by(1)
396416
# .to change(CaseContact.active, :count).by(1)
397417
# .and change(CaseContact.started, :count).by(1)
@@ -441,6 +461,7 @@
441461
it "redirects to the new CaseContact form with the same cases selected" do
442462
expect {
443463
visit new_case_contact_path(casa_case, {draft_case_ids:})
464+
expect(page).to have_content("Record New Case Contact")
444465
}.to change(CaseContact.started, :count).by(1)
445466
this_case_contact = CaseContact.started.last
446467

@@ -452,6 +473,7 @@
452473

453474
expect {
454475
click_on "Submit"
476+
expect(page).to have_text "Case contacts successfully created."
455477
}.to change(CaseContact.active, :count).by(2)
456478

457479
expect(page).to have_text "New Case Contact"
@@ -516,6 +538,7 @@
516538

517539
expect {
518540
click_on "Submit"
541+
expect(page).to have_text "Case contact successfully created."
519542
}.to change(CaseContact.active, :count).by(1)
520543
contact = CaseContact.active.last
521544
expect(contact.casa_case_id).to eq casa_case.id

0 commit comments

Comments
 (0)