Skip to content

Commit 17be151

Browse files
committed
Fix flaky capy tests that weren't waiting for an action to finish
1 parent b5a8d74 commit 17be151

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

spec/system/banners/new_spec.rb

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@
1515
check "Active?"
1616
fill_in_rich_text_area "banner_content", with: "Please fill out this survey."
1717
click_on "Submit"
18-
19-
visit banners_path
18+
expect(page).to have_current_path(banners_path)
2019
expect(page).to have_text("Volunteer Survey Announcement")
2120

22-
visit banners_path
2321
within "#banners" do
2422
click_on "Edit", match: :first
2523
end
2624
fill_in "Name", with: "Better Volunteer Survey Announcement"
2725
click_on "Submit"
2826

29-
visit banners_path
27+
expect(page).to have_current_path(banners_path)
3028
expect(page).to have_text("Better Volunteer Survey Announcement")
3129

3230
visit root_path
@@ -44,17 +42,14 @@
4442
fill_in_rich_text_area "banner_content", with: "Please fill out this survey."
4543
click_on "Submit"
4644

47-
visit banners_path
45+
expect(page).to have_current_path(banners_path)
4846
expect(page).to have_text("Expiring Announcement")
49-
50-
visit banners_path
5147
within "#banners" do
5248
click_on "Edit", match: :first
5349
end
5450
fill_in "banner_expires_at", with: 2.days.from_now.strftime("%m%d%Y\t%I%M%P")
5551
click_on "Submit"
56-
57-
visit banners_path
52+
expect(page).to have_current_path(banners_path)
5853
expect(page).to have_text("Expiring Announcement")
5954

6055
visit root_path
@@ -71,7 +66,7 @@
7166
fill_in_rich_text_area "banner_content", with: "Please fill out this survey."
7267
click_on "Submit"
7368

74-
visit banners_path
69+
expect(page).to have_current_path(new_banner_path)
7570
expect(page).not_to have_text("Announcement not created")
7671
end
7772

@@ -93,8 +88,8 @@
9388
check "Active?"
9489
fill_in_rich_text_area "banner_content", with: "New active banner content."
9590
click_on "Submit"
91+
expect(page).to have_current_path(banners_path)
9692

97-
visit banners_path
9893
within("table#banners") do
9994
already_existing_banner_row = find("tr", text: active_banner.name)
10095

@@ -118,7 +113,7 @@
118113
fill_in_rich_text_area "banner_content", with: "New active banner content."
119114
click_on "Submit"
120115

121-
visit banners_path
116+
expect(page).to have_current_path(banners_path)
122117

123118
within("table#banners") do
124119
already_existing_banner_row = find("tr", text: active_banner.name)

spec/system/bulk_court_dates/new_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
within ".top-page-actions" do
3737
click_on "Create"
3838
end
39+
expect(page).to have_current_path(new_bulk_court_date_path)
3940

4041
visit casa_case_path(casa_case)
4142
expect(page).to have_content(hearing_type.name)

spec/system/case_contacts/additional_expenses_spec.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,19 @@
4949
fill_expense_fields 5.34, "Lunch"
5050
uncheck "Request travel or other reimbursement"
5151

52-
expect { click_on "Submit" }
53-
.to change(CaseContact.active, :count).by(1)
52+
expect do
53+
click_on "Submit"
54+
55+
expect(page).to have_text("Case contact successfully created.")
56+
end.to change(CaseContact.active, :count).by(1)
5457

5558
case_contact = CaseContact.active.last
5659
expect(case_contact.additional_expenses).to be_empty
5760
expect(case_contact.miles_driven).to be_zero
5861
expect(case_contact.want_driving_reimbursement).to be false
5962
end
6063

61-
# TODO: Fix this test
62-
xit "can remove an expense" do
64+
it "can remove an expense" do
6365
subject
6466
fill_in_contact_details
6567
check "Request travel or other reimbursement"
@@ -81,6 +83,7 @@
8183
expect(page).to have_field(class: "expense-amount-input", count: 2)
8284

8385
click_on "Submit"
86+
expect(page).to have_text('Case contact successfully created.')
8487
}
8588
.to change(CaseContact.active, :count).by(1)
8689
.and change(AdditionalExpense, :count).by(2)

0 commit comments

Comments
 (0)