From ec4dba71c2a6f7640a30bc46a71b755e07aa8dd5 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 2 Sep 2024 18:39:37 -0600 Subject: [PATCH] Adds flatpickr test --- .../reports/orders_and_distributors_spec.rb | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/spec/system/admin/reports/orders_and_distributors_spec.rb b/spec/system/admin/reports/orders_and_distributors_spec.rb index 37c3267c31..e6011a8ee5 100644 --- a/spec/system/admin/reports/orders_and_distributors_spec.rb +++ b/spec/system/admin/reports/orders_and_distributors_spec.rb @@ -73,7 +73,7 @@ RSpec.describe "Orders And Distributors" do ) # displays only orders from the hub it is managing - expect(page).to have_content(distributor.name), count: 5 + expect(page).to have_content(distributor.name, count: 6) # only sees line items from orders it manages expect(page).not_to have_content(distributor2.name) @@ -132,7 +132,33 @@ RSpec.describe "Orders And Distributors" do create(:order_ready_to_ship, distributor_id: distributor.id, completed_at: completed_at2) } - context "applying filters" do + context "applying time/date filters" do + it "is precise to time of day, not just date" do + # When I generate a customer report + # with a timeframe that includes one order but not the other + find("input.datepicker").click + select_dates_from_daterangepicker datetime_start1, datetime_end + find(".shortcut-buttons-flatpickr-button").click # closes flatpickr + + run_report + # Then I should see the rows for the first order but not the second + # One row per line item - order3 only + expect(page).to have_text(distributor.name, count: 6) + expect(page).to have_text(order3.email, count: 5) + + # setting a time interval to include both orders + find("input.datepicker").click + select_dates_from_daterangepicker datetime_start2, Time.zone.now + + run_report + # Then I should see the rows for both orders + expect(page).to have_text(distributor.name, count: 11) + expect(page).to have_text(order3.email, count: 5) + expect(page).to have_text(order4.email, count: 5) + end + end + + context "applying distributor filters" do it "displays line items from the correct distributors" do # for one distributor select2_select distributor.name, from: "q_distributor_id_in"