haya_select_helpers 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf6acdffd9a4d2e98a8745622eb27cb59fad687a26314dfd08527df0de461af2
4
- data.tar.gz: 4f29d9bb7ac705fa10ab7a6f101c3b056037cc0c1e2fe98ec0b89d850d87180e
3
+ metadata.gz: 0a2a0808c53f9adebdb42fa32100fbb8152a3b701fbca486cb3d116849306f1e
4
+ data.tar.gz: 2e0cd08fc49c9105a0c84d8469e6dd1f5eea928261b3bed299d8bb3848f6d70b
5
5
  SHA512:
6
- metadata.gz: a3ca2d3a43fa0657ed05729f478af7389509c1169e9cbdf062bec578ee0da78a69cf0287f748b55b4e6fe1633d2d640a424459bc54b6bf8c2d7d4000835f3c33
7
- data.tar.gz: d27f8fe5d9b66fcd54539b069caceee820b58760e93b044a8605cfe8013c3f1bb370b980a7128a316ab764fbf574f18022b2f64c5888747afddfad9ddd25138f
6
+ metadata.gz: '08e3d969f7b4a1c460c43c152a9d28f9457bc494cae12d6a966dfe6a36db48494f5b3315d1fb2b39d2fcbb37b2b68163c5cb1d9d7ae50efdaca06a061d4f24a8'
7
+ data.tar.gz: 5350a18c9c7eeb346ef151f2002583be8ce5f680b76b0c11854398bce565995886f73b8f573622d9bb16c88895cda5538cbfd34607800344d32fe4e971058fcc
data/lib/haya_select.rb CHANGED
@@ -4,21 +4,21 @@ class HayaSelect
4
4
  delegate :all, :expect, :eq, :pretty_html, :wait_for_and_find, :wait_for_expect, :wait_for_no_selector, :wait_for_selector, to: :scope
5
5
 
6
6
  def initialize(id:, scope:)
7
- @base_selector = ".haya-select[data-id='#{id}']"
8
- @not_opened_current_selected_selector = "#{base_selector}[data-opened='false'] .haya-select-current-selected"
9
- @opened_current_selected_selector = "#{base_selector}[data-opened='true'] .haya-select-current-selected"
10
- @options_selector = ".haya-select-options-container[data-id='#{id}']"
7
+ @base_selector = "[data-component='haya-select'][data-id='#{id}']"
8
+ @not_opened_current_selected_selector = "#{base_selector}[data-opened='false'] [data-class='current-selected']"
9
+ @opened_current_selected_selector = "#{base_selector}[data-opened='true'] [data-class='current-selected']"
10
+ @options_selector = "[data-class='options-container'][data-id='#{id}']"
11
11
  @scope = scope
12
12
  end
13
13
 
14
14
  def label
15
- wait_for_and_find("#{base_selector} .haya-select-current-selected .current-option").text
15
+ wait_for_and_find("#{base_selector} [data-class='current-selected'] [data-class='current-option']").text
16
16
  rescue Selenium::WebDriver::Error::StaleElementReferenceError
17
17
  retry
18
18
  end
19
19
 
20
20
  def open
21
- wait_for_and_find("#{base_selector}[data-opened='false'] .haya-select-current-selected").click
21
+ wait_for_and_find("#{base_selector}[data-opened='false'] [data-class='current-selected']").click
22
22
  wait_for_selector opened_current_selected_selector
23
23
  wait_for_selector options_selector
24
24
  self
@@ -26,9 +26,15 @@ class HayaSelect
26
26
  retry
27
27
  end
28
28
 
29
+ def close
30
+ wait_for_selector opened_current_selected_selector
31
+ wait_for_and_find("[data-class='search-text-input']").click
32
+ wait_for_no_selector opened_current_selected_selector
33
+ end
34
+
29
35
  def options
30
- wait_for_selector "#{options_selector} .haya-select-option"
31
- option_elements = all("#{options_selector} .haya-select-option")
36
+ wait_for_selector "#{options_selector} [data-class='select-option']"
37
+ option_elements = all("#{options_selector} [data-class='select-option']")
32
38
  option_elements.map do |option_element|
33
39
  {
34
40
  label: option_element.text,
@@ -43,24 +49,32 @@ class HayaSelect
43
49
  wait_for_expect do
44
50
  expect(options).to eq expected_options
45
51
  end
52
+ self
46
53
  end
47
54
 
48
55
  def search(value)
49
- wait_for_and_find("#{base_selector} .haya-select-search-text-input").set(value)
56
+ wait_for_and_find("#{base_selector} [data-class='search-text-input']").set(value)
57
+ self
50
58
  rescue Selenium::WebDriver::Error::StaleElementReferenceError
51
59
  retry
52
60
  end
53
61
 
54
- def select(label)
62
+ def select(label = nil, value: nil)
55
63
  open
56
- select_option(label: label)
64
+ select_option(label:, value:)
57
65
  wait_for_selector not_opened_current_selected_selector
58
66
  wait_for_no_selector options_selector
59
67
  self
60
68
  end
61
69
 
62
- def select_option(label:)
63
- option = wait_for_and_find("#{options_selector} .haya-select-option", exact_text: label)
70
+ def select_option(label: nil, value: nil)
71
+ raise "No 'label' or 'value' given" if label.nil? && value.nil?
72
+
73
+ selector = "#{options_selector} [data-testid='option-presentation']"
74
+ selector << "[data-text='#{label}']" unless label.nil?
75
+ selector << "[data-value='#{value}']" unless value.nil?
76
+
77
+ option = wait_for_and_find(selector)
64
78
 
65
79
  raise "The '#{label}'-option is disabled" if option["data-disabled"] == "true"
66
80
 
@@ -71,18 +85,18 @@ class HayaSelect
71
85
  end
72
86
 
73
87
  def value
74
- wait_for_and_find("#{base_selector} .haya-select-current-selected input[type='hidden']", visible: false)[:value]
88
+ wait_for_and_find("#{base_selector} [data-class='current-selected'] input[type='hidden']", visible: false)[:value]
75
89
  rescue Selenium::WebDriver::Error::StaleElementReferenceError
76
90
  retry
77
91
  end
78
92
 
79
93
  def wait_for_label(expected_label)
80
- wait_for_selector "#{base_selector} .haya-select-current-selected .current-option", exact_text: expected_label
94
+ wait_for_selector "#{base_selector} [data-class='current-selected'] [data-class='current-option']", exact_text: expected_label
81
95
  self
82
96
  end
83
97
 
84
98
  def toggles
85
- all("#{base_selector} .haya-select-option-presentation").map do |element|
99
+ all("#{base_selector} [data-testid='option-presentation']").map do |element|
86
100
  {
87
101
  toggle_icon: element["data-toggle-icon"],
88
102
  toggle_value: element["data-toggle-value"],
@@ -93,14 +107,25 @@ class HayaSelect
93
107
  retry
94
108
  end
95
109
 
110
+ def selected_option_values
111
+ all("[data-class='select-option'][data-selected='true']").map { |select_option_element| select_option_element["data-value"] }
112
+ end
113
+
114
+ def wait_for_selected_option_values(values)
115
+ wait_for_expect do
116
+ expect(selected_option_values).to eq values
117
+ end
118
+ end
119
+
96
120
  def wait_for_toggles(expected_toggles)
97
121
  wait_for_expect do
98
122
  expect(toggles).to eq expected_toggles
99
123
  end
124
+ self
100
125
  end
101
126
 
102
127
  def wait_for_value(expected_value)
103
- wait_for_selector "#{base_selector} .haya-select-current-selected input[type='hidden'][value='#{expected_value}']", visible: false
128
+ wait_for_selector "#{base_selector} [data-class='current-selected'] input[type='hidden'][value='#{expected_value}']", visible: false
104
129
  self
105
130
  end
106
131
  end
@@ -1,3 +1,3 @@
1
1
  module HayaSelectHelpers
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haya_select_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-15 00:00:00.000000000 Z
11
+ date: 2026-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubygems_version: 3.4.10
70
+ rubygems_version: 3.3.7
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: RSpec helpers for HayaSelect.