From cd9c505c6b51aaba9fb52019b7928f2824861201 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Nov 2023 05:48:57 +0000 Subject: [PATCH 1/4] chore(deps): bump tom-select from 2.2.3 to 2.3.1 Bumps [tom-select](https://github.com/orchidjs/tom-select) from 2.2.3 to 2.3.1. - [Release notes](https://github.com/orchidjs/tom-select/releases) - [Commits](https://github.com/orchidjs/tom-select/compare/v2.2.3...v2.3.1) --- updated-dependencies: - dependency-name: tom-select dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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/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" From 270a310e0fe778142b1fdd475eb36b68acc059f0 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Mon, 8 Jan 2024 14:44:36 +1100 Subject: [PATCH 2/4] Use send_keys to populate tom select input Setting the value directly doesn't trigger the search, presumably because it doesn't trigger any javascript event. --- spec/support/request/web_helper.rb | 4 ++-- spec/system/admin/order_spec.rb | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/spec/support/request/web_helper.rb b/spec/support/request/web_helper.rb index 4e8aad2be0..e452939972 100644 --- a/spec/support/request/web_helper.rb +++ b/spec/support/request/web_helper.rb @@ -100,8 +100,8 @@ 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) - tomselect_wrapper.find(".ts-control").click + # 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 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 From 98545741e6069a2ec288552bac7de6e4e690a450 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Wed, 24 Jan 2024 14:47:21 +1100 Subject: [PATCH 3/4] Add tomselect_select helper When using `tomselect_search_and_select` and searching isn't really required it leaves the dropdown option open. It can then cause problem when trying to interact with other element in the page. This happens because clicking on the chosen option happena before the searching finishes. We can now use `tomselect_select` when searching is not actually required. It should not be a problem when search is required, as capybara will wait for the option to appear on the page before clicking. --- spec/support/request/web_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/support/request/web_helper.rb b/spec/support/request/web_helper.rb index e452939972..01a4796f4e 100644 --- a/spec/support/request/web_helper.rb +++ b/spec/support/request/web_helper.rb @@ -105,6 +105,13 @@ module WebHelper 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 + def request_monitor_finished(controller = nil) page.evaluate_script("#{angular_scope(controller)}.scope().RequestMonitor.loading == false") end From 67dc79b074f47811850ff39d8263f50b96cd72ac Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Wed, 24 Jan 2024 14:53:44 +1100 Subject: [PATCH 4/4] Replace tomselect_search_and_select by tomselect_select In these scenarios, searching for the option is not actually required, we can directly click on the needed option. It prevent issue with the dropdown option staying open and breaking specs. --- spec/system/admin/orders_spec.rb | 4 ++-- spec/system/admin/subscriptions/crud_spec.rb | 2 +- spec/system/admin/subscriptions/smoke_tests_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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