Class: Applitools::UniversalEyesConfig

Inherits:
Object
  • Object
show all
Includes:
Jsonable
Defined in:
lib/applitools/universal_sdk/universal_eyes_config.rb

Constant Summary collapse

FROM_ORIGINAL_EYES =

23 + 3 + 2 + 11 = 39

[:api_key, :app_name, :batch, :browsers_info, :concurrent_sessions, :debug_screenshots,
  :force_full_page_screenshot, :hide_caret, :hide_scrollbars, :host_app, :host_os, :match_timeout, :proxy,
  :save_failed_tests, :save_new_tests, :scale_ratio, :send_dom, :stitch_mode, :test_name,
  :viewport_size, :visual_grid_options, :wait_before_screenshots, :wait_before_capture] + [
  :disabled?, # disabled? => is_disabled
  :stitching_overlap, # SeleniumEyes.stitching_overlap => stitch_overlap
  :dont_fetch_resources # dont_fetch_resources => disable_browser_fetching
] + [
  :layout_breakpoints,
  :scroll_root_element,
] + [
  :environment_name, :branch_name, :default_match_settings, :properties, :parent_branch_name,
  :compare_with_parent_branch, :baseline_env_name, :save_diffs, :session_type, :baseline_branch_name
]
OTHER =

51 - 39 - 2 = 10

[:logs, :remove_session, :remote_events, :display_name, :host_app_info, :host_os_info, :device_info,
:ignore_baseline, :cut, :rotation ]

Instance Method Summary collapse

Methods included from Jsonable

included, #json, #json_data

Constructor Details

#initialize(*args) ⇒ UniversalEyesConfig

Returns a new instance of UniversalEyesConfig.



158
159
160
161
162
163
164
165
166
167
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 158

def initialize(*args)
  options = Applitools::Utils.extract_options! args
  options.keys.select {|k| options[k] && respond_to?("#{k}=") }.each {|k| send("#{k}=", options[k]) }
  # other
  self.connection_timeout = Applitools::Connectivity::ServerConnector::DEFAULT_TIMEOUT
  if 'true'.casecmp(ENV['APPLITOOLS_DONT_CLOSE_BATCHES'] || '') == 0
    self.dont_close_batches = true
    Applitools::EyesLogger.info('APPLITOOLS_DONT_CLOSE_BATCHES environment variable set to true. Doing nothing.')
  end
end

Instance Method Details

#api_changeObject



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 217

def api_change
  # self.updateBaselineIfDifferent = saveFailedTests unless saveFailedTests.nil?
  # self.updateBaselineIfNew = saveNewTests unless saveNewTests.nil?
  environment = {}
  environment[:hostingApp] = hostApp unless hostApp.nil?
  environment[:displayHostingApp] = hostAppInfo unless hostAppInfo.nil?
  environment[:os] = hostOS unless hostOS.nil?
  environment[:displayOs] = hostOSInfo unless hostOSInfo.nil?
  environment[:deviceName] = deviceInfo unless deviceInfo.nil?
  unless viewportSize.nil?
    environment[:viewportSize] = viewportSize
    self.viewportSize = nil
  end
  self.environment = environment unless environment.empty?
  # :ignoreGitBranching, :abortIdleTestTimeout
end

#copy_from(what, from) ⇒ Object



198
199
200
201
202
203
204
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 198

def copy_from(what, from)
  if from.respond_to?(what)
    send("#{what.to_s.chomp('?') }=", from.send(what))
  else
    puts "respond_to? #{what} - fail"
  end
end

#from_eyes_imagesObject



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 169

def from_eyes_images
  FROM_ORIGINAL_EYES - [
    :browsers_info,
    :concurrent_sessions,
    :debug_screenshots,
    :force_full_page_screenshot,
    :hide_caret,
    :hide_scrollbars,
    :send_dom,
    :stitch_mode,
    :visual_grid_options,
    :wait_before_screenshots,
    :wait_before_capture,
    :stitching_overlap
  ]

end

#from_original_sdk(original_eyes) ⇒ Object



187
188
189
190
191
192
193
194
195
196
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 187

def from_original_sdk(original_eyes)
  from_eyes = original_eyes.class.name != 'Applitools::Images::Eyes' ? FROM_ORIGINAL_EYES : from_eyes_images
  from_eyes.each {|m| copy_from(m, original_eyes) }
  self.agent_id = original_eyes.base_agent_id if original_eyes.respond_to?(:base_agent_id)
  self.agent_id = original_eyes.full_agent_id if original_eyes.respond_to?(:full_agent_id)
  # self.display_name = original_eyes.app_name
  self.dont_close_batches = original_eyes.dont_close_batches unless original_eyes.dont_close_batches.nil?
  prepare_for_json!
  self.eyes_server_url = original_eyes.server_url unless original_eyes.server_url.nil? # v4api_change
end

#prepare_for_json!Object



206
207
208
209
210
211
212
213
214
215
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 206

def prepare_for_json!
  self.batch = batch.to_hash if batch.is_a?(Applitools::BatchInfo)
  self.browsers_info = browsers_info.to_hash if browsers_info.is_a?(Applitools::Selenium::BrowsersInfo)
  self.default_match_settings = default_match_settings.to_hash if default_match_settings.is_a?(Applitools::ImageMatchSettings)
  self.proxy = proxy.to_hash if proxy.is_a?(Applitools::Connectivity::Proxy)
  self.viewport_size = viewport_size.to_h if viewport_size.is_a?(Applitools::RectangleSize)
  api_change
  # require 'pry'
  # binding.pry
end

#to_hashObject



234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/applitools/universal_sdk/universal_eyes_config.rb', line 234

def to_hash
  json_data.compact.reject do |_, v|
    case v
      when Array, Hash
        v.empty?
      when Numeric
        v.zero?
      # when FalseClass
      #   true
      else
        false
    end
  end
end