Skip to content

Commit aca21dd

Browse files
committed
Update few specs with missing tests
1 parent fccf125 commit aca21dd

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
@@ -49,6 +49,12 @@ def checkbox(locator)
4949
def selected_option(select_locator)
5050
find(:select, select_locator).find(:option, selected: true)
5151
end
52+
53+
def clear_search
54+
within('div[role="search"]') do
55+
find('button[aria-label="Clear"]').click
56+
end
57+
end
5258
end
5359
end
5460
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
@@ -22,7 +22,7 @@
2222
end
2323

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

2727
before do
2828
visit "/admin/refund_reasons/#{query}"
@@ -44,10 +44,13 @@
4444
context "with valid data" do
4545
it "successfully creates a new refund reason, keeping page and q params" do
4646
fill_in "Name", with: "Return process"
47+
uncheck "Active"
4748

4849
click_on "Add Refund Reason"
4950

5051
expect(page).to have_content("Refund reason was successfully created.")
52+
click_on "Return process"
53+
expect(checkbox("Active")).not_to be_checked
5154
expect(Spree::RefundReason.find_by(name: "Return process")).to be_present
5255
expect(page.current_url).to include(query)
5356
end
@@ -64,10 +67,10 @@
6467
end
6568

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

6972
before do
70-
Spree::RefundReason.create(name: "Return process")
73+
Spree::RefundReason.create(name: "Return process", active: false)
7174
visit "/admin/refund_reasons#{query}"
7275
click_on "Return process"
7376
expect(page).to have_css("dialog")
@@ -86,13 +89,20 @@
8689

8790
it "successfully updates the existing refund reason" do
8891
fill_in "Name", with: "Customer complaint"
89-
92+
check "Active"
9093
click_on "Update Refund Reason"
94+
95+
expect(page.current_url).to include(query)
9196
expect(page).to have_content("Refund reason was successfully updated.")
97+
expect(page).to have_content("No Refund Reasons found") # search query still applied, filters out updated name
98+
clear_search
99+
92100
expect(page).to have_content("Customer complaint")
93101
expect(page).not_to have_content("Return process")
102+
103+
click_on "Customer complaint"
104+
expect(checkbox("Active")).to be_checked
94105
expect(Spree::RefundReason.find_by(name: "Customer complaint")).to be_present
95-
expect(page.current_url).to include(query)
96106
end
97107
end
98108
end

admin/spec/features/tax_categories_spec.rb

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

5051
click_on "Add Tax Category"
5152

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

0 commit comments

Comments
 (0)