Module: Shoelace::Testing

Defined in:
lib/shoelace/testing.rb

Instance Method Summary collapse

Instance Method Details

#sl_check(label) ⇒ Object



32
33
34
# File 'lib/shoelace/testing.rb', line 32

def sl_check(label)
  find("sl-checkbox", text: label).click
end

#sl_multi_select(*options_to_select, from:) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shoelace/testing.rb', line 16

def sl_multi_select(*options_to_select, from: )
  select_element = find("sl-select[placeholder=\"#{from}\"]")

  select_element.click
  within select_element do
    options_to_select.each do |option_text|
      find('sl-option', text: option_text).click
    end
  end

  # The multi select does not close automatically, so need to click to close it.
  select_element.click if options_to_select.size > 1

  select_element
end

#sl_select(option_text, from:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/shoelace/testing.rb', line 5

def sl_select(option_text, from: )
  select_element = find("sl-select[placeholder=\"#{from}\"]")
  select_element.click

  within select_element do
    find('sl-option', text: option_text).click
  end

  select_element
end

#sl_toggle(label) ⇒ Object



36
37
38
# File 'lib/shoelace/testing.rb', line 36

def sl_toggle(label)
  find("sl-switch", text: label).click
end