From c569f7eb60b60c26a59cd53b3143aeae07dd0a65 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Mon, 10 Aug 2026 10:39:46 +0200 Subject: [PATCH] test: focus TomSelect input explicitly before typing --- spec/support/select_from_tom_select.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/support/select_from_tom_select.rb b/spec/support/select_from_tom_select.rb index e80ece0be..622845267 100644 --- a/spec/support/select_from_tom_select.rb +++ b/spec/support/select_from_tom_select.rb @@ -13,12 +13,17 @@ def select_from_tom_select(item_text, from:) # global. select = find("##{from}", visible: false) wrapper = select.find(:xpath, '..') + expect(wrapper).to have_css('.ts-wrapper', wait: 15) expect(wrapper).to have_css('.ts-control', wait: 15) # Open the dropdown by clicking the control wrapper.find('.ts-control').click input = wrapper.find('.ts-control input') + # Focus the input explicitly; in headless CI the click above does not always + # move focus to the textbox before we dispatch the input event. + page.execute_script('arguments[0].focus();', input.native) + # Type first 3 characters to trigger search (shouldLoad requires >= 3). # Use JS to set the value and dispatch an input event directly, instead of # send_keys (which can race with TomSelect's debounce timer in headless CI