eyes_core 4.4.1 → 4.5.0.beta

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: 3b270e9777509fbff56836132e7c946acc6f131aff903e8205836dd7742e1df1
4
- data.tar.gz: 57843ac7683e28309baf66857d49b3c2127891aabbc9043a568f121c5c701d21
3
+ metadata.gz: fb4470a9e790799f337bf3649c9d1d815b78933e1cdd394e14f02c1fcb1e9707
4
+ data.tar.gz: 8a54d18a05cafc611d51b689dcf3b47db26e7ee8c7be1fec3ff2e77b007ed2f2
5
5
  SHA512:
6
- metadata.gz: cc448938f1fca93ba339854ab3570a758f389b6c48e207781e10cc18a726b0c889391b04a0ba24354ebaeefe9050744d09a47bf660aa44c75e2d5b3fea5de760
7
- data.tar.gz: acbd8ac4994b80b804a39a7f7ab0c400531b1558d2541785cb49b7d5c64a98f7e10bd1dd78efa7b979f1ac4b243d31036c521f8b8c8304e27a3d2f9be7b9c5cf
6
+ metadata.gz: 9bbb9b54179c3d535a981e26d5ddfde2bc88be6e378074b635ff7796c2cf1ffa1b176b5d74a35e9b03b0d6d9e9ce6241149e92ccaf2b81e33ac59bb81f7e9568
7
+ data.tar.gz: 7052cf337483264abfaf9d495c3f6a6c83381266ae17cde752c589c193df264afd72f82178077400bbd67ac1b72f58e446a741046c793f06dbcf83c48e8f67fe
@@ -21,7 +21,7 @@ module Applitools::Connectivity
21
21
  DEFAULT_SERVER_URL = 'https://eyesapi.applitools.com'.freeze
22
22
 
23
23
  SSL_CERT = File.join(File.dirname(File.expand_path(__FILE__)), '../../../certs/cacert.pem').to_s.freeze
24
- DEFAULT_TIMEOUT = 300
24
+ DEFAULT_TIMEOUT = 300_000
25
25
  API_SESSIONS = '/api/sessions'.freeze
26
26
  API_SESSIONS_RUNNING = API_SESSIONS + '/running/'.freeze
27
27
  API_SINGLE_TEST = API_SESSIONS + '/'.freeze
@@ -93,14 +93,16 @@ module Applitools
93
93
 
94
94
  def to_hash
95
95
  {
96
- 'top' => top,
97
- 'left' => left,
98
- 'width' => width,
99
- 'height' => height,
100
- 'maxUpOffset' => max_top_offset + padding_top,
101
- 'maxLeftOffset' => max_left_offset + padding_left,
102
- 'maxRightOffset' => max_right_offset + padding_right,
103
- 'maxDownOffset' => max_bottom_offset + padding_bottom
96
+ x: left,
97
+ y: top,
98
+ width: width,
99
+ height: height,
100
+ offset: {
101
+ top: max_top_offset + padding_top,
102
+ bottom: max_bottom_offset + padding_bottom,
103
+ left: max_left_offset + padding_left,
104
+ right: max_right_offset + padding_right
105
+ }
104
106
  }
105
107
  end
106
108
  end
@@ -126,10 +128,12 @@ module Applitools
126
128
 
127
129
  def to_hash
128
130
  {
129
- maxUpOffset: max_top_offset,
130
- maxDownOffset: max_bottom_offset,
131
- maxLeftOffset: max_left_offset,
132
- maxRightOffset: max_right_offset
131
+ offset: {
132
+ top: max_top_offset,
133
+ bottom: max_bottom_offset,
134
+ left: max_left_offset,
135
+ right: max_right_offset
136
+ }
133
137
  }
134
138
  end
135
139
  end
@@ -8,11 +8,12 @@ module Applitools
8
8
  LAYOUT1 = 'Layout1'.freeze
9
9
  LAYOUT2 = 'Layout2'.freeze
10
10
  CONTENT = 'Content'.freeze
11
+ IGNORE_COLORS = 'IgnoreColors'.freeze
11
12
  STRICT = 'Strict'.freeze
12
13
  EXACT = 'Exact'.freeze
13
14
 
14
15
  def enum_values
15
- [NONE, LAYOUT, LAYOUT1, LAYOUT2, CONTENT, STRICT, EXACT]
16
+ [NONE, LAYOUT, LAYOUT1, LAYOUT2, CONTENT, IGNORE_COLORS, STRICT, EXACT]
16
17
  end
17
18
  end
18
19
  end
@@ -18,7 +18,7 @@ module Applitools
18
18
 
19
19
  def old_style_results_array
20
20
  Applitools::Utils.deep_stringify_keys(results).map do |e|
21
- r = e['testResults'] ? e['testResults'] : {}
21
+ r = e['result'] ? e['result'] : {}
22
22
  Applitools::TestResults.new(r)
23
23
  end
24
24
  end
@@ -13,9 +13,11 @@ module Applitools
13
13
 
14
14
  raise Applitools::EyesNotOpenException.new('Eyes not open!') if @universal_eyes.nil?
15
15
  Applitools::EyesLogger.logger.info "#{test_name} : check(#{name}) started ..."
16
+ settings = get_universal_check_settings(name, target)
17
+ image_target = settings[:image].nil? ? {} : { image: settings.delete(:image) }
16
18
  # require 'pry'
17
19
  # binding.pry
18
- check_result = @universal_eyes.check(get_universal_check_settings(name, target))
20
+ check_result = @universal_eyes.check(settings, image_target)
19
21
  if server_error?(check_result)
20
22
  # require 'pry'
21
23
  # binding.pry
@@ -23,12 +25,13 @@ module Applitools
23
25
  end
24
26
 
25
27
  if check_result != {}
26
- result = Applitools::MatchResult.new(Applitools::Utils.deep_stringify_keys(check_result))
28
+ result = Applitools::MatchResult.new(Applitools::Utils.deep_stringify_keys(check_result[0]))
27
29
 
28
30
  check_fail_result_processing(name) unless result.as_expected?
29
31
  end
30
32
 
31
33
  logger.info 'Done!'
34
+ result
32
35
  end
33
36
 
34
37
  private
@@ -18,17 +18,19 @@ module Applitools
18
18
  # trigger recording and frame handling
19
19
  def universal_open(options = {})
20
20
  original_driver = options.delete(:driver)
21
- Applitools::ArgumentGuard.not_nil original_driver, 'options[:driver]'
21
+ if self.class.name != 'Applitools::Images::Eyes'
22
+ Applitools::ArgumentGuard.not_nil original_driver, 'options[:driver]'
22
23
 
23
- if respond_to?(:disabled?) && disabled?
24
- logger.info('Ignored')
25
- return original_driver
26
- end
24
+ if respond_to?(:disabled?) && disabled?
25
+ logger.info('Ignored')
26
+ return original_driver
27
+ end
27
28
 
28
- self.driver = Applitools::Selenium::SeleniumEyes.eyes_driver(original_driver, self)
29
+ self.driver = Applitools::Selenium::SeleniumEyes.eyes_driver(original_driver, self)
30
+ end
29
31
 
30
32
  update_config_from_options(options)
31
- universal_driver_config = driver.universal_driver_config
33
+ universal_driver_config = driver.universal_driver_config if self.class.name != 'Applitools::Images::Eyes'
32
34
  universal_eyes_manager = runner.get_universal_eyes_manager
33
35
 
34
36
  universal_eyes_config = Applitools::UniversalEyesConfig.new
@@ -42,7 +44,11 @@ module Applitools
42
44
 
43
45
  self.open = true if respond_to?(:open=, true)
44
46
  self.running_session = true if respond_to?(:running_session=, true)
45
- driver
47
+ if self.class.name != 'Applitools::Images::Eyes'
48
+ driver
49
+ else
50
+ self.open?
51
+ end
46
52
  rescue Applitools::EyesError => e
47
53
  logger.error e.message
48
54
  raise e
@@ -9,12 +9,18 @@ module Applitools
9
9
  # minMatch?: number
10
10
  # language?: string
11
11
  # }
12
- def extract_text(targets_array)
12
+ def extract_text(*args)
13
+ image_target = args[0].is_a?(Hash) ? args[0] : nil
14
+ targets_array = args[0].is_a?(Hash) ? args[1].to_a : args[0]
13
15
  targets_array.map do |target|
14
16
  target['target'] = { elementId: target['target'].ref } if target['target'].is_a?(::Selenium::WebDriver::Element)
17
+ target['target']['x'] = target['target'].delete('left') if target['target']['left']
18
+ target['target']['y'] = target['target'].delete('top') if target['target']['top']
19
+ target[:region] = target.delete('target')
15
20
  target
16
21
  end
17
- universal_eyes.extract_text(targets_array)
22
+ driver_target = respond_to?(:driver) ? driver.universal_driver_config : image_target
23
+ universal_eyes.extract_text(targets_array, driver_target)
18
24
  end
19
25
 
20
26
 
@@ -25,7 +31,8 @@ module Applitools
25
31
  # language?: string
26
32
  # }
27
33
  def extract_text_regions(patterns_array)
28
- results = universal_eyes.extract_text_regions(patterns_array)
34
+ driver_target = respond_to?(:driver) ? driver.universal_driver_config : { image: patterns_array.delete('image') }
35
+ results = universal_eyes.extract_text_regions(patterns_array, driver_target)
29
36
  Applitools::Utils.deep_stringify_keys(results)
30
37
  end
31
38
 
@@ -35,7 +42,8 @@ module Applitools
35
42
  locatorNames: locate_settings[:locator_names],
36
43
  firstOnly: !!locate_settings[:first_only]
37
44
  }
38
- results = universal_eyes.locate(settings)
45
+ driver_target = driver.universal_driver_config
46
+ results = universal_eyes.locate(settings, driver_target)
39
47
  Applitools::Utils.deep_stringify_keys(results)
40
48
  end
41
49
 
@@ -80,6 +80,19 @@ module Applitools
80
80
  :scrollRootElement,
81
81
  :fully
82
82
 
83
+ # v3
84
+ json_fields :ufgOptions,
85
+ :userCommandId
86
+
87
+ # ImageTarget
88
+ json_fields :image
89
+ # :name,
90
+ # :source,
91
+ # :dom,
92
+ # :locationInViewport,
93
+ # :locationInView,
94
+ # :fullViewSize
95
+
83
96
  def initialize(*args)
84
97
  options = Applitools::Utils.extract_options! args
85
98
  options.keys.select {|k| options[k] && respond_to?("#{k}=") }.each {|k| send("#{k}=", options[k]) }
@@ -100,6 +113,7 @@ module Applitools
100
113
  def from_original_target(target, eyes)
101
114
  # require('pry')
102
115
  # binding.pry
116
+ return from_eyes_images(target, eyes) if eyes.class.name === 'Applitools::Images::Eyes'
103
117
 
104
118
  self.accessibility_settings = eyes.accessibility_validation
105
119
  self.disable_browser_fetching = eyes.dont_fetch_resources
@@ -160,11 +174,39 @@ module Applitools
160
174
  self.send_dom = from_target_options_or_eyes(:send_dom, target.options, eyes)
161
175
  self.use_dom = from_target_options_or_eyes(:use_dom, target.options, eyes)
162
176
  self.visual_grid_options = from_target_options_or_eyes(:visual_grid_options, target.options, eyes)
177
+ self.ufg_options = self.visual_grid_options
178
+ self.user_command_id = self.variation_group_id
179
+
180
+ self.image = target.image if target.respond_to?(:image)
163
181
  # rescue => e
164
182
  # require('pry')
165
183
  # binding.pry
166
184
  end
167
185
 
186
+ def from_eyes_images(target, eyes)
187
+ self.accessibility_settings = eyes.accessibility_validation
188
+ self.disable_browser_fetching = eyes.dont_fetch_resources
189
+ self.accessibility_regions = target.accessibility_regions
190
+ self.floating_regions = target.floating_regions
191
+
192
+ self.ignore_regions = target.ignored_regions.map do |ir|
193
+ ir.is_a?(Proc) ? normalize_element_selector(ir.call(eyes.driver)) : ir
194
+ end
195
+
196
+ if target.region_to_check.is_a?(Hash)
197
+ self.region = target.region_to_check
198
+ elsif target.region_to_check.is_a?(String)
199
+ self.region = target.region_to_check
200
+ elsif target.region_to_check.is_a?(Proc)
201
+ el = target.region_to_check.call(eyes.driver)
202
+ self.region = normalize_element_selector(el) unless el.respond_to?(:empty?) && el.empty?
203
+ end
204
+
205
+ self.exact = (target.options[:exact] && target.options[:exact].to_hash) || (eyes.exact && eyes.exact.to_hash)
206
+
207
+ self.image = target.image
208
+ end
209
+
168
210
  def to_hash
169
211
  json_data.compact.reject do |_, v|
170
212
  case v
@@ -16,29 +16,37 @@ module Applitools::Connectivity
16
16
  extend Forwardable
17
17
  def_delegators 'Applitools::EyesLogger', :logger
18
18
 
19
- SESSION_INIT = 'Core.makeSDK'
19
+ SESSION_INIT = 'Core.makeCore'
20
20
 
21
21
  CORE_MAKE_MANAGER = 'Core.makeManager'
22
22
  CORE_GET_VIEWPORT_SIZE = 'Core.getViewportSize'
23
23
  CORE_SET_VIEWPORT_SIZE = 'Core.setViewportSize'
24
- CORE_CLOSE_BATCHES = 'Core.closeBatches'
24
+ CORE_CLOSE_BATCHES = 'Core.closeBatch'
25
25
  CORE_DELETE_TEST = 'Core.deleteTest'
26
26
 
27
27
  EYES_MANAGER_MAKE_EYES = 'EyesManager.openEyes'
28
28
  EYES_MANAGER_CLOSE_ALL_EYES = 'EyesManager.closeManager'
29
29
  EYES_CHECK = 'Eyes.check'
30
- EYES_LOCATE = 'Eyes.locate'
31
- EYES_EXTRACT_TEXT_REGIONS = 'Eyes.extractTextRegions'
30
+ EYES_CHECK_AND_CLOSE = 'Eyes.checkAndClose' # ...
31
+ EYES_LOCATE = 'Core.locate'
32
+ EYES_EXTRACT_TEXT_REGIONS = 'Eyes.locateText'
32
33
  EYES_EXTRACT_TEXT = 'Eyes.extractText'
33
34
  EYES_CLOSE = 'Eyes.close'
34
35
  EYES_ABORT = 'Eyes.abort'
35
36
 
37
+ attr_accessor :commands_config
36
38
 
37
39
  def initialize
38
40
  # @socket = Applitools::Connectivity::UniversalClientSocket.new
39
41
  prepare_socket
40
42
  # store on open for next check calls
41
43
  @open_config = nil
44
+ @commands_config = {
45
+ open: {},
46
+ screenshot: {},
47
+ check: {},
48
+ close: {}
49
+ }
42
50
  end
43
51
 
44
52
  def make_manager(eyes_manager_config)
@@ -50,66 +58,207 @@ module Applitools::Connectivity
50
58
 
51
59
 
52
60
  def core_make_manager(eyes_manager_config)
53
- # await(->(cb) { @socket.request(CORE_MAKE_MANAGER, eyes_manager_config, cb) })
61
+ # interface MakeManagerRequestPayload {
62
+ # type: 'ufg' | 'classic'
63
+ # concurrency?: number
64
+ # legacyConcurrency?: number
65
+ # agentId?: string
66
+ # }
67
+ #
68
+ # type MakeManagerResponsePayload = Ref<EyesManager>
54
69
  command_with_result(CORE_MAKE_MANAGER, eyes_manager_config)
55
70
  end
56
71
 
72
+ def config_mapping(old_config, command_config, name)
73
+ return if old_config[name].nil?
74
+ command_config[name] = old_config.delete(name)
75
+ end
76
+
77
+ def map_open_eyes_config_to_commands_config(config)
78
+ [
79
+ :serverUrl, :apiKey, :proxy, :connectionTimeout, :removeSession, :agentId, :appName, :testName, :displayName,
80
+ :userTestId, :sessionType, :properties, :batch, :keepBatchOpen, :environmentName, :environment, :branchName,
81
+ :parentBranchName, :baselineEnvName, :baselineBranchName, :compareWithParentBranch, :ignoreBaseline,
82
+ :ignoreGitBranching, :saveDiffs, :abortIdleTestTimeout
83
+ ].each do |k|
84
+ config_mapping(config, commands_config[:open], k)
85
+ end
86
+
87
+ commands_config[:open][:keepBatchOpen] = config.delete(:dontCloseBatches) unless config[:dontCloseBatches].nil?
88
+
89
+ [:hideCaret, :hideScrollbars, :disableBrowserFetching, :sendDom, :stitchMode,
90
+ :layoutBreakpoints, :waitBeforeCapture].each do |k|
91
+ config_mapping(config, commands_config[:check], k)
92
+ end
93
+
94
+ commands_config[:check][:renderers] = config.delete(:browsersInfo) unless config[:browsersInfo].nil?
95
+
96
+ unless config[:defaultMatchSettings].nil?
97
+ if config[:defaultMatchSettings][:accessibilitySettings]
98
+ commands_config[:check][:accessibilitySettings] = {}
99
+ commands_config[:check][:accessibilitySettings][:level] = config[:defaultMatchSettings][:accessibilitySettings].delete(:level) unless config[:defaultMatchSettings][:accessibilitySettings][:level].nil?
100
+ commands_config[:check][:accessibilitySettings][:version] = config[:defaultMatchSettings][:accessibilitySettings].delete(:guidelinesVersion) unless config[:defaultMatchSettings][:accessibilitySettings][:guidelinesVersion].nil?
101
+ config[:defaultMatchSettings].delete(:accessibilitySettings) if config[:defaultMatchSettings][:accessibilitySettings].empty?
102
+ end
103
+ commands_config[:check][:ignoreCaret] = config[:defaultMatchSettings].delete(:ignoreCaret) unless config[:defaultMatchSettings][:ignoreCaret].nil?
104
+ commands_config[:check][:matchLevel] = config[:defaultMatchSettings].delete(:matchLevel) unless config[:defaultMatchSettings][:matchLevel].nil?
105
+ config.delete(:defaultMatchSettings) if config[:defaultMatchSettings].empty?
106
+ end
107
+
108
+ if commands_config[:check][:fully].nil?
109
+ commands_config[:check][:fully] = config.delete(:forceFullPageScreenshot) unless config[:forceFullPageScreenshot].nil?
110
+ end
111
+
112
+ commands_config[:close][:updateBaselineIfNew] = config.delete(:saveNewTests) unless config[:saveNewTests].nil?
113
+ commands_config[:close][:updateBaselineIfDifferent] = config.delete(:saveFailedTests) unless config[:saveFailedTests].nil?
114
+
115
+ commands_config[:screenshot] = commands_config[:check]
116
+ end
117
+
118
+
119
+
120
+
57
121
  def eyes_manager_make_eyes(manager, driver_config, config)
58
122
  @open_config = config
59
123
 
60
- # await(->(cb) {
61
- # @socket.request(EYES_MANAGER_MAKE_EYES, {manager: manager, driver: driver_config, config: config}, cb)
62
- # })
63
- command_with_result(EYES_MANAGER_MAKE_EYES, {manager: manager, driver: driver_config, config: config})
124
+ map_open_eyes_config_to_commands_config(config)
125
+ # interface OpenEyesRequestPayload {
126
+ # manager: Ref<EyesManager>
127
+ # target?: DriverTarget
128
+ # settings?: OpenSettings
129
+ # config?: Config
130
+ # }
131
+ #
132
+ # type OpenEyesResponsePayload = Ref<Eyes>
133
+ command_with_result(EYES_MANAGER_MAKE_EYES, {manager: manager, target: driver_config, settings: commands_config[:open], config: commands_config})
64
134
  end
65
135
 
66
136
  def eyes_manager_close_all_eyes(manager)
67
- # await(->(cb) { @socket.request(EYES_MANAGER_CLOSE_ALL_EYES, {manager: manager}, cb) })
68
- command_with_result(EYES_MANAGER_CLOSE_ALL_EYES, {manager: manager})
137
+ # interface CloseManagerRequestPayload {
138
+ # manager: Ref<EyesManager>
139
+ # settings?: {throwErr?: boolean}
140
+ # }
141
+ #
142
+ # interface CloseManagerResponsePayload {
143
+ # results: Array<{
144
+ # error?: Error
145
+ # result?: TestResult
146
+ # renderer?: TType extends 'ufg' ? Renderer : never
147
+ # userTestId: string
148
+ # }>
149
+ # passed: number
150
+ # unresolved: number
151
+ # failed: number
152
+ # exceptions: number
153
+ # mismatches: number
154
+ # missing: number
155
+ # matches: number
156
+ # }
157
+ command_with_result(EYES_MANAGER_CLOSE_ALL_EYES, {manager: manager, config: commands_config})
69
158
  end
70
159
 
71
- def eyes_check(eyes, settings)
72
- # await(->(cb) { @socket.request(EYES_CHECK, {eyes: eyes, settings: settings, config: @open_config}, cb) })
73
- command_with_result(EYES_CHECK, {eyes: eyes, settings: settings, config: @open_config})
160
+ def eyes_check(eyes, settings, image_target = {})
161
+ # interface CheckRequestPayload {
162
+ # eyes: Ref<Eyes>
163
+ # target?: ImageTarget | DriverTarget
164
+ # settings?: CheckSettings
165
+ # config?: Config
166
+ # }
167
+ #
168
+ # type CheckResponsePayload = CheckResult[]
169
+ payload = {eyes: eyes, settings: settings, config: commands_config}
170
+ payload[:target] = image_target unless image_target.empty?
171
+ command_with_result(EYES_CHECK, payload)
74
172
  end
75
173
 
76
- def eyes_locate(eyes, settings)
77
- # await(->(cb) { @socket.request(EYES_LOCATE, {eyes: eyes, settings: settings, config: @open_config}, cb) })
78
- command_with_result(EYES_LOCATE, {eyes: eyes, settings: settings, config: @open_config})
174
+ def eyes_locate(eyes, settings, driver_target)
175
+ # interface LocateRequestPayload {
176
+ # target?: ImageTarget | DriverTarget
177
+ # settings?: LocateSettings
178
+ # config?: Config
179
+ # }
180
+ #
181
+ # interface LocateResponsePayload {
182
+ # [key: string]: Array<{x: number, y: number, width: number, height: number}>
183
+ # }
184
+
185
+ command_with_result(EYES_LOCATE, {target: driver_target, settings: settings, config: commands_config})
79
186
  end
80
187
 
81
- def eyes_extract_text_regions(eyes, settings)
82
- # await(->(cb) { @socket.request(EYES_EXTRACT_TEXT_REGIONS, {eyes: eyes, settings: settings, config: @open_config}, cb) })
83
- command_with_result(EYES_EXTRACT_TEXT_REGIONS, {eyes: eyes, settings: settings, config: @open_config})
188
+ def eyes_extract_text_regions(eyes, settings, driver_target)
189
+ # interface LocateTextRequestPayload {
190
+ # eyes: Ref<Eyes>
191
+ # target?: ImageTarget | DriverTarget
192
+ # settings?: LocateTextSettings
193
+ # config?: Config
194
+ # }
195
+ #
196
+ # type LocateTextResponcePayload = Record<string, Array<{text: string, x: number, y: number, width: number, hieght: number}>>
197
+ payload = {eyes: eyes, target: driver_target, settings: settings, config: commands_config}
198
+ payload.delete(:target) if driver_target.nil? || driver_target.empty?
199
+ command_with_result(EYES_EXTRACT_TEXT_REGIONS, payload)
84
200
  end
85
201
 
86
- def eyes_extract_text(eyes, regions)
87
- # await(->(cb) { @socket.request(EYES_EXTRACT_TEXT, {eyes: eyes, regions: regions, config: @open_config}, cb) })
88
- command_with_result(EYES_EXTRACT_TEXT, {eyes: eyes, regions: regions, config: @open_config})
202
+ def eyes_extract_text(eyes, regions, driver_target)
203
+ # interface ExtractTextRequestPayload {
204
+ # eyes: Ref<Eyes>
205
+ # target?: ImageTarget | DriverTarget
206
+ # settings?: ExtractTextSettings | ExtractTextSettings[]
207
+ # config?: Config
208
+ # }
209
+ #
210
+ # type ExtractTextResponcePayload = string[]
211
+ payload = {eyes: eyes, target: driver_target, settings: regions, config: commands_config}
212
+ payload.delete(:settings) if regions.empty?
213
+ command_with_result(EYES_EXTRACT_TEXT, payload)
89
214
  end
90
215
 
91
216
  def eyes_close(eyes)
92
- # await(->(cb) { @socket.request(EYES_CLOSE, {eyes: eyes}, cb) })
93
- command_with_result(EYES_CLOSE, {eyes: eyes})
217
+ # interface CloseResponsePayload {
218
+ # eyes: Ref<Eyes>
219
+ # settings?: CloseSettings
220
+ # config?: Config
221
+ # }
222
+ #
223
+ # type CloseResponsePayload = TestResult[]
224
+ settings = {throwErr: false}
225
+
226
+ command_with_result(EYES_CLOSE, {eyes: eyes, settings: settings, config: commands_config})
94
227
  end
95
228
 
96
229
  def eyes_abort(eyes)
97
- # await(->(cb) { @socket.request(EYES_ABORT, {eyes: eyes}, cb) })
230
+ # interface AbortPayload {
231
+ # eyes: Ref<Eyes>
232
+ # }
233
+ #
234
+ # type AbortResponsePayload = TestResult[]
98
235
  command_with_result(EYES_ABORT, {eyes: eyes})
99
236
  end
100
237
 
101
238
  def core_get_viewport_size(driver)
102
- # await(->(cb) { @socket.request(CORE_GET_VIEWPORT_SIZE, {driver: driver}, cb) })
103
- command_with_result(CORE_GET_VIEWPORT_SIZE, {driver: driver})
239
+ # interface GetViewportSizeRequestPayload {
240
+ # target: DriverTarget
241
+ # }
242
+ #
243
+ # interface GetViewportSizeResponsePayload {
244
+ # width: number
245
+ # height: number
246
+ # }
247
+ command_with_result(CORE_GET_VIEWPORT_SIZE, {target: driver})
104
248
  end
105
249
 
106
250
  def core_set_viewport_size(driver, size)
107
- # await(->(cb) { @socket.request(CORE_SET_VIEWPORT_SIZE, {driver: driver, size: size}, cb) })
108
- command_with_result(CORE_SET_VIEWPORT_SIZE, {driver: driver, size: size})
251
+ # interface SetViewportSizeRequestPayload {
252
+ # target: DriverTarget
253
+ # size: {width: number, height: number}
254
+ # }
255
+ command_with_result(CORE_SET_VIEWPORT_SIZE, {target: driver, size: size})
109
256
  end
110
257
 
111
258
  def core_close_batches(close_batch_settings=nil)
112
- # batchIds, serverUrl?, apiKey?, proxy?
259
+ # interface CloseBatchRequestPayload {
260
+ # settings: CloseBatchSettings | CloseBatchSettings[]
261
+ # }
113
262
  unless close_batch_settings.is_a?(Hash)
114
263
  batch_ids = [@open_config[:batch][:id]]
115
264
  batch_ids = [close_batch_settings] if close_batch_settings.is_a?(String)
@@ -117,13 +266,13 @@ module Applitools::Connectivity
117
266
  optional = [:serverUrl, :apiKey, :proxy].map {|k| [k, @open_config[k]] }.to_h
118
267
  close_batch_settings = { settings: ({ batchIds: batch_ids }.merge(optional).compact) }
119
268
  end
120
- # await(->(cb) { @socket.request(CORE_CLOSE_BATCHES, close_batch_settings, cb) })
121
269
  command_with_result(CORE_CLOSE_BATCHES, close_batch_settings)
122
270
  end
123
271
 
124
272
  def core_delete_test(delete_test_settings)
125
- # testId, batchId, secretToken, serverUrl, apiKey?, proxy?
126
- # await(->(cb) { @socket.request(CORE_DELETE_TEST, delete_test_settings, cb) })
273
+ # interface DeleteTestRequestPayload {
274
+ # settings: DeleteTestSettings | DeleteTestSettings[]
275
+ # }
127
276
  command_with_result(CORE_DELETE_TEST, delete_test_settings)
128
277
  end
129
278
 
@@ -175,12 +324,13 @@ module Applitools::Connectivity
175
324
  end
176
325
 
177
326
  def session_init
178
- command(SESSION_INIT, {
327
+ make_core_payload = {
179
328
  name: :rb,
180
329
  version: Applitools::VERSION,
181
330
  protocol: :webdriver,
182
331
  cwd: Dir.pwd
183
- })
332
+ }
333
+ command(SESSION_INIT, make_core_payload)
184
334
  # no response
185
335
  end
186
336
 
@@ -11,10 +11,10 @@ module Applitools
11
11
  @universal_client = universal_client
12
12
  end
13
13
 
14
- def check(settings)
14
+ def check(settings, image_target = {})
15
15
  elapsed_time_start = Time.now
16
16
  # Applitools::EyesLogger.logger.debug "check settings: #{settings}"
17
- check_result = @universal_client.eyes_check(@eyes, settings)
17
+ check_result = @universal_client.eyes_check(@eyes, settings, image_target)
18
18
  # Applitools::EyesLogger.logger.debug "check_result: #{check_result}"
19
19
  Applitools::EyesLogger.logger.info "Completed in #{format('%.2f', Time.now - elapsed_time_start)} seconds"
20
20
  check_result
@@ -28,16 +28,16 @@ module Applitools
28
28
  @universal_client.eyes_abort(@eyes)
29
29
  end
30
30
 
31
- def locate(settings)
32
- @universal_client.eyes_locate(@eyes, settings)
31
+ def locate(settings, driver_target)
32
+ @universal_client.eyes_locate(@eyes, settings, driver_target)
33
33
  end
34
34
 
35
- def extract_text_regions(patterns_array)
36
- @universal_client.eyes_extract_text_regions(@eyes, patterns_array)
35
+ def extract_text_regions(patterns_array, driver_target)
36
+ @universal_client.eyes_extract_text_regions(@eyes, patterns_array, driver_target)
37
37
  end
38
38
 
39
- def extract_text(targets_array)
40
- @universal_client.eyes_extract_text(@eyes, targets_array)
39
+ def extract_text(targets_array, driver_target)
40
+ @universal_client.eyes_extract_text(@eyes, targets_array, driver_target)
41
41
  end
42
42
 
43
43
  end
@@ -123,6 +123,13 @@ module Applitools
123
123
  :layoutBreakpoints,
124
124
  :disableBrowserFetching
125
125
 
126
+ # v3
127
+ json_fields :environment
128
+ # :updateBaselineIfDifferent,
129
+ # :updateBaselineIfNew,
130
+ # :ignoreGitBranching,
131
+ # :abortIdleTestTimeout
132
+
126
133
  # 23 + 3 + 2 + 11 = 39
127
134
  FROM_ORIGINAL_EYES = [:api_key, :app_name, :batch, :browsers_info, :concurrent_sessions, :debug_screenshots,
128
135
  :force_full_page_screenshot, :hide_caret, :hide_scrollbars, :host_app, :host_os, :match_timeout, :proxy,
@@ -159,8 +166,27 @@ module Applitools
159
166
  end
160
167
  end
161
168
 
169
+ def from_eyes_images
170
+ FROM_ORIGINAL_EYES - [
171
+ :browsers_info,
172
+ :concurrent_sessions,
173
+ :debug_screenshots,
174
+ :force_full_page_screenshot,
175
+ :hide_caret,
176
+ :hide_scrollbars,
177
+ :send_dom,
178
+ :stitch_mode,
179
+ :visual_grid_options,
180
+ :wait_before_screenshots,
181
+ :wait_before_capture,
182
+ :stitching_overlap
183
+ ]
184
+
185
+ end
186
+
162
187
  def from_original_sdk(original_eyes)
163
- FROM_ORIGINAL_EYES.each {|m| copy_from(m, original_eyes) }
188
+ from_eyes = original_eyes.class.name != 'Applitools::Images::Eyes' ? FROM_ORIGINAL_EYES : from_eyes_images
189
+ from_eyes.each {|m| copy_from(m, original_eyes) }
164
190
  self.agent_id = original_eyes.base_agent_id if original_eyes.respond_to?(:base_agent_id)
165
191
  self.agent_id = original_eyes.full_agent_id if original_eyes.respond_to?(:full_agent_id)
166
192
  # self.display_name = original_eyes.app_name
@@ -181,10 +207,28 @@ module Applitools
181
207
  self.default_match_settings = default_match_settings.to_hash if default_match_settings.is_a?(Applitools::ImageMatchSettings)
182
208
  self.proxy = proxy.to_hash if proxy.is_a?(Applitools::Connectivity::Proxy)
183
209
  self.viewport_size = viewport_size.to_h if viewport_size.is_a?(Applitools::RectangleSize)
210
+ v3api_change
184
211
  # require 'pry'
185
212
  # binding.pry
186
213
  end
187
214
 
215
+ def v3api_change
216
+ # self.updateBaselineIfDifferent = saveFailedTests unless saveFailedTests.nil?
217
+ # self.updateBaselineIfNew = saveNewTests unless saveNewTests.nil?
218
+ environment = {}
219
+ environment[:hostApp] = hostApp unless hostApp.nil?
220
+ environment[:hostAppInfo] = hostAppInfo unless hostAppInfo.nil?
221
+ environment[:hostOS] = hostOS unless hostOS.nil?
222
+ environment[:hostOSInfo] = hostOSInfo unless hostOSInfo.nil?
223
+ environment[:deviceInfo] = deviceInfo unless deviceInfo.nil?
224
+ unless viewportSize.nil?
225
+ environment[:viewportSize] = viewportSize
226
+ self.viewportSize = nil
227
+ end
228
+ self.environment = environment unless environment.empty?
229
+ # :ignoreGitBranching, :abortIdleTestTimeout
230
+ end
231
+
188
232
  def to_hash
189
233
  json_data.compact.reject do |_, v|
190
234
  case v
@@ -18,7 +18,7 @@ module Applitools
18
18
  # }
19
19
  attr_reader :type, :concurrency, :legacy
20
20
 
21
- VG = 'vg'.freeze
21
+ VG = 'ufg'.freeze
22
22
  CLASSIC = 'classic'.freeze
23
23
  def type_enum_values
24
24
  [VG, CLASSIC]
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Applitools
4
- VERSION = '4.4.1'.freeze
5
- UNIVERSAL_VERSION = '2.12.3'.freeze
4
+ VERSION = '4.5.0.beta'.freeze
5
+ IMAGES_VERSION = '4.0.0.alpha'.freeze
6
+ UNIVERSAL_VERSION = '3.0.2'.freeze
6
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyes_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.1
4
+ version: 4.5.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Applitools Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-03 00:00:00.000000000 Z
11
+ date: 2022-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 2.12.3
117
+ version: 3.0.2
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 2.12.3
124
+ version: 3.0.2
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bundler
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -422,9 +422,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
422
422
  version: '0'
423
423
  required_rubygems_version: !ruby/object:Gem::Requirement
424
424
  requirements:
425
- - - ">="
425
+ - - ">"
426
426
  - !ruby/object:Gem::Version
427
- version: '0'
427
+ version: 1.3.1
428
428
  requirements: []
429
429
  rubygems_version: 3.3.14
430
430
  signing_key: