Sha256: 7b80ff1b279a06305585be32e0b95c47dfbd7adbaf3bd01d8a1d4bd477e19c02

Contents?: true

Size: 977 Bytes

Versions: 11

Compression:

Stored size: 977 Bytes

Contents

# frozen_string_literal: true

# Adapted from https://github.com/JedWatson/react-select/issues/832#issuecomment-276441836

module Capybara
  module ReactSelect
    def autocomplete_select(value, from:)
      within("div[data-autocomplete-for='#{from}']") do
        find(".Select-control").click

        find(".Select .Select-input input").native.send_keys(value[0..4])
        expect(page).to have_css(".Select-menu-outer") # select should be open now

        # This is a little funky because when the entered text forces the select to
        # wrap, it causes React to re-render.  We need to get it to re-render
        # (if needed) by hovering.
        expect(page).to have_css(".Select-option", text: value)
        find(".Select-option", text: value).hover
        expect(page).to have_css(".Select-option", text: value)
        find(".Select-option", text: value).click
        expect(page).to have_css(".Select-value-label", text: value)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-dev-0.14.4 lib/decidim/dev/test/rspec_support/react_select.rb
decidim-dev-0.14.3 lib/decidim/dev/test/rspec_support/react_select.rb
decidim-dev-0.14.2 lib/decidim/dev/test/rspec_support/react_select.rb
decidim-dev-0.14.1 lib/decidim/dev/test/rspec_support/react_select.rb
decidim-dev-0.13.1 lib/decidim/dev/test/rspec_support/react_select.rb
decidim-dev-0.12.2 lib/decidim/dev/test/rspec_support/react_select.rb
decidim-dev-0.13.0 lib/decidim/dev/test/rspec_support/react_select.rb
decidim-dev-0.12.1 lib/decidim/dev/test/rspec_support/react_select.rb
decidim-dev-0.13.0.pre1 lib/decidim/dev/test/rspec_support/react_select.rb
decidim-dev-0.12.0 lib/decidim/dev/test/rspec_support/react_select.rb
decidim-dev-0.12.0.pre lib/decidim/dev/test/rspec_support/react_select.rb