Class: Applitools::EyesBaseConfiguration

Inherits:
AbstractConfiguration show all
Defined in:
lib/applitools/core/eyes_base_configuration.rb

Constant Summary collapse

DEFAULT_MATCH_TIMEOUT =

seconds

0
DEFAULT_CONFIG =
{
  branch_name: ENV['APPLITOOLS_BRANCH'],
  parent_branch_name: ENV['APPLITOOLS_PARENT_BRANCH'],
  baseline_branch_name: ENV['APPLITOOLS_BASELINE_BRANCH'],
  save_diffs: false,
  server_url: ENV['APPLITOOLS_SERVER_URL'] ||
    ENV['bamboo_APPLITOOLS_SERVER_URL'] || Applitools::Connectivity::ServerConnector::DEFAULT_SERVER_URL,
  api_key: ENV['APPLITOOLS_API_KEY'] || ENV['bamboo_APPLITOOLS_API_KEY'] || '',
  save_new_tests: true,
  default_match_settings: Applitools::ImageMatchSettings.new,
  accessibility_validation: nil,
  properties: [],
  match_timeout: DEFAULT_MATCH_TIMEOUT,
  dont_fetch_resources: true,
  enable_cross_origin_rendering: true,
  dont_use_cookies: false,
}.freeze

Instance Attribute Summary

Attributes inherited from AbstractConfiguration

#config_hash, #validation_errors

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractConfiguration

#deep_clone

Methods included from EyesConfigurationDSL

#accessor_methods, #boolean_field, #collect_method, #enum_field, #int_field, #methods_to_delegate, #object_field, #string_field

Constructor Details

#initializeEyesBaseConfiguration

Returns a new instance of EyesBaseConfiguration.



40
41
42
43
# File 'lib/applitools/core/eyes_base_configuration.rb', line 40

def initialize
  super
  # self.batch_info = Applitools::BatchInfo.new
end

Class Method Details

.default_configObject



35
36
37
# File 'lib/applitools/core/eyes_base_configuration.rb', line 35

def default_config
  DEFAULT_CONFIG
end

Instance Method Details

#add_property(name, value) ⇒ Object



195
196
197
# File 'lib/applitools/core/eyes_base_configuration.rb', line 195

def add_property(name, value)
  properties << { name: name, value: value } if name && value
end

#batchObject



81
82
83
84
85
86
87
# File 'lib/applitools/core/eyes_base_configuration.rb', line 81

def batch
  if batch_info.nil?
    Applitools::EyesLogger.info 'No batch set'
    self.batch_info = BatchInfo.new
  end
  batch_info
end

#batch=(value) ⇒ Object



89
90
91
# File 'lib/applitools/core/eyes_base_configuration.rb', line 89

def batch=(value)
  self.batch_info = value
end

#config_keysObject



58
59
60
# File 'lib/applitools/core/eyes_base_configuration.rb', line 58

def config_keys
  config_hash.keys
end

#custom_getter_for_exact(_value) ⇒ Object



166
167
168
# File 'lib/applitools/core/eyes_base_configuration.rb', line 166

def custom_getter_for_exact(_value)
  default_match_settings.exact
end

#custom_getter_for_ignore_caret(_value) ⇒ Object



182
183
184
# File 'lib/applitools/core/eyes_base_configuration.rb', line 182

def custom_getter_for_ignore_caret(_value)
  default_match_settings.ignore_caret
end

#custom_getter_for_ignore_displacements(_value) ⇒ Object



162
163
164
# File 'lib/applitools/core/eyes_base_configuration.rb', line 162

def custom_getter_for_ignore_displacements(_value)
  default_match_settings.ignore_displacements
end

#custom_getter_for_match_level(_value) ⇒ Object



178
179
180
# File 'lib/applitools/core/eyes_base_configuration.rb', line 178

def custom_getter_for_match_level(_value)
  default_match_settings.match_level
end

#custom_getter_for_remainder(_value) ⇒ Object



174
175
176
# File 'lib/applitools/core/eyes_base_configuration.rb', line 174

def custom_getter_for_remainder(_value)
  default_match_settings.remainder
end

#custom_getter_for_scale(_value) ⇒ Object



170
171
172
# File 'lib/applitools/core/eyes_base_configuration.rb', line 170

def custom_getter_for_scale(_value)
  default_match_settings.scale
end

#custom_setter_for_accessibility_validation(value) ⇒ Object



190
191
192
193
# File 'lib/applitools/core/eyes_base_configuration.rb', line 190

def custom_setter_for_accessibility_validation(value)
  # self.default_match_settings = self.parent.class.default_config[:default_match_settings] unless default_match_settings
  default_match_settings.accessibility_validation = value
end

#custom_setter_for_exact(value) ⇒ Object



142
143
144
# File 'lib/applitools/core/eyes_base_configuration.rb', line 142

def custom_setter_for_exact(value)
  default_match_settings.exact = value
end

#custom_setter_for_ignore_caret(value) ⇒ Object



186
187
188
# File 'lib/applitools/core/eyes_base_configuration.rb', line 186

def custom_setter_for_ignore_caret(value)
  default_match_settings.ignore_caret = value
end

#custom_setter_for_ignore_displacements(value) ⇒ Object



158
159
160
# File 'lib/applitools/core/eyes_base_configuration.rb', line 158

def custom_setter_for_ignore_displacements(value)
  default_match_settings.ignore_displacements = value
end

#custom_setter_for_match_level(value) ⇒ Object



146
147
148
# File 'lib/applitools/core/eyes_base_configuration.rb', line 146

def custom_setter_for_match_level(value)
  default_match_settings.match_level = value
end

#custom_setter_for_remainder(value) ⇒ Object



154
155
156
# File 'lib/applitools/core/eyes_base_configuration.rb', line 154

def custom_setter_for_remainder(value)
  default_match_settings.remainder = value
end

#custom_setter_for_scale(value) ⇒ Object



150
151
152
# File 'lib/applitools/core/eyes_base_configuration.rb', line 150

def custom_setter_for_scale(value)
  default_match_settings.scale = value
end

#disable_browser_fetching=(value) ⇒ Object



199
200
201
# File 'lib/applitools/core/eyes_base_configuration.rb', line 199

def disable_browser_fetching=(value)
  self.dont_fetch_resources = value
end

#layout_breakpointsObject



220
221
222
# File 'lib/applitools/core/eyes_base_configuration.rb', line 220

def layout_breakpoints
  config_hash[:layout_breakpoints]
end

#layout_breakpoints=(value) ⇒ Object

layoutBreakpoints?: boolean | number[]



209
210
211
212
213
214
215
216
217
218
219
# File 'lib/applitools/core/eyes_base_configuration.rb', line 209

def layout_breakpoints=(value)
  config_hash[:layout_breakpoints] = { breakpoints: value } if value === true || value === false
  config_hash[:layout_breakpoints] = { breakpoints: value } if value.is_a?(Array) && value.all? {|v| v.is_a?(Numeric)}
  if value.is_a?(Hash)
    if value.has_key?(:breakpoints) || value.has_key?('breakpoints')
      config_hash[:layout_breakpoints] = value
    else
      config_hash[:layout_breakpoints] = { breakpoints: value }
    end
  end
end

#merge(other_config) ⇒ Object



45
46
47
48
49
50
# File 'lib/applitools/core/eyes_base_configuration.rb', line 45

def merge(other_config)
  return if object_id == other_config.object_id
  (config_keys + other_config. config_keys).uniq do |k|
    merge_key(other_config, k)
  end
end

#merge_key(other_config, key) ⇒ Object



52
53
54
55
56
# File 'lib/applitools/core/eyes_base_configuration.rb', line 52

def merge_key(other_config, key)
  return unless other_config.send("defined_#{key}?")
  return unless respond_to?("#{key}=")
  send("#{key}=", other_config.send(key))
end

#scroll_root_elementObject



229
230
231
# File 'lib/applitools/core/eyes_base_configuration.rb', line 229

def scroll_root_element
  config_hash[:scroll_root_element]
end

#scroll_root_element=(value) ⇒ Object

scrollRootElement?: TElement | TSelector



226
227
228
# File 'lib/applitools/core/eyes_base_configuration.rb', line 226

def scroll_root_element=(value)
  config_hash[:scroll_root_element] = value
end

#set_proxy(uri, user = nil, password = nil) ⇒ Object



138
139
140
# File 'lib/applitools/core/eyes_base_configuration.rb', line 138

def set_proxy(uri, user = nil, password = nil)
  self.proxy = Applitools::Connectivity::Proxy.new(uri, user, password)
end

#short_descriptionObject



134
135
136
# File 'lib/applitools/core/eyes_base_configuration.rb', line 134

def short_description
  "#{test_name} of #{app_name}"
end

#to_sObject



62
63
64
65
66
# File 'lib/applitools/core/eyes_base_configuration.rb', line 62

def to_s
  config_keys.map do |k|
    "#{k} = #{send(k)}"
  end.join("\n")
end

#valid?Boolean

Returns:

  • (Boolean)


68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/applitools/core/eyes_base_configuration.rb', line 68

def valid?
  validation_errors.clear

  validation_errors[:app_name] = ':app_name is required' unless app_name
  validation_errors[:test_name] = ':test_name is required' unless test_name

  validation_errors[:app_name] = ':app_name is required' if app_name && app_name.empty?
  validation_errors[:test_name] = ':test_name is required' if test_name && test_name.empty?
  # validation_errors[:viewport_size] = ':viewport_size is required' if viewport_size.square.zero?
  return true if validation_errors.keys.size.zero?
  false
end