formatic 1.0.3 → 1.0.4
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/formatic/testing/search.rb +35 -9
- data/lib/formatic/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7af22aa2b9a0b0f1c08544a87127b14dfc941adc37394091ddf8af2e776b66ec
|
|
4
|
+
data.tar.gz: 6e06db902597c3ba6ad82977a02f8991d90cc2412250f70d7fb7d07e1fe590f0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4a0615255123699957ce1b08a0e65349ad276c1d5ebd1aaf10b641ee9fc996b57b147acf4730e985b8d9e4f51d308e77c54dcfc2bf06352cce6d03a76f2e5be
|
|
7
|
+
data.tar.gz: b7473fd62e049f5e5e22a656bdade50c135c41f84eebba1d63c689f29064f3ce7108cfd4e61b4c6d3745850122f344c1aac2f9a1e1bff14d958d66ee990a6434
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## [1.0.4] - 2026-11-12
|
|
2
|
+
|
|
3
|
+
- Rack test `search` helper clears the `Formatic::Search` field on a blank query (`search '', from: 'Customer'`)
|
|
4
|
+
|
|
1
5
|
## [1.0.3] - 2026-11-11
|
|
2
6
|
|
|
3
7
|
- Rack test `search` helper chooses the matching quick-pick radio directly when the query matches, falling back to the endpoint search otherwise
|
|
@@ -6,6 +6,7 @@ require 'calls'
|
|
|
6
6
|
module Formatic
|
|
7
7
|
module Testing
|
|
8
8
|
# Selects a Formatic search result in a Rack test.
|
|
9
|
+
# A blank query clears the selection instead.
|
|
9
10
|
class Search
|
|
10
11
|
include Calls
|
|
11
12
|
|
|
@@ -20,16 +21,9 @@ module Formatic
|
|
|
20
21
|
query_field = find_query_field(page, from)
|
|
21
22
|
component = search_component(query_field)
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
return record
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
record = matching_record(search_records(component), query)
|
|
28
|
-
|
|
29
|
-
raise SelectionError, "No result matching #{query.inspect} from #{from.inspect}" unless record
|
|
24
|
+
return clear_selection(component, query_field) if query.nil? || query == ''
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
record
|
|
26
|
+
select_record(component, query_field)
|
|
33
27
|
end
|
|
34
28
|
|
|
35
29
|
private
|
|
@@ -57,6 +51,19 @@ module Formatic
|
|
|
57
51
|
query_field.find(:xpath, 'ancestor::div[contains(@class, "js-formatic-search")][1]')
|
|
58
52
|
end
|
|
59
53
|
|
|
54
|
+
def select_record(component, query_field)
|
|
55
|
+
if (record = matching_pick(component, query))
|
|
56
|
+
return record
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
record = matching_record(search_records(component), query)
|
|
60
|
+
|
|
61
|
+
raise SelectionError, "No result matching #{query.inspect} from #{from.inspect}" unless record
|
|
62
|
+
|
|
63
|
+
apply_selection(component, query_field, record)
|
|
64
|
+
record
|
|
65
|
+
end
|
|
66
|
+
|
|
60
67
|
def search_records(component)
|
|
61
68
|
response = search_request(configured_value(component, 'url'), search_params(component))
|
|
62
69
|
|
|
@@ -113,6 +120,25 @@ module Formatic
|
|
|
113
120
|
component.find('.js-formatic-search__results', visible: :all).native.inner_html = ''
|
|
114
121
|
query_field.set('')
|
|
115
122
|
end
|
|
123
|
+
|
|
124
|
+
# A blank query removes the current selection.
|
|
125
|
+
# The hidden value is blanked and re-enabled for submission.
|
|
126
|
+
# Checked quickpick radios are unchecked.
|
|
127
|
+
# The selected card and the results are emptied.
|
|
128
|
+
# The query input is blanked last.
|
|
129
|
+
def clear_selection(component, query_field)
|
|
130
|
+
value_input = component.find('.js-formatic-search__value', visible: :all)
|
|
131
|
+
value_input.native.remove_attribute('disabled')
|
|
132
|
+
value_input.set('')
|
|
133
|
+
|
|
134
|
+
component.all('input.js-formatic-search__pick', visible: :all).each do |radio|
|
|
135
|
+
radio.native.remove_attribute('checked')
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
component.find('.js-formatic-search__selected', visible: :all).native.inner_html = ''
|
|
139
|
+
component.find('.js-formatic-search__results', visible: :all).native.inner_html = ''
|
|
140
|
+
query_field.set('')
|
|
141
|
+
end
|
|
116
142
|
end
|
|
117
143
|
end
|
|
118
144
|
end
|
data/lib/formatic/version.rb
CHANGED