From 1155bd42ea983f52b1c81da8fb358b244cd40af1 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 26 Jul 2023 12:08:37 +1000 Subject: [PATCH] Reflex test to reveal collation sorting varies on different OS... https://dba.stackexchange.com/questions/106964/why-is-my-postgresql-order-by-case-insensitive Uncommented, the spec fails on macOS (BSD).. but succeeds in Ubuntu (Linux). Weird. --- spec/reflexes/products_reflex_spec.rb | 28 +++++++++++++++++++ .../system/admin/products_v3/products_spec.rb | 4 +-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/spec/reflexes/products_reflex_spec.rb b/spec/reflexes/products_reflex_spec.rb index a19076a378..4b1b6a6b90 100644 --- a/spec/reflexes/products_reflex_spec.rb +++ b/spec/reflexes/products_reflex_spec.rb @@ -3,5 +3,33 @@ require "reflex_helper" describe ProductsReflex, type: :reflex do + let(:current_user) { create(:admin_user) } # todo: set up an enterprise user to test permissions + let(:context) { + { url: admin_products_v3_index_url, connection: { current_user: } } + } + before do + # activate feature toggle admin_style_v3 to use new admin interface + Flipper.enable(:admin_style_v3) + end + + describe 'fetch' do + subject{ build_reflex(method_name: :fetch, **context) } + + describe "sorting" do + let!(:product_z) { create(:simple_product, name: "Zucchini") } + # let!(:product_b) { create(:simple_product, name: "bananas") } # Fails on macOS + let!(:product_a) { create(:simple_product, name: "Apples") } + + it "Should sort products alphabetically by default" do + subject.run(:fetch) + + expect(subject.get(:products).to_a).to eq [ + product_a, + # product_b, + product_z, + ] + end + end + end end diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 915de05c64..5e97ca6910 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -24,7 +24,7 @@ describe 'As an admin, I can see the new product page' do end describe "sorting" do - let!(:product_z) { create(:simple_product, name: "Zucchini") } + let!(:product_z) { create(:simple_product, name: "zucchini") } let!(:product_a) { create(:simple_product, name: "Apples") } before do @@ -34,7 +34,7 @@ describe 'As an admin, I can see the new product page' do it "Should sort products alphabetically by default" do expect(page).to have_selector "table.products tbody tr td", text: "Apples" # other products push later one to next page - expect(page).not_to have_selector "table.products tbody tr td", text: "Zucchini" + expect(page).not_to have_selector "table.products tbody tr td", text: "zucchini" end end