Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions spec/features/admin/tom_select_member_lookup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
scenario 'searching for members with TomSelect' do
visit admin_members_path

expect(page).to have_css('.ts-wrapper', wait: 5)
expect(page).to have_css('.ts-wrapper', wait: 15)

find('.ts-control').click
# Type in chunks to match shouldLoad (requires >= 3 chars).
find('.ts-control input').send_keys('Ja')
sleep 0.5

find('.ts-control input').send_keys('ne')

expect(page).to have_css('.ts-dropdown .option', wait: 5)
expect(page).to have_css('.ts-dropdown .option', wait: 15)

expect(page).to have_content('Jane Doe')
expect(page).to have_content('jane@example.com')
Expand All @@ -32,12 +31,12 @@
scenario 'selecting a member updates view profile link' do
visit admin_members_path

expect(page).to have_css('.ts-wrapper', wait: 5)
expect(page).to have_css('.ts-wrapper', wait: 15)

find('.ts-control').click
find('.ts-control input').send_keys('Jane Doe')

expect(page).to have_css('.ts-dropdown .option', wait: 5)
expect(page).to have_css('.ts-dropdown .option', wait: 15)

find('.ts-dropdown .option', text: 'Jane Doe').click

Expand Down
11 changes: 6 additions & 5 deletions spec/support/select_from_tom_select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ def select_from_tom_select(item_text, from: nil)
# Type first 3 characters to trigger search (shouldLoad requires >= 3)
input.send_keys(item_text[0, 3])

# Wait for debounce (300ms) and network request
sleep 0.5
# Wait for the initial search results to load after the debounce and AJAX.
# Uses Capybara's adaptive wait instead of a blind sleep so slow CI environments
# get enough time while fast environments don't waste a fixed wait.
expect(page).to have_css('.ts-dropdown .option', wait: 15)

# Type the rest if item_text is longer than 3 characters
input.send_keys(item_text[3..]) if item_text.length > 3

# Wait for results (includes debounce + network)
# Uses a generous timeout for CI environments where AJAX may be slower
expect(page).to have_css('.ts-dropdown .option', wait: 10)
# Wait for updated results after the refined search
expect(page).to have_css('.ts-dropdown .option', text: item_text, wait: 10)

# Click the matching option
# Use JavaScript click to avoid element interception issues
Expand Down