Skip to content

Commit 526a065

Browse files
committed
Update few specs with missing tests
1 parent 755dbcb commit 526a065

File tree

4 files changed

+62
-5
lines changed

4 files changed

+62
-5
lines changed

admin/lib/solidus_admin/testing_support/feature_helpers.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ def checkbox(locator)
3737
def selected_option(select_locator)
3838
find(:select, select_locator).find(:option, selected: true)
3939
end
40+
41+
def clear_search
42+
within('div[role="search"]') do
43+
find('button[aria-label="Clear"]').click
44+
end
45+
end
4046
end
4147
end
4248
end

admin/spec/features/product_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@
4040
visit "/admin/products/just-a-prod"
4141

4242
fill_in "Name", with: "Just a product (updated)"
43+
uncheck 'Promotable'
4344
within('header') { click_button "Save" }
4445

4546
expect(page).to have_content("Just a product (updated)")
47+
expect(checkbox("Promotable")).not_to be_checked
48+
4649
fill_in "Name", with: ""
4750
within('header') { click_button "Save" }
4851

admin/spec/features/refund_reasons_spec.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
end
2828

2929
context "when creating a new refund reason" do
30-
let(:query) { "?page=1&q%5Bname_or_description_cont%5D=Ret" }
30+
let(:query) { "?page=1&q%5Bname_or_code_cont%5D=Ret" }
3131

3232
before do
3333
visit "/admin/refund_reasons/#{query}"
@@ -46,10 +46,13 @@
4646
context "with valid data" do
4747
it "successfully creates a new refund reason, keeping page and q params" do
4848
fill_in "Name", with: "Return process"
49+
uncheck "Active"
4950

5051
click_on "Add Refund Reason"
5152

5253
expect(page).to have_content("Refund reason was successfully created.")
54+
click_on "Return process"
55+
expect(checkbox("Active")).not_to be_checked
5356
expect(Spree::RefundReason.find_by(name: "Return process")).to be_present
5457
expect(page.current_url).to include(query)
5558
end
@@ -66,10 +69,10 @@
6669
end
6770

6871
context "when editing an existing refund reason" do
69-
let(:query) { "?page=1&q%5Bname_or_description_cont%5D=Ret" }
72+
let(:query) { "?page=1&q%5Bname_or_code_cont%5D=Ret" }
7073

7174
before do
72-
Spree::RefundReason.create(name: "Return process")
75+
Spree::RefundReason.create(name: "Return process", active: false)
7376
visit "/admin/refund_reasons#{query}"
7477
click_on "Return process"
7578
expect(page).to have_css("dialog")
@@ -85,13 +88,20 @@
8588

8689
it "successfully updates the existing refund reason" do
8790
fill_in "Name", with: "Customer complaint"
88-
91+
check "Active"
8992
click_on "Update Refund Reason"
93+
94+
expect(page.current_url).to include(query)
9095
expect(page).to have_content("Refund reason was successfully updated.")
96+
expect(page).to have_content("No Refund Reasons found") # search query still applied, filters out updated name
97+
clear_search
98+
9199
expect(page).to have_content("Customer complaint")
92100
expect(page).not_to have_content("Return process")
101+
102+
click_on "Customer complaint"
103+
expect(checkbox("Active")).to be_checked
93104
expect(Spree::RefundReason.find_by(name: "Customer complaint")).to be_present
94-
expect(page.current_url).to include(query)
95105
end
96106
end
97107
end

admin/spec/features/tax_categories_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@
4848
context "with valid data" do
4949
it "successfully creates a new tax category, keeping page and q params" do
5050
fill_in "Name", with: "Clothing"
51+
check "Default"
5152

5253
click_on "Add Tax Category"
5354

5455
expect(page).to have_content("Tax category was successfully created.")
56+
click_on "Clothing"
57+
expect(checkbox("Default")).to be_checked
5558
expect(Spree::TaxCategory.find_by(name: "Clothing")).to be_present
5659
expect(page.current_url).to include(query)
5760
end
@@ -66,4 +69,39 @@
6669
end
6770
end
6871
end
72+
73+
context "when editing an existing tax category" do
74+
let(:query) { "?page=1&q%5Bname_or_description_cont%5D=Cloth" }
75+
76+
before do
77+
Spree::TaxCategory.create(name: "Clothing", is_default: true)
78+
visit "/admin/tax_categories#{query}"
79+
click_on "Clothing"
80+
expect(page).to have_css("dialog")
81+
expect(page).to have_content("Edit Tax Category")
82+
expect(page).to be_axe_clean
83+
end
84+
85+
it "closing the modal keeps query params" do
86+
within("dialog") { click_on "Cancel" }
87+
expect(page).not_to have_selector("dialog")
88+
expect(page.current_url).to include(query)
89+
end
90+
91+
it "successfully updates the existing tax category" do
92+
fill_in "Name", with: "Other"
93+
uncheck "Default"
94+
click_on "Update Tax Category"
95+
96+
expect(page.current_url).to include(query)
97+
expect(page).to have_content("Tax category was successfully updated.")
98+
expect(page).to have_content("No Tax Categories found") # search query still applied, filters out updated name
99+
clear_search
100+
101+
expect(page).to have_content("Other")
102+
expect(page).not_to have_content("Clothing")
103+
click_on "Other"
104+
expect(checkbox("Default")).not_to be_checked
105+
end
106+
end
69107
end

0 commit comments

Comments
 (0)