diff --git a/package.json b/package.json index c9bec5f193..a9b2f6a515 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "stimulus": "^3.2.2", "stimulus-flatpickr": "^1.4.0", "stimulus_reflex": "3.5.0-rc3", - "tom-select": "^2.2.3", + "tom-select": "^2.3.1", "trix": "^2.0.8", "webpack": "~4" }, diff --git a/spec/support/request/web_helper.rb b/spec/support/request/web_helper.rb index 4e8aad2be0..01a4796f4e 100644 --- a/spec/support/request/web_helper.rb +++ b/spec/support/request/web_helper.rb @@ -100,8 +100,15 @@ module WebHelper def tomselect_search_and_select(value, options) tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper") tomselect_wrapper.find(".ts-control").click - tomselect_wrapper.find(:css, '.ts-dropdown input.dropdown-input').set(value) + # Use send_keys as setting the value directly doesn't trigger the search + tomselect_wrapper.find(:css, '.ts-dropdown input.dropdown-input').send_keys(value) + tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click + end + + def tomselect_select(value, options) + tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper") tomselect_wrapper.find(".ts-control").click + tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click end diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 379bd88e8f..4c5b677983 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -1074,19 +1074,18 @@ describe ' end describe "searching customers" do - def serching_for_customers + def searching_for_customers # opens the customer dropdown find(".items-placeholder").click - # sets the query name - find(".dropdown-input").set("John") + find(".dropdown-input").send_keys("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") + find(".dropdown-input").send_keys("maura@smith.biz") within(".customer-details") do expect(page).to have_content("John Doe") expect(page).to have_content(customer.email.to_s) @@ -1103,7 +1102,7 @@ describe ' end it "finds a customer by name" do - serching_for_customers + searching_for_customers end end @@ -1117,7 +1116,7 @@ describe ' end it "finds a customer by name" do - serching_for_customers + searching_for_customers end end end diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index 41858b9e1e..b9f29d296b 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -934,8 +934,8 @@ describe ' fill_in "Order number", with: "R123456" tomselect_multiselect order_cycle.name, from: 'q[order_cycle_id_in][]' tomselect_multiselect distributor.name, from: 'q[distributor_id_in][]' - tomselect_search_and_select shipping_method.name, from: 'shipping_method_id' - tomselect_search_and_select "complete", from: 'q[state_eq]' + tomselect_select shipping_method.name, from: 'shipping_method_id' + tomselect_select "complete", from: 'q[state_eq]' fill_in "Email", with: user.email fill_in "First name begins with", with: "J" fill_in "Last name begins with", with: "D" diff --git a/spec/system/admin/subscriptions/crud_spec.rb b/spec/system/admin/subscriptions/crud_spec.rb index 274ecf823d..cb4c901639 100644 --- a/spec/system/admin/subscriptions/crud_spec.rb +++ b/spec/system/admin/subscriptions/crud_spec.rb @@ -233,7 +233,7 @@ describe 'Subscriptions' do before do visit admin_subscriptions_path page.find("#new-subscription").click - tomselect_search_and_select shop.name, from: "subscription[shop_id]" + tomselect_select shop.name, from: "subscription[shop_id]" click_button "Continue" end diff --git a/spec/system/admin/subscriptions/smoke_tests_spec.rb b/spec/system/admin/subscriptions/smoke_tests_spec.rb index cfd1e7a2a4..86ab504a4b 100644 --- a/spec/system/admin/subscriptions/smoke_tests_spec.rb +++ b/spec/system/admin/subscriptions/smoke_tests_spec.rb @@ -183,7 +183,7 @@ describe 'Subscriptions' do before do visit admin_subscriptions_path page.find("#new-subscription").click - tomselect_search_and_select shop.name, from: "subscription[shop_id]" + tomselect_select shop.name, from: "subscription[shop_id]" click_button "Continue" end diff --git a/yarn.lock b/yarn.lock index e104a0e578..c4c2abbc97 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8768,10 +8768,10 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== -tom-select@^2.2.3: - version "2.2.3" - resolved "https://registry.yarnpkg.com/tom-select/-/tom-select-2.2.3.tgz#858acca2dcec1dbe1a94a3f4c944384e166a4f40" - integrity sha512-VMhRdFlugLGdnNZsP5r8sHKtyvWekIbtr53uoKONMzM+JSBWgy5pV9F+iZ2LTEbzIQI0efIwZ7I6h+wzZoM/zQ== +tom-select@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/tom-select/-/tom-select-2.3.1.tgz#df338d9082874cd0bceb3bee87ed0184447c47f1" + integrity sha512-QS4vnOcB6StNGqX4sGboGXL2fkhBF2gIBB+8Hwv30FZXYPn0CyYO8kkdATRvwfCTThxiR4WcXwKJZ3cOmtI9eg== dependencies: "@orchidjs/sifter" "^1.0.3" "@orchidjs/unicode-variants" "^1.0.4"