From e4845f4165d321ae94295a50cebd7cb68a3adc29 Mon Sep 17 00:00:00 2001 From: cyrillefr Date: Mon, 20 Feb 2023 21:43:05 +0100 Subject: [PATCH] Add a spec for sorting in Bulk Order management --- .../admin/bulk_order_management_spec.rb | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/spec/system/admin/bulk_order_management_spec.rb b/spec/system/admin/bulk_order_management_spec.rb index 6118c66674..018c9ee527 100644 --- a/spec/system/admin/bulk_order_management_spec.rb +++ b/spec/system/admin/bulk_order_management_spec.rb @@ -26,17 +26,27 @@ describe ' context "displaying the list of line items" do let!(:o1) { create(:order_with_distributor, state: 'complete', shipment_state: 'ready', - completed_at: Time.zone.now ) + completed_at: Time.zone.parse('2022-05-05 15:30:45')) } let!(:o2) { create(:order_with_distributor, state: 'complete', shipment_state: 'ready', - completed_at: Time.zone.now ) + completed_at: Time.zone.parse('2022-04-26 15:10:45')) + } + let!(:o21) { + create(:order_with_distributor, state: 'complete', shipment_state: 'ready', + completed_at: Time.zone.parse('2022-08-04 09:10:45')) + } + let!(:o22) { + create(:order_with_distributor, state: 'complete', shipment_state: 'ready', + completed_at: Time.zone.parse('2022-06-07 09:10:45')) } let!(:o3) { create(:order_with_distributor, state: 'address', completed_at: nil ) } let!(:o4) { create(:order_with_distributor, state: 'complete', completed_at: Time.zone.now ) } let!(:o5) { create(:order_with_distributor, state: 'complete', completed_at: Time.zone.now ) } let!(:li1) { create(:line_item_with_shipment, order: o1) } let!(:li2) { create(:line_item_with_shipment, order: o2) } + let!(:li21) { create(:line_item_with_shipment, order: o21) } + let!(:li22) { create(:line_item_with_shipment, order: o22) } let!(:li3) { create(:line_item, order: o3 ) } let!(:li4) { create(:line_item_with_shipment, order: o4) } let!(:li5) { create(:line_item_with_shipment, order: o5) } @@ -57,6 +67,13 @@ describe ' expect(page).to have_no_selector "tr#li_#{li4.id}" expect(page).to have_no_selector "tr#li_#{li5.id}" end + + it "orders by completion date" do + find("a", text: 'COMPLETED AT').click # sets ascending ordering + expect(page).to have_content(/#{li2.product.name}.*#{li1.product.name}.*#{li22.product.name}.*#{li21.product.name}/m) + find("a", text: 'COMPLETED AT').click # sets descending ordering + expect(page).to have_content(/#{li21.product.name}.*#{li22.product.name}.*#{li1.product.name}.*#{li2.product.name}/m) + end end context "pagination" do