Skip to content

Commit

Permalink
Create list_form_system_test.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
nimmolo committed Aug 30, 2024
1 parent c72376a commit a39938e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/system/list_form_system_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

require("application_system_test_case")

class ListFormSystemTest < ApplicationSystemTestCase
def test_multi_autocompleter
@browser = page.driver.browser
rolf = users("rolf")
login!(rolf)

visit("/species_lists/new")
assert_selector("body.species_lists__new")
assert_field("list_members")
assert_field("list_name_id", type: :hidden)

name1 = names("coprinus_comatus")
name2 = names("agaricus_campestris")
name3 = names("stereum_hirsutum")
fill_in("list_members", with: "Agaricus campestris")
assert_field("list_name_id", with: name2.id, type: :hidden)
@browser.keyboard.type(:return)
assert_field("list_members", with: /Agaricus campestris/)
@browser.keyboard.type("Coprinus com")
assert_selector(".auto_complete") # wait
assert_selector(".auto_complete ul li a", text: "Coprinus comatus")
@browser.keyboard.type(:down, :tab)
assert_field("list_members", with: /Coprinus comatus/)
assert_field("list_name_id", with: "#{name2.id},#{name1.id}", type: :hidden)
@browser.keyboard.type(:return)
sleep(1)
@browser.keyboard.type(:return)
@browser.keyboard.type("Stereum hirs")
assert_selector(".auto_complete") # wait
assert_selector(".auto_complete ul li a", text: "Stereum hirsutum")
@browser.keyboard.type(:down, :tab)
assert_field("list_members", with: /Stereum hirsutum/)
assert_field("list_name_id", with: "#{name2.id},#{name1.id},#{name3.id}",
type: :hidden)
end
end

0 comments on commit a39938e

Please sign in to comment.