Skip to content

Commit c3fea3e

Browse files
Merge pull request #5870 from SuperGoodSoft/issue-5614/store-filter-on-order-index
Add filtering by store to orders index component
2 parents c78a9de + 7597004 commit c3fea3e

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

admin/app/components/solidus_admin/orders/index/component.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ def filters
7777
option
7878
]
7979
end
80+
},
81+
{
82+
label: t('.filters.store'),
83+
combinator: 'or',
84+
attribute: "store_id",
85+
predicate: "eq",
86+
options: Spree::Store.all.pluck(:name, :id)
8087
}
8188
]
8289
end

admin/app/components/solidus_admin/orders/index/component.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ en:
55
other: '%{count} Items'
66
filters:
77
status: Status
8+
store: Store
89
shipment_state: Shipment State
910
payment_state: Payment State
1011
promotions: Promotions

admin/spec/features/orders/index_spec.rb

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
describe "Orders", type: :feature do
66
before { sign_in create(:admin_user, email: '[email protected]') }
77

8-
it "lists products", :js do
8+
it "lists orders", :js do
99
create(:order, number: "R123456789", total: 19.99)
1010

1111
visit "/admin/orders"
@@ -15,4 +15,31 @@
1515
expect(page).to have_content("$19.99")
1616
expect(page).to be_axe_clean
1717
end
18+
19+
context "with multiple stores", :js do
20+
let!(:order_in_default_store) { create :order }
21+
let(:another_store) { create :store, name: "Another Store" }
22+
let!(:order_in_another_store) { create :order, store: another_store }
23+
24+
it "can filter orders by store" do
25+
visit solidus_admin.orders_path
26+
27+
click_on "In Progress"
28+
29+
expect(page).to have_content(order_in_default_store.number)
30+
expect(page).to have_content(order_in_another_store.number)
31+
32+
click_on "Filter"
33+
34+
within("div[role='search']") do
35+
find('details', text: "Store").click
36+
expect(page).to have_content("Another Store")
37+
38+
find('label', text: "Another Store").click
39+
end
40+
41+
expect(page).to have_content(order_in_another_store.number)
42+
expect(page).to_not have_content(order_in_default_store.number)
43+
end
44+
end
1845
end

0 commit comments

Comments
 (0)