From 7e168fad0251bc56b409ce15e558e7cfc5bfbebc Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 19 Sep 2022 13:44:22 +0100 Subject: [PATCH] Spec reproduing failing customer query, as superadmin --- spec/system/admin/order_spec.rb | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index bc68f00ac6..ab23c34346 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -710,4 +710,54 @@ describe ' expect(o.order_cycle).to eq order_cycle1 end end + + describe "searching customers" do + def serching_for_customers + # opens the customer dropdown + find(".items-placeholder").click + + # sets the query name + find(".dropdown-input").set("John") + within(".customer-details") do + expect(page).to have_content("John Doe") + expect(page).to have_content(customer.email.to_s) + end + + # sets the query email + find(".dropdown-input").set("maura@smith.biz") + within(".customer-details") do + expect(page).to have_content("John Doe") + expect(page).to have_content(customer.email.to_s) + end + end + + context "as the enterprise owner" do + before do + product.variants.first.update(on_demand: false, on_hand: 0) + + login_as user + new_order_with_distribution(distributor, order_cycle) + expect(page).to have_selector 'h1', text: "Customer Details" + end + + it "finds a customer by name" do + serching_for_customers + end + end + + context "as superadmin" do + before do + product.variants.first.update(on_demand: false, on_hand: 0) + + login_as_admin + new_order_with_distribution(distributor, order_cycle) + expect(page).to have_selector 'h1', text: "Customer Details" + end + + it "finds a customer by name" do + pending("issue #9684") + serching_for_customers + end + end + end end