Skip to content

Commit

Permalink
Merge pull request #11121 from filipefurtad0/cart_state_orders_not_ap…
Browse files Browse the repository at this point in the history
…pearing_orders_page

Cart state orders not appearing orders page
  • Loading branch information
rioug authored Jul 6, 2023
2 parents eb71c65 + e547e73 commit fb3c99e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
26 changes: 22 additions & 4 deletions spec/requests/api/orders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
}
let!(:li4) { create(:line_item_with_shipment, order: order_dist_1_credit_owed) }

let!(:order_empty) {
create(:order_with_line_items, line_items_count: 0)
}

let(:user) { order_dist_1.distributor.owner }
let(:'X-Spree-Token') do
user.generate_api_key
Expand Down Expand Up @@ -153,6 +149,28 @@
expect(orders.first["id"]).to eq order_dist_2.id
end
end

context "and queried by cart state" do
let!(:order_empty) {
create(:order_with_line_items, line_items_count: 0)
}

let!(:order_not_empty) {
create(:order_with_line_items, line_items_count: 1)
}

let!(:order_not_empty_no_address) {
create(:order_with_line_items, line_items_count: 1, bill_address_id: nil, ship_address_id: nil)
}

let(:'q[state_eq]') { "cart" }

run_test! do |response|
data = JSON.parse(response.body)
orders = data["orders"]
expect(orders.size).to eq 3
end
end
end
end
end
Expand Down
40 changes: 40 additions & 0 deletions spec/system/admin/orders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,46 @@
end
end

context "cart orders" do
let!(:order_empty) {
create(:order_with_line_items, user: customer2, distributor: distributor2,
line_items_count: 0)
}

let!(:order_not_empty) {
create(:order_with_line_items, user: customer2, distributor: distributor2,
line_items_count: 1)
}

let!(:order_not_empty_no_address) {
create(:order_with_line_items, line_items_count: 1, user: customer2,
distributor: distributor2, bill_address_id: nil, ship_address_id: nil)
}

before do
login_as_admin
visit spree.admin_orders_path
uncheck 'Only show complete orders'
tomselect_search_and_select "cart", from: 'q[state_eq]'
page.find('.filter-actions .button[type=submit]').click
end

it "displays non-empty cart orders" do
pending "issue #11120"

# empty cart order does not appear in the results
expect(page).not_to have_content order_empty.number

# non-empty cart order, with bill- and ship-address appear in the results
expect(page).to have_content order_not_empty.number

# non-empty cart order, with no with bill- and ship-address appear in the results

# pending issue #11120
expect(page).to have_content order_not_empty_no_address.number
end
end

describe "ordering" do
context "orders with different completion dates" do
before do
Expand Down

0 comments on commit fb3c99e

Please sign in to comment.