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



193
194
195
# File 'lib/applitools/core/eyes_base_configuration.rb', line 193

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



164
165
166
# File 'lib/applitools/core/eyes_base_configuration.rb', line 164

def custom_getter_for_exact(_value)
  default_match_settings.exact
end

#custom_getter_for_ignore_caret(_value) ⇒ Object



180
181
182
# File 'lib/applitools/core/eyes_base_configuration.rb', line 180

def custom_getter_for_ignore_caret(_value)
  default_match_settings.ignore_caret
end

#custom_getter_for_ignore_displacements(_value) ⇒ Object



160
161
162
# File 'lib/applitools/core/eyes_base_configuration.rb', line 160

def custom_getter_for_ignore_displacements(_value)
  default_match_settings.ignore_displacements
end

#custom_getter_for_match_level(_value) ⇒ Object



176
177
178
# File 'lib/applitools/core/eyes_base_configuration.rb', line 176

def custom_getter_for_match_level(_value)
  default_match_settings.match_level
end

#custom_getter_for_remainder(_value) ⇒ Object



172
173
174
# File 'lib/applitools/core/eyes_base_configuration.rb', line 172

def custom_getter_for_remainder(_value)
  default_match_settings.remainder
end

#custom_getter_for_scale(_value) ⇒ Object



168
169
170
# File 'lib/applitools/core/eyes_base_configuration.rb', line 168

def custom_getter_for_scale(_value)
  default_match_settings.scale
end

#custom_setter_for_accessibility_validation(value) ⇒ Object



188
189
190
191
# File 'lib/applitools/core/eyes_base_configuration.rb', line 188

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



140
141
142
# File 'lib/applitools/core/eyes_base_configuration.rb', line 140

def custom_setter_for_exact(value)
  default_match_settings.exact = value
end

#custom_setter_for_ignore_caret(value) ⇒ Object



184
185
186
# File 'lib/applitools/core/eyes_base_configuration.rb', line 184

def custom_setter_for_ignore_caret(value)
  default_match_settings.ignore_caret = value
end

#custom_setter_for_ignore_displacements(value) ⇒ Object



156
157
158
# File 'lib/applitools/core/eyes_base_configuration.rb', line 156

def custom_setter_for_ignore_displacements(value)
  default_match_settings.ignore_displacements = value
end

#custom_setter_for_match_level(value) ⇒ Object



144
145
146
# File 'lib/applitools/core/eyes_base_configuration.rb', line 144

def custom_setter_for_match_level(value)
  default_match_settings.match_level = value
end

#custom_setter_for_remainder(value) ⇒ Object



152
153
154
# File 'lib/applitools/core/eyes_base_configuration.rb', line 152

def custom_setter_for_remainder(value)
  default_match_settings.remainder = value
end

#custom_setter_for_scale(value) ⇒ Object



148
149
150
# File 'lib/applitools/core/eyes_base_configuration.rb', line 148

def custom_setter_for_scale(value)
  default_match_settings.scale = value
end

#disable_browser_fetching=(value) ⇒ Object



197
198
199
# File 'lib/applitools/core/eyes_base_configuration.rb', line 197

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

#layout_breakpointsObject



210
211
212
# File 'lib/applitools/core/eyes_base_configuration.rb', line 210

def layout_breakpoints
  config_hash[:layout_breakpoints]
end

#layout_breakpoints=(value) ⇒ Object

layoutBreakpoints?: boolean | number[]



207
208
209
# File 'lib/applitools/core/eyes_base_configuration.rb', line 207

def layout_breakpoints=(value)
  config_hash[:layout_breakpoints] = (value.is_a?(Array) && value.all? {|v| v.is_a?(Numeric)}) ? value : !!value
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



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

def scroll_root_element
  config_hash[:scroll_root_element]
end

#scroll_root_element=(value) ⇒ Object

scrollRootElement?: TElement | TSelector



216
217
218
# File 'lib/applitools/core/eyes_base_configuration.rb', line 216

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

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



136
137
138
# File 'lib/applitools/core/eyes_base_configuration.rb', line 136

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

#short_descriptionObject



132
133
134
# File 'lib/applitools/core/eyes_base_configuration.rb', line 132

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