Skip to content

Commit

Permalink
Merge pull request #5870 from SuperGoodSoft/issue-5614/store-filter-o…
Browse files Browse the repository at this point in the history
…n-order-index

Add filtering by store to orders index component
  • Loading branch information
MadelineCollier authored Oct 16, 2024
2 parents c78a9de + 7597004 commit c3fea3e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
7 changes: 7 additions & 0 deletions admin/app/components/solidus_admin/orders/index/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ def filters
option
]
end
},
{
label: t('.filters.store'),
combinator: 'or',
attribute: "store_id",
predicate: "eq",
options: Spree::Store.all.pluck(:name, :id)
}
]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ en:
other: '%{count} Items'
filters:
status: Status
store: Store
shipment_state: Shipment State
payment_state: Payment State
promotions: Promotions
Expand Down
29 changes: 28 additions & 1 deletion admin/spec/features/orders/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe "Orders", type: :feature do
before { sign_in create(:admin_user, email: '[email protected]') }

it "lists products", :js do
it "lists orders", :js do
create(:order, number: "R123456789", total: 19.99)

visit "/admin/orders"
Expand All @@ -15,4 +15,31 @@
expect(page).to have_content("$19.99")
expect(page).to be_axe_clean
end

context "with multiple stores", :js do
let!(:order_in_default_store) { create :order }
let(:another_store) { create :store, name: "Another Store" }
let!(:order_in_another_store) { create :order, store: another_store }

it "can filter orders by store" do
visit solidus_admin.orders_path

click_on "In Progress"

expect(page).to have_content(order_in_default_store.number)
expect(page).to have_content(order_in_another_store.number)

click_on "Filter"

within("div[role='search']") do
find('details', text: "Store").click
expect(page).to have_content("Another Store")

find('label', text: "Another Store").click
end

expect(page).to have_content(order_in_another_store.number)
expect(page).to_not have_content(order_in_default_store.number)
end
end
end

0 comments on commit c3fea3e

Please sign in to comment.