Module: Capybara::AutoCompleteJS

Defined in:
lib/decidim/dev/test/rspec_support/autocomplete_select.rb

Instance Method Summary collapse

Instance Method Details

#autocomplete_select(value, from:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/decidim/dev/test/rspec_support/autocomplete_select.rb', line 5

def autocomplete_select(value, from:)
  within("div[data-autocomplete-for='#{from}']") do
    find(".autocomplete-input").click
    find(".autocomplete-input").native.send_keys(value[0..4])
    expect(page).to have_css("#autoComplete_list_1") # select should be open now

    expect(page).to have_css("#autoComplete_result_0", text: value)
    find_by_id("autoComplete_result_0", text: value).hover
    expect(page).to have_css("#autoComplete_result_0", text: value)
    find_by_id("autoComplete_result_0", text: value).click
    expect(page).to have_css(".autocomplete__selected-item", text: value)
  end
end