Skip to content

Commit 27c64c7

Browse files
authored
Merge pull request #5993 from tvdeyen/harden-admin-feature-specs
test: Wait for modal to open before testing its content
2 parents ad84609 + 7112488 commit 27c64c7

File tree

10 files changed

+39
-39
lines changed

10 files changed

+39
-39
lines changed

admin/spec/features/adjustment_reasons_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
before do
2727
visit "/admin/adjustment_reasons#{query}"
2828
click_on "Add new"
29+
expect(page).to have_selector("dialog")
2930
expect(page).to have_content("New Adjustment Reason")
3031
expect(page).to be_axe_clean
3132
end
3233

33-
it "opens a modal" do
34-
expect(page).to have_selector("dialog")
34+
it "closing the modal keeps query params" do
3535
within("dialog") { click_on "Cancel" }
3636
expect(page).not_to have_selector("dialog")
3737
expect(page.current_url).to include(query)
@@ -69,12 +69,12 @@
6969
Spree::AdjustmentReason.create(name: "Good Reason", code: 5999)
7070
visit "/admin/adjustment_reasons#{query}"
7171
find_row("Good Reason").click
72+
expect(page).to have_selector("dialog")
7273
expect(page).to have_content("Edit Adjustment Reason")
7374
expect(page).to be_axe_clean
7475
end
7576

76-
it "opens a modal" do
77-
expect(page).to have_selector("dialog")
77+
it "closing the modal keeps query params" do
7878
within("dialog") { click_on "Cancel" }
7979
expect(page).not_to have_selector("dialog")
8080
expect(page.current_url).to include(query)

admin/spec/features/orders/show_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
expect(page).to have_content("Order R123456789")
4949
open_customer_menu
5050
click_on "Edit billing address"
51-
expect(page).to have_css("dialog", wait: 30)
51+
expect(page).to have_css("dialog", wait: 5)
5252

5353
within("dialog") do
5454
fill_in "Name", with: "John Doe"
@@ -74,7 +74,7 @@
7474

7575
open_customer_menu
7676
click_on "Edit shipping address"
77-
expect(page).to have_css("dialog", wait: 30)
77+
expect(page).to have_css("dialog", wait: 5)
7878

7979
within("dialog") do
8080
fill_in "Name", with: "Jane Doe"
@@ -119,18 +119,18 @@
119119
expect(Spree::Order.last.line_items.count).to eq(0)
120120

121121
find("[aria-selected]", text: "Just another product").click
122-
expect(page).to have_content("Variant added to cart successfully", wait: 30)
122+
expect(page).to have_content("Variant added to cart successfully", wait: 5)
123123

124124
expect(Spree::Order.last.line_items.count).to eq(1)
125125
expect(Spree::Order.last.line_items.last.quantity).to eq(1)
126126

127127
fill_in "line_item[quantity]", with: 4
128-
expect(page).to have_content("Quantity updated successfully", wait: 30)
128+
expect(page).to have_content("Quantity updated successfully", wait: 5)
129129

130130
expect(Spree::Order.last.line_items.last.quantity).to eq(4)
131131

132132
accept_confirm("Are you sure?") { click_on "Delete" }
133-
expect(page).to have_content("Line item removed successfully", wait: 30)
133+
expect(page).to have_content("Line item removed successfully", wait: 5)
134134

135135
expect(Spree::Order.last.line_items.count).to eq(0)
136136
expect(page).to be_axe_clean

admin/spec/features/refund_reasons_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
before do
2727
visit "/admin/refund_reasons/#{query}"
2828
click_on "Add new"
29+
expect(page).to have_selector("dialog")
2930
expect(page).to have_content("New Refund Reason")
3031
expect(page).to be_axe_clean
3132
end
3233

33-
it "opens a modal" do
34-
expect(page).to have_selector("dialog")
34+
it "closing the modal keeps query params" do
3535
within("dialog") { click_on "Cancel" }
3636
expect(page).not_to have_selector("dialog")
3737
expect(page.current_url).to include(query)
@@ -66,12 +66,12 @@
6666
Spree::RefundReason.create(name: "Return process")
6767
visit "/admin/refund_reasons#{query}"
6868
find_row("Return process").click
69+
expect(page).to have_selector("dialog")
6970
expect(page).to have_content("Edit Refund Reason")
7071
expect(page).to be_axe_clean
7172
end
7273

73-
it "opens a modal" do
74-
expect(page).to have_selector("dialog")
74+
it "closing the modal keeps query params" do
7575
within("dialog") { click_on "Cancel" }
7676
expect(page).not_to have_selector("dialog")
7777
expect(page.current_url).to include(query)

admin/spec/features/return_reasons_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
before do
2727
visit "/admin/return_reasons#{query}"
2828
click_on "Add new"
29+
expect(page).to have_selector("dialog")
2930
expect(page).to have_content("New Return Reason")
3031
expect(page).to be_axe_clean
3132
end
3233

33-
it "opens a modal" do
34-
expect(page).to have_selector("dialog")
34+
it "closing the modal keeps query params" do
3535
within("dialog") { click_on "Cancel" }
3636
expect(page).not_to have_selector("dialog")
3737
expect(page.current_url).to include(query)
@@ -68,12 +68,12 @@
6868
Spree::ReturnReason.create(name: "Good Reason")
6969
visit "/admin/return_reasons#{query}"
7070
find_row("Good Reason").click
71+
expect(page).to have_selector("dialog")
7172
expect(page).to have_content("Edit Return Reason")
7273
expect(page).to be_axe_clean
7374
end
7475

75-
it "opens a modal" do
76-
expect(page).to have_selector("dialog")
76+
it "closing the modal keeps query params" do
7777
within("dialog") { click_on "Cancel" }
7878
expect(page).not_to have_selector("dialog")
7979
expect(page.current_url).to include(query)

admin/spec/features/roles_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
before do
5555
visit "/admin/roles#{query}"
5656
click_on "Add new"
57+
expect(page).to have_selector("dialog")
5758
expect(page).to have_content("New Role")
5859
expect(page).to be_axe_clean
5960
end
6061

61-
it "opens a modal" do
62-
expect(page).to have_selector("dialog")
62+
it "closing the modal keeps query params" do
6363
within("dialog") { click_on "Cancel" }
6464
expect(page).not_to have_selector("dialog")
6565
expect(page.current_url).to include(query)
@@ -121,14 +121,14 @@
121121
Spree::Role.create(name: "Reviewer", permission_sets: [settings_edit_permission])
122122
visit "/admin/roles#{query}"
123123
find_row("Reviewer").click
124+
expect(page).to have_selector("dialog")
124125
expect(page).to have_content("Edit Role")
125126
expect(page).to be_axe_clean
126127
expect(Spree::Role.find_by(name: "Reviewer").permission_set_ids)
127128
.to contain_exactly(settings_edit_permission.id)
128129
end
129130

130-
it "opens a modal" do
131-
expect(page).to have_selector("dialog")
131+
it "closing the modal keeps query params" do
132132
within("dialog") { click_on "Cancel" }
133133
expect(page).not_to have_selector("dialog")
134134
expect(page.current_url).to include(query)

admin/spec/features/shipping_categories_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
before do
2727
visit "/admin/shipping_categories#{query}"
2828
click_on "Add new"
29+
expect(page).to have_selector("dialog")
2930
expect(page).to have_content("New Shipping Category")
3031
expect(page).to be_axe_clean
3132
end
3233

33-
it "opens a modal" do
34-
expect(page).to have_selector("dialog")
34+
it "closing the modal keeps query params" do
3535
within("dialog") { click_on "Cancel" }
3636
expect(page).not_to have_selector("dialog")
3737
expect(page.current_url).to include(query)
@@ -66,12 +66,12 @@
6666
Spree::ShippingCategory.create(name: "Letter Mail")
6767
visit "/admin/shipping_categories#{query}"
6868
find_row("Letter Mail").click
69+
expect(page).to have_selector("dialog")
6970
expect(page).to have_content("Edit Shipping Category")
7071
expect(page).to be_axe_clean
7172
end
7273

73-
it "opens a modal" do
74-
expect(page).to have_selector("dialog")
74+
it "closing the modal keeps query params" do
7575
within("dialog") { click_on "Cancel" }
7676
expect(page).not_to have_selector("dialog")
7777
expect(page.current_url).to include(query)

admin/spec/features/store_credit_reasons_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
before do
2727
visit "/admin/store_credit_reasons#{query}"
2828
click_on "Add new"
29+
expect(page).to have_selector("dialog")
2930
expect(page).to have_content("New Store Credit Reason")
3031
expect(page).to be_axe_clean
3132
end
3233

33-
it "opens a modal" do
34-
expect(page).to have_selector("dialog")
34+
it "closing the modal keeps query params" do
3535
within("dialog") { click_on "Cancel" }
3636
expect(page).not_to have_selector("dialog")
3737
expect(page.current_url).to include(query)
@@ -66,12 +66,12 @@
6666
Spree::StoreCreditReason.create(name: "New Customer Reward")
6767
visit "/admin/store_credit_reasons#{query}"
6868
find_row("New Customer Reward").click
69+
expect(page).to have_selector("dialog")
6970
expect(page).to have_content("Edit Store Credit Reason")
7071
expect(page).to be_axe_clean
7172
end
7273

73-
it "opens a modal" do
74-
expect(page).to have_selector("dialog")
74+
it "closing the modal keeps query params" do
7575
within("dialog") { click_on "Cancel" }
7676
expect(page).not_to have_selector("dialog")
7777
expect(page.current_url).to include(query)

admin/spec/features/tax_categories_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
before do
2929
visit "/admin/tax_categories#{query}"
3030
click_on "Add new"
31+
expect(page).to have_selector("dialog")
3132
expect(page).to have_content("New Tax Category")
3233
expect(page).to be_axe_clean
3334
end
3435

35-
it "opens a modal" do
36-
expect(page).to have_selector("dialog")
36+
it "closing the modal keeps query params" do
3737
within("dialog") { click_on "Cancel" }
3838
expect(page).not_to have_selector("dialog")
3939
expect(page.current_url).to include(query)

legacy_promotions/spec/features/solidus_admin/promotions_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
visit "/admin/promotions"
1515
expect(page).to have_content("My active Promotion")
1616
click_on "Draft"
17-
expect(page).to have_content("My draft Promotion", wait: 30)
17+
expect(page).to have_content("My draft Promotion", wait: 5)
1818
click_on "Future"
19-
expect(page).to have_content("My future Promotion", wait: 30)
19+
expect(page).to have_content("My future Promotion", wait: 5)
2020
click_on "Expired"
21-
expect(page).to have_content("My expired Promotion", wait: 30)
21+
expect(page).to have_content("My expired Promotion", wait: 5)
2222
click_on "All"
23-
expect(page).to have_content("My active Promotion", wait: 30)
23+
expect(page).to have_content("My active Promotion", wait: 5)
2424
expect(page).to have_content("My draft Promotion")
2525
expect(page).to have_content("My future Promotion")
2626
expect(page).to have_content("My expired Promotion")

promotions/spec/system/solidus_promotions/admin/promotions_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
visit "/admin/solidus/promotions"
1515
expect(page).to have_content("My active Promotion")
1616
click_on "Draft"
17-
expect(page).to have_content("My draft Promotion", wait: 30)
17+
expect(page).to have_content("My draft Promotion", wait: 5)
1818
click_on "Future"
19-
expect(page).to have_content("My future Promotion", wait: 30)
19+
expect(page).to have_content("My future Promotion", wait: 5)
2020
click_on "Expired"
21-
expect(page).to have_content("My expired Promotion", wait: 30)
21+
expect(page).to have_content("My expired Promotion", wait: 5)
2222
click_on "All"
23-
expect(page).to have_content("My active Promotion", wait: 30)
23+
expect(page).to have_content("My active Promotion", wait: 5)
2424
expect(page).to have_content("My draft Promotion")
2525
expect(page).to have_content("My future Promotion")
2626
expect(page).to have_content("My expired Promotion")

0 commit comments

Comments
 (0)