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.
This commit is contained in:
Gaetan Craig-Riou
2024-01-08 14:44:36 +11:00
committed by Gaetan Craig-Riou
parent cd9c505c6b
commit 270a310e0f
2 changed files with 7 additions and 8 deletions

View File

@@ -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

View File

@@ -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