Skip to content

Commit a86eb6f

Browse files
committed
Help de-flaky some system tests
1 parent bfc28e2 commit a86eb6f

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

spec/system/banners/new_spec.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
visit banners_path
2020
expect(page).to have_text("Volunteer Survey Announcement")
2121

22-
visit banners_path
2322
within "#banners" do
2423
click_on "Edit", match: :first
2524
end
2625
fill_in "Name", with: "Better Volunteer Survey Announcement"
2726
click_on "Submit"
2827

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

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

47-
visit banners_path
48-
expect(page).to have_text("Expiring Announcement")
45+
expect(page).to have_text("Expiring Announcement Yes in 7 days")
4946

50-
visit banners_path
5147
within "#banners" do
5248
click_on "Edit", match: :first
5349
end
54-
fill_in "banner_expires_at", with: 2.days.from_now.strftime("%m%d%Y\t%I%M%P")
50+
fill_in "banner_expires_at", with: 3.days.from_now.strftime("%m%d%Y\t%I%M%P")
5551
click_on "Submit"
5652

57-
visit banners_path
58-
expect(page).to have_text("Expiring Announcement")
53+
expect(page).to have_text("Expiring Announcement Yes in 3 days")
5954

6055
visit root_path
6156
expect(page).to have_text("Please fill out this survey.")
@@ -94,7 +89,9 @@
9489
fill_in_rich_text_area "banner_content", with: "New active banner content."
9590
click_on "Submit"
9691

97-
visit banners_path
92+
# We're still on the banners page
93+
expect(page).to have_current_path(banners_path)
94+
9895
within("table#banners") do
9996
already_existing_banner_row = find("tr", text: active_banner.name)
10097

spec/system/case_contacts/additional_expenses_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@
5858
expect(case_contact.want_driving_reimbursement).to be false
5959
end
6060

61-
# TODO: Fix this test
62-
xit "can remove an expense" do
61+
it "can remove an expense" do
6362
subject
6463
fill_in_contact_details
6564
check "Request travel or other reimbursement"
@@ -81,6 +80,7 @@
8180
expect(page).to have_field(class: "expense-amount-input", count: 2)
8281

8382
click_on "Submit"
83+
expect(page).to have_text('Case contact successfully created')
8484
}
8585
.to change(CaseContact.active, :count).by(1)
8686
.and change(AdditionalExpense, :count).by(2)

spec/system/case_contacts/contact_topic_answers_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def notes_section
115115
context "when casa org has no contact topics" do
116116
let(:contact_topics) { [] }
117117

118-
xit "displays a field for contact.notes" do # TODO make test not flaky
118+
it "displays a field for contact.notes" do
119119
subject
120120
expect(page).to have_no_button "Add Another Discussion Topic"
121121
expect(notes_section).to have_field "Additional Notes"
@@ -139,7 +139,10 @@ def notes_section
139139

140140
fill_in "Additional Notes", with: "This is a fake a topic answer."
141141

142-
expect { click_on "Submit" }.to change(CaseContact.active, :count).by(1)
142+
expect do
143+
click_on "Submit"
144+
expect(page).to have_text('Case contact successfully created')
145+
end.to change(CaseContact.active, :count).by(1)
143146

144147
contact = CaseContact.active.last
145148
expect(contact.contact_topic_answers).to be_empty

spec/system/case_contacts/edit_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@
171171

172172
check "Create Another"
173173

174-
expect { click_on "Submit" }.to change(CaseContact.started, :count).by(1)
174+
expect do
175+
click_on "Submit"
176+
expect(page).to have_text("successfully updated")
177+
end.to change(CaseContact.started, :count).by(1)
175178
new_case_contact = CaseContact.last
176179
expect(new_case_contact.draft_case_ids).to match_array(case_contact_draft_ids)
177180
expect(page).to have_text "New Case Contact"

spec/system/case_groups/case_groups_spec.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@
2020

2121
click_on "Submit"
2222

23-
visit case_groups_path
24-
expect(page).to have_text("A family")
25-
2623
within "#case-groups" do
24+
expect(page).to have_text("A family")
2725
click_on "Edit", match: :first
2826
end
2927
fill_in "Name", with: "Another family"
3028
click_on "Submit"
3129

32-
visit case_groups_path
3330
expect(page).to have_text("Another family")
3431
end
3532

@@ -49,9 +46,10 @@
4946

5047
click_on "Submit"
5148

52-
visit case_groups_path
53-
expect(page).to have_text(casa_case1.case_number)
54-
expect(page).to have_text(casa_case2.case_number)
49+
list_item_text = find_all('table li').map &:text
50+
expect(list_item_text.count).to be 2
51+
expect(list_item_text[0]).to match casa_case1.case_number
52+
expect(list_item_text[1]).to match casa_case2.case_number
5553

5654
within "#case-groups" do
5755
click_on "Edit", match: :first
@@ -62,7 +60,6 @@
6260
end
6361
click_on "Submit"
6462

65-
visit case_groups_path
6663
expect(page).to have_text(casa_case1.case_number)
6764
expect(page).not_to have_text(casa_case2.case_number)
6865
end

0 commit comments

Comments
 (0)