eyes_core 3.18.1 → 4.0.0
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/lib/applitools/appium/eyes.rb +2 -1
- data/lib/applitools/appium/target.rb +218 -193
- data/lib/applitools/connectivity/proxy.rb +11 -3
- data/lib/applitools/connectivity/server_connector.rb +4 -2
- data/lib/applitools/core/accessibility_level.rb +11 -0
- data/lib/applitools/core/batch_info.rb +24 -2
- data/lib/applitools/core/classic_runner.rb +8 -1
- data/lib/applitools/core/eyes_base.rb +82 -29
- data/lib/applitools/core/eyes_base_configuration.rb +34 -2
- data/lib/applitools/core/eyes_runner.rb +12 -0
- data/lib/applitools/core/floating_region.rb +17 -8
- data/lib/applitools/core/image_match_settings.rb +54 -0
- data/lib/applitools/core/match_level.rb +3 -1
- data/lib/applitools/core/match_window_data.rb +4 -0
- data/lib/applitools/core/session_start_info.rb +2 -1
- data/lib/applitools/core/test_results.rb +2 -2
- data/lib/applitools/core/universal_eyes_checks.rb +66 -0
- data/lib/applitools/core/universal_eyes_open.rb +100 -0
- data/lib/applitools/core/universal_new_api.rb +43 -0
- data/lib/applitools/universal_sdk/universal_check_settings.rb +184 -0
- data/lib/applitools/universal_sdk/universal_client.rb +142 -0
- data/lib/applitools/universal_sdk/universal_client_socket.rb +110 -0
- data/lib/applitools/universal_sdk/universal_eyes.rb +45 -0
- data/lib/applitools/universal_sdk/universal_eyes_config.rb +203 -0
- data/lib/applitools/universal_sdk/universal_eyes_manager.rb +40 -0
- data/lib/applitools/universal_sdk/universal_eyes_manager_config.rb +62 -0
- data/lib/applitools/universal_sdk/universal_server.rb +81 -0
- data/lib/applitools/utils/utils.rb +13 -0
- data/lib/applitools/version.rb +2 -1
- data/lib/eyes_core.rb +3 -0
- metadata +69 -2
| @@ -6,6 +6,11 @@ require 'applitools/core/eyes_base_configuration' | |
| 6 6 | 
             
            require 'applitools/core/match_level'
         | 
| 7 7 | 
             
            require 'zlib'
         | 
| 8 8 |  | 
| 9 | 
            +
            require_relative 'universal_eyes_open'
         | 
| 10 | 
            +
            require_relative 'universal_eyes_checks'
         | 
| 11 | 
            +
            require_relative 'universal_new_api'
         | 
| 12 | 
            +
            require_relative '../universal_sdk/universal_client'
         | 
| 13 | 
            +
             | 
| 9 14 | 
             
            require_relative 'match_level_setter'
         | 
| 10 15 |  | 
| 11 16 | 
             
            module Applitools
         | 
| @@ -19,6 +24,13 @@ module Applitools | |
| 19 24 | 
             
              }.freeze
         | 
| 20 25 |  | 
| 21 26 | 
             
              class EyesBase
         | 
| 27 | 
            +
                # new open, with eyes-manager
         | 
| 28 | 
            +
                include Applitools::UniversalEyesOpen
         | 
| 29 | 
            +
                # all checks here
         | 
| 30 | 
            +
                include Applitools::UniversalEyesChecks
         | 
| 31 | 
            +
                # add extract_text, extract_text_regions, locate
         | 
| 32 | 
            +
                include Applitools::UniversalNewApi
         | 
| 33 | 
            +
             | 
| 22 34 | 
             
                include Applitools::MatchLevelSetter
         | 
| 23 35 | 
             
                extend Forwardable
         | 
| 24 36 | 
             
                extend Applitools::Helpers
         | 
| @@ -28,6 +40,25 @@ module Applitools | |
| 28 40 | 
             
                SCREENSHOT_AS_IS = Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is].freeze
         | 
| 29 41 | 
             
                CONTEXT_RELATIVE = Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative].freeze
         | 
| 30 42 |  | 
| 43 | 
            +
                class << self
         | 
| 44 | 
            +
                  def set_viewport_size(driver, viewport_size)
         | 
| 45 | 
            +
                    Applitools::ArgumentGuard.not_nil(driver, 'Driver')
         | 
| 46 | 
            +
                    Applitools::ArgumentGuard.not_nil(viewport_size, 'viewport_size')
         | 
| 47 | 
            +
                    Applitools::ArgumentGuard.is_a?(viewport_size, 'viewport_size', Applitools::RectangleSize)
         | 
| 48 | 
            +
                    Applitools::EyesLogger.info "Set viewport size #{viewport_size}"
         | 
| 49 | 
            +
                    begin
         | 
| 50 | 
            +
                      driver_config_json = driver.universal_driver_config
         | 
| 51 | 
            +
                      required_size = Applitools::RectangleSize.from_any_argument viewport_size
         | 
| 52 | 
            +
                      @universal_client = Applitools::Connectivity::UniversalClient.new
         | 
| 53 | 
            +
                      @universal_client.core_set_viewport_size(driver_config_json, required_size.to_hash)
         | 
| 54 | 
            +
                    rescue => e
         | 
| 55 | 
            +
                      Applitools::EyesLogger.error e.class
         | 
| 56 | 
            +
                      Applitools::EyesLogger.error e.message
         | 
| 57 | 
            +
                      raise Applitools::EyesError.new 'Failed to set viewport size!'
         | 
| 58 | 
            +
                    end
         | 
| 59 | 
            +
                  end
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
             | 
| 31 62 | 
             
                attr_accessor :config
         | 
| 32 63 | 
             
                private :config, :config=
         | 
| 33 64 |  | 
| @@ -60,6 +91,9 @@ module Applitools | |
| 60 91 |  | 
| 61 92 | 
             
                def_delegators 'config', *Applitools::EyesBaseConfiguration.methods_to_delegate
         | 
| 62 93 |  | 
| 94 | 
            +
                # attr_accessor :universal_client, :universal_eyes_manager
         | 
| 95 | 
            +
                attr_accessor :universal_eyes, :universal_driver
         | 
| 96 | 
            +
             | 
| 63 97 | 
             
                def initialize(*args)
         | 
| 64 98 | 
             
                  options = Applitools::Utils.extract_options!(args)
         | 
| 65 99 | 
             
                  self.runner = options[:runner]
         | 
| @@ -100,6 +134,9 @@ module Applitools | |
| 100 134 | 
             
                  self.server_scale = 0
         | 
| 101 135 | 
             
                  self.server_remainder = 0
         | 
| 102 136 | 
             
                  self.compare_with_parent_branch = false
         | 
| 137 | 
            +
             | 
| 138 | 
            +
                  self.universal_eyes = nil # eyes.open
         | 
| 139 | 
            +
                  self.universal_driver = nil # eyes.open
         | 
| 103 140 | 
             
                end
         | 
| 104 141 |  | 
| 105 142 | 
             
                def ensure_config
         | 
| @@ -158,15 +195,20 @@ module Applitools | |
| 158 195 | 
             
                  self.last_screenshot = nil
         | 
| 159 196 | 
             
                  clear_user_inputs
         | 
| 160 197 |  | 
| 198 | 
            +
                  if !running_session && !universal_eyes
         | 
| 199 | 
            +
                    logger.info('Server session was not started')
         | 
| 200 | 
            +
                    logger.info('--- Empty test ended')
         | 
| 201 | 
            +
                    return Applitools::TestResults.new
         | 
| 202 | 
            +
                  end
         | 
| 203 | 
            +
             | 
| 204 | 
            +
             | 
| 161 205 | 
             
                  if running_session.nil?
         | 
| 162 206 | 
             
                    logger.info 'Closed'
         | 
| 163 207 | 
             
                    return false
         | 
| 164 208 | 
             
                  end
         | 
| 165 209 |  | 
| 166 210 | 
             
                  logger.info 'Aborting server session...'
         | 
| 167 | 
            -
                   | 
| 168 | 
            -
                  logger.info '---Test aborted'
         | 
| 169 | 
            -
             | 
| 211 | 
            +
                  universal_sdk_abort
         | 
| 170 212 | 
             
                rescue Applitools::EyesError => e
         | 
| 171 213 | 
             
                  logger.error e.message
         | 
| 172 214 |  | 
| @@ -207,18 +249,18 @@ module Applitools | |
| 207 249 | 
             
                  raise e
         | 
| 208 250 | 
             
                end
         | 
| 209 251 |  | 
| 210 | 
            -
                def update_config_from_options(options)
         | 
| 211 | 
            -
             | 
| 212 | 
            -
             | 
| 213 | 
            -
             | 
| 214 | 
            -
             | 
| 215 | 
            -
             | 
| 216 | 
            -
             | 
| 217 | 
            -
             | 
| 218 | 
            -
             | 
| 219 | 
            -
             | 
| 220 | 
            -
             | 
| 221 | 
            -
                end
         | 
| 252 | 
            +
                # def update_config_from_options(options)
         | 
| 253 | 
            +
                #   # Applitools::ArgumentGuard.hash options, 'open_base parameter', [:test_name]
         | 
| 254 | 
            +
                #   default_options = { session_type: 'SEQUENTIAL' }
         | 
| 255 | 
            +
                #   options = default_options.merge options
         | 
| 256 | 
            +
                #
         | 
| 257 | 
            +
                #   self.app_name = options[:app_name] if options[:app_name]
         | 
| 258 | 
            +
                #
         | 
| 259 | 
            +
                #   # Applitools::ArgumentGuard.not_nil options[:test_name], 'options[:test_name]'
         | 
| 260 | 
            +
                #   self.test_name = options[:test_name] if options[:test_name]
         | 
| 261 | 
            +
                #   self.viewport_size = options[:viewport_size] if options[:viewport_size]
         | 
| 262 | 
            +
                #   self.session_type = options[:session_type] if options[:session_type]
         | 
| 263 | 
            +
                # end
         | 
| 222 264 |  | 
| 223 265 | 
             
                def merge_config(other_config)
         | 
| 224 266 | 
             
                  config.merge(other_config)
         | 
| @@ -319,7 +361,7 @@ module Applitools | |
| 319 361 | 
             
                                                                 branch_name: branch_name, parent_branch_name: parent_branch_name,
         | 
| 320 362 | 
             
                                                                 baseline_branch_name: baseline_branch_name, save_diffs: save_diffs,
         | 
| 321 363 | 
             
                                                                 properties: properties
         | 
| 322 | 
            -
             | 
| 364 | 
            +
                  session_start_info.agent_run_id = agent_run_id if agent_run_id
         | 
| 323 365 | 
             
                  match_window_data.start_info = session_start_info
         | 
| 324 366 | 
             
                  match_window_data.update_baseline_if_new = save_new_tests
         | 
| 325 367 | 
             
                  match_window_data.update_baseline_if_different = save_failed_tests
         | 
| @@ -393,40 +435,50 @@ module Applitools | |
| 393 435 |  | 
| 394 436 | 
             
                  clear_user_inputs
         | 
| 395 437 |  | 
| 396 | 
            -
                   | 
| 438 | 
            +
                  if !running_session && !universal_eyes
         | 
| 397 439 | 
             
                    be_silent || logger.info('Server session was not started')
         | 
| 398 440 | 
             
                    be_silent || logger.info('--- Empty test ended')
         | 
| 399 441 | 
             
                    return Applitools::TestResults.new
         | 
| 400 442 | 
             
                  end
         | 
| 401 443 |  | 
| 402 | 
            -
                  is_new_session = running_session.new_session?
         | 
| 403 | 
            -
                  session_results_url = running_session.url
         | 
| 444 | 
            +
                  # is_new_session = running_session.new_session?
         | 
| 445 | 
            +
                  # session_results_url = running_session.url
         | 
| 404 446 |  | 
| 405 447 | 
             
                  logger.info 'Ending server session...'
         | 
| 406 448 |  | 
| 407 | 
            -
                  save = is_new_session && save_new_tests || !is_new_session && failed && save_failed_tests
         | 
| 449 | 
            +
                  # save = is_new_session && save_new_tests || !is_new_session && failed && save_failed_tests
         | 
| 408 450 |  | 
| 409 | 
            -
                  logger.info "Automatically save test? #{save}"
         | 
| 451 | 
            +
                  # logger.info "Automatically save test? #{save}"
         | 
| 410 452 |  | 
| 411 | 
            -
                   | 
| 453 | 
            +
                  # U-Notes : universal server returns Array ; keys as sym
         | 
| 454 | 
            +
                  universal_results = universal_eyes.close # Array even for one test
         | 
| 455 | 
            +
                  # require 'pry'
         | 
| 456 | 
            +
                  # binding.pry
         | 
| 457 | 
            +
                  key_transformed_results = Applitools::Utils.deep_stringify_keys(universal_results)
         | 
| 458 | 
            +
                  results = key_transformed_results.map {|result| Applitools::TestResults.new(result) }
         | 
| 459 | 
            +
                  results = results.first if results.size == 1
         | 
| 460 | 
            +
                  session_results_url = results.url
         | 
| 461 | 
            +
                  # results = server_connector.stop_session running_session, false, save
         | 
| 412 462 | 
             
                  runner.aggregate_result(results) if runner
         | 
| 413 463 |  | 
| 414 | 
            -
                  results.is_new = is_new_session
         | 
| 415 | 
            -
                  results.url = session_results_url
         | 
| 464 | 
            +
                  # results.is_new = is_new_session
         | 
| 465 | 
            +
                  # results.url = session_results_url
         | 
| 466 | 
            +
                  save = results.new? && save_new_tests || !results.new? && failed && save_failed_tests
         | 
| 467 | 
            +
                  logger.info "Automatically save test? #{save}"
         | 
| 416 468 |  | 
| 417 469 | 
             
                  logger.info results.to_s(verbose_results)
         | 
| 418 470 |  | 
| 419 471 | 
             
                  if results.unresolved?
         | 
| 420 472 | 
             
                    if results.new?
         | 
| 421 473 | 
             
                      logger.error "--- New test ended. see details at #{session_results_url}"
         | 
| 422 | 
            -
                      error_message = "New test '#{ | 
| 423 | 
            -
                        "of '#{ | 
| 474 | 
            +
                      error_message = "New test '#{test_name}' " \
         | 
| 475 | 
            +
                        "of '#{app_name}' " \
         | 
| 424 476 | 
             
                        "Please approve the baseline at #{session_results_url} "
         | 
| 425 477 | 
             
                      raise Applitools::NewTestError.new error_message, results if throw_exception
         | 
| 426 478 | 
             
                    else
         | 
| 427 479 | 
             
                      logger.error "--- Differences are found. see details at #{session_results_url}"
         | 
| 428 | 
            -
                      error_message = "Test '#{ | 
| 429 | 
            -
                        "of '#{ | 
| 480 | 
            +
                      error_message = "Test '#{test_name}' " \
         | 
| 481 | 
            +
                        "of '#{app_name}' " \
         | 
| 430 482 | 
             
                        "detected differences! See details at #{session_results_url}"
         | 
| 431 483 | 
             
                      raise Applitools::DiffsFoundError.new error_message, results if throw_exception
         | 
| 432 484 | 
             
                    end
         | 
| @@ -435,7 +487,7 @@ module Applitools | |
| 435 487 |  | 
| 436 488 | 
             
                  if results.failed?
         | 
| 437 489 | 
             
                    logger.error "--- Failed test ended. see details at #{session_results_url}"
         | 
| 438 | 
            -
                    error_message = "Test '#{ | 
| 490 | 
            +
                    error_message = "Test '#{test_name}' of '#{app_name}' " \
         | 
| 439 491 | 
             
                        "is failed! See details at #{session_results_url}"
         | 
| 440 492 | 
             
                    raise Applitools::TestFailedError.new error_message, results if throw_exception
         | 
| 441 493 | 
             
                    return results
         | 
| @@ -597,6 +649,7 @@ module Applitools | |
| 597 649 | 
             
                                                            branch_name: branch_name, parent_branch_name: parent_branch_name,
         | 
| 598 650 | 
             
                                                            baseline_branch_name: baseline_branch_name, save_diffs: save_diffs,
         | 
| 599 651 | 
             
                                                            properties: properties
         | 
| 652 | 
            +
                  session_start_info.agent_run_id = agent_run_id if agent_run_id
         | 
| 600 653 |  | 
| 601 654 | 
             
                  logger.info 'Starting server session...'
         | 
| 602 655 | 
             
                  self.running_session = server_connector.start_session session_start_info
         | 
| @@ -11,7 +11,7 @@ require 'applitools/core/image_match_settings' | |
| 11 11 |  | 
| 12 12 | 
             
            module Applitools
         | 
| 13 13 | 
             
              class EyesBaseConfiguration < AbstractConfiguration
         | 
| 14 | 
            -
                DEFAULT_MATCH_TIMEOUT =  | 
| 14 | 
            +
                DEFAULT_MATCH_TIMEOUT = 0 # seconds
         | 
| 15 15 |  | 
| 16 16 | 
             
                DEFAULT_CONFIG = {
         | 
| 17 17 | 
             
                  branch_name: ENV['APPLITOOLS_BRANCH'],
         | 
| @@ -25,7 +25,10 @@ module Applitools | |
| 25 25 | 
             
                  default_match_settings: Applitools::ImageMatchSettings.new,
         | 
| 26 26 | 
             
                  accessibility_validation: nil,
         | 
| 27 27 | 
             
                  properties: [],
         | 
| 28 | 
            -
                  match_timeout: DEFAULT_MATCH_TIMEOUT
         | 
| 28 | 
            +
                  match_timeout: DEFAULT_MATCH_TIMEOUT,
         | 
| 29 | 
            +
                  dont_fetch_resources: true,
         | 
| 30 | 
            +
                  enable_cross_origin_rendering: true,
         | 
| 31 | 
            +
                  dont_use_cookies: false,
         | 
| 29 32 | 
             
                }.freeze
         | 
| 30 33 |  | 
| 31 34 | 
             
                class << self
         | 
| @@ -118,6 +121,10 @@ module Applitools | |
| 118 121 | 
             
                object_field :accessibility_validation, Applitools::AccessibilitySettings, true
         | 
| 119 122 | 
             
                object_field :properties, Array
         | 
| 120 123 | 
             
                int_field :match_timeout
         | 
| 124 | 
            +
                string_field :agent_run_id
         | 
| 125 | 
            +
                boolean_field :dont_fetch_resources
         | 
| 126 | 
            +
                boolean_field :enable_cross_origin_rendering
         | 
| 127 | 
            +
                boolean_field :dont_use_cookies
         | 
| 121 128 |  | 
| 122 129 | 
             
                methods_to_delegate.delete(:batch_info)
         | 
| 123 130 | 
             
                methods_to_delegate.delete(:batch_info=)
         | 
| @@ -187,7 +194,32 @@ module Applitools | |
| 187 194 | 
             
                  properties << { name: name, value: value } if name && value
         | 
| 188 195 | 
             
                end
         | 
| 189 196 |  | 
| 197 | 
            +
                def disable_browser_fetching=(value)
         | 
| 198 | 
            +
                  self.dont_fetch_resources = value
         | 
| 199 | 
            +
                end
         | 
| 200 | 
            +
             | 
| 190 201 | 
             
                methods_to_delegate.push(:set_proxy)
         | 
| 191 202 | 
             
                methods_to_delegate.push(:add_property)
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                # U-Notes : Universal Add
         | 
| 205 | 
            +
             | 
| 206 | 
            +
                # layoutBreakpoints?: boolean | number[]
         | 
| 207 | 
            +
                def layout_breakpoints=(value)
         | 
| 208 | 
            +
                  config_hash[:layout_breakpoints] = (value.is_a?(Array) && value.all? {|v| v.is_a?(Numeric)}) ? value : !!value
         | 
| 209 | 
            +
                end
         | 
| 210 | 
            +
                def layout_breakpoints
         | 
| 211 | 
            +
                  config_hash[:layout_breakpoints]
         | 
| 212 | 
            +
                end
         | 
| 213 | 
            +
                collect_method :layout_breakpoints
         | 
| 214 | 
            +
             | 
| 215 | 
            +
                # scrollRootElement?: TElement | TSelector
         | 
| 216 | 
            +
                def scroll_root_element=(value)
         | 
| 217 | 
            +
                  config_hash[:scroll_root_element] = value
         | 
| 218 | 
            +
                end
         | 
| 219 | 
            +
                def scroll_root_element
         | 
| 220 | 
            +
                  config_hash[:scroll_root_element]
         | 
| 221 | 
            +
                end
         | 
| 222 | 
            +
                collect_method :scroll_root_element
         | 
| 223 | 
            +
             | 
| 192 224 | 
             
              end
         | 
| 193 225 | 
             
            end
         | 
| @@ -3,9 +3,12 @@ | |
| 3 3 | 
             
            module Applitools
         | 
| 4 4 | 
             
              class EyesRunner
         | 
| 5 5 | 
             
                attr_accessor :batches_server_connectors_map
         | 
| 6 | 
            +
                attr_accessor :universal_client, :universal_eyes_manager
         | 
| 6 7 |  | 
| 7 8 | 
             
                def initialize
         | 
| 8 9 | 
             
                  self.batches_server_connectors_map = {}
         | 
| 10 | 
            +
                  self.universal_client = Applitools::Connectivity::UniversalClient.new
         | 
| 11 | 
            +
                  self.universal_eyes_manager = nil # eyes.open
         | 
| 9 12 | 
             
                end
         | 
| 10 13 |  | 
| 11 14 | 
             
                def add_batch(batch_id, &block)
         | 
| @@ -15,5 +18,14 @@ module Applitools | |
| 15 18 | 
             
                def delete_all_batches
         | 
| 16 19 | 
             
                  batches_server_connectors_map.each_value { |v| v.call if v.respond_to? :call }
         | 
| 17 20 | 
             
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def get_universal_eyes_manager
         | 
| 23 | 
            +
                  return universal_eyes_manager if universal_eyes_manager
         | 
| 24 | 
            +
                  self.universal_eyes_manager = universal_client.make_manager(universal_eyes_manager_config.to_hash)
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def close_all_eyes
         | 
| 28 | 
            +
                  get_universal_eyes_manager.close_all_eyes
         | 
| 29 | 
            +
                end
         | 
| 18 30 | 
             
              end
         | 
| 19 31 | 
             
            end
         | 
| @@ -93,14 +93,14 @@ module Applitools | |
| 93 93 |  | 
| 94 94 | 
             
                def to_hash
         | 
| 95 95 | 
             
                  {
         | 
| 96 | 
            -
                    ' | 
| 97 | 
            -
                    ' | 
| 98 | 
            -
                    ' | 
| 99 | 
            -
                    ' | 
| 100 | 
            -
                    ' | 
| 101 | 
            -
                    ' | 
| 102 | 
            -
                    ' | 
| 103 | 
            -
                    ' | 
| 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
         | 
| 104 104 | 
             
                  }
         | 
| 105 105 | 
             
                end
         | 
| 106 106 | 
             
              end
         | 
| @@ -123,5 +123,14 @@ module Applitools | |
| 123 123 | 
             
                  self.max_right_offset = max_right_offset
         | 
| 124 124 | 
             
                  self.max_bottom_offset = max_bottom_offset
         | 
| 125 125 | 
             
                end
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                def to_hash
         | 
| 128 | 
            +
                  {
         | 
| 129 | 
            +
                    maxUpOffset: max_top_offset,
         | 
| 130 | 
            +
                    maxDownOffset: max_bottom_offset,
         | 
| 131 | 
            +
                    maxLeftOffset: max_left_offset,
         | 
| 132 | 
            +
                    maxRightOffset: max_right_offset
         | 
| 133 | 
            +
                  }
         | 
| 134 | 
            +
                end
         | 
| 126 135 | 
             
              end
         | 
| 127 136 | 
             
            end
         | 
| @@ -98,6 +98,60 @@ module Applitools | |
| 98 98 | 
             
                      min_diff_height == other.min_diff_height &&
         | 
| 99 99 | 
             
                      match_threshold == other.match_threshold
         | 
| 100 100 | 
             
                  end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  def to_hash
         | 
| 103 | 
            +
                    {
         | 
| 104 | 
            +
                      minDiffIntensity: min_diff_intensity,
         | 
| 105 | 
            +
                      minDiffWidth: min_diff_width,
         | 
| 106 | 
            +
                      minDiffHeight: min_diff_height,
         | 
| 107 | 
            +
                      matchThreshold: match_threshold
         | 
| 108 | 
            +
                    }
         | 
| 109 | 
            +
                  end
         | 
| 101 110 | 
             
                end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                # export type MatchSettings<TRegion> = {
         | 
| 113 | 
            +
                #   exact?: {
         | 
| 114 | 
            +
                #     minDiffIntensity: number
         | 
| 115 | 
            +
                #     minDiffWidth: number
         | 
| 116 | 
            +
                #     minDiffHeight: number
         | 
| 117 | 
            +
                #     matchThreshold: number
         | 
| 118 | 
            +
                #   }
         | 
| 119 | 
            +
                #   matchLevel?: MatchLevel
         | 
| 120 | 
            +
                #   sendDom?: boolean
         | 
| 121 | 
            +
                #   useDom?: boolean
         | 
| 122 | 
            +
                #   enablePatterns?: boolean
         | 
| 123 | 
            +
                #   ignoreCaret?: boolean
         | 
| 124 | 
            +
                #   ignoreDisplacements?: boolean
         | 
| 125 | 
            +
                #   accessibilitySettings?: {
         | 
| 126 | 
            +
                #     level?: AccessibilityLevel
         | 
| 127 | 
            +
                #     guidelinesVersion?: AccessibilityGuidelinesVersion
         | 
| 128 | 
            +
                #   }
         | 
| 129 | 
            +
                #   ignoreRegions?: TRegion[]
         | 
| 130 | 
            +
                #   layoutRegions?: TRegion[]
         | 
| 131 | 
            +
                #   strictRegions?: TRegion[]
         | 
| 132 | 
            +
                #   contentRegions?: TRegion[]
         | 
| 133 | 
            +
                #   floatingRegions?: (TRegion | FloatingRegion<TRegion>)[]
         | 
| 134 | 
            +
                #   accessibilityRegions?: (TRegion | AccessibilityRegion<TRegion>)[]
         | 
| 135 | 
            +
                # }
         | 
| 136 | 
            +
                def to_hash
         | 
| 137 | 
            +
                  result = {}
         | 
| 138 | 
            +
                  result[:exact] = exact.to_hash unless exact == Exact.new # ...
         | 
| 139 | 
            +
                  result[:matchLevel] = match_level
         | 
| 140 | 
            +
                  # result[:sendDom] = nil # duplicate configuration ?
         | 
| 141 | 
            +
                  result[:useDom] = use_dom if use_dom
         | 
| 142 | 
            +
                  result[:enablePatterns] = enable_patterns if enable_patterns
         | 
| 143 | 
            +
                  result[:ignoreCaret] = ignore_caret if ignore_caret
         | 
| 144 | 
            +
                  result[:ignoreDisplacements] = ignore_displacements if ignore_displacements
         | 
| 145 | 
            +
                  result[:accessibilitySettings] = accessibility_settings.to_hash if accessibility_settings
         | 
| 146 | 
            +
                  result[:ignoreRegions] = ignore unless ignore.empty?
         | 
| 147 | 
            +
                  result[:layoutRegions] = layout unless layout.empty?
         | 
| 148 | 
            +
                  result[:strictRegions] = strict unless strict.empty?
         | 
| 149 | 
            +
                  result[:contentRegions] = content unless content.empty?
         | 
| 150 | 
            +
                  result[:floatingRegions] = floating unless floating.empty?
         | 
| 151 | 
            +
                  result[:accessibilityRegions] = accessibility unless accessibility.empty?
         | 
| 152 | 
            +
                  result.compact
         | 
| 153 | 
            +
                  # :SplitTopHeight, :SplitBottomHeight, :scale, :remainder - deprecated ?
         | 
| 154 | 
            +
                end
         | 
| 155 | 
            +
             | 
| 102 156 | 
             
              end
         | 
| 103 157 | 
             
            end
         | 
| @@ -5,13 +5,15 @@ module Applitools | |
| 5 5 | 
             
                extend self
         | 
| 6 6 | 
             
                NONE = 'None'.freeze
         | 
| 7 7 | 
             
                LAYOUT = 'Layout'.freeze
         | 
| 8 | 
            +
                LAYOUT1 = 'Layout1'.freeze
         | 
| 8 9 | 
             
                LAYOUT2 = 'Layout2'.freeze
         | 
| 9 10 | 
             
                CONTENT = 'Content'.freeze
         | 
| 10 11 | 
             
                STRICT = 'Strict'.freeze
         | 
| 11 12 | 
             
                EXACT = 'Exact'.freeze
         | 
| 12 13 |  | 
| 13 14 | 
             
                def enum_values
         | 
| 14 | 
            -
                  [NONE, LAYOUT, LAYOUT2, CONTENT, STRICT, EXACT]
         | 
| 15 | 
            +
                  [NONE, LAYOUT, LAYOUT1, LAYOUT2, CONTENT, STRICT, EXACT]
         | 
| 15 16 | 
             
                end
         | 
| 16 17 | 
             
              end
         | 
| 17 18 | 
             
            end
         | 
| 19 | 
            +
            # U-Notes : Added Layout1 MatchLevel
         | 
| @@ -87,6 +87,10 @@ module Applitools | |
| 87 87 | 
             
                  current_data['Options']['Name'] = value
         | 
| 88 88 | 
             
                end
         | 
| 89 89 |  | 
| 90 | 
            +
                def variation_group_id=(value)
         | 
| 91 | 
            +
                  current_data['Options']['variantId'] = value
         | 
| 92 | 
            +
                end
         | 
| 93 | 
            +
             | 
| 90 94 | 
             
                def user_inputs=(value)
         | 
| 91 95 | 
             
                  Applitools::ArgumentGuard.is_a? value, 'value', Array
         | 
| 92 96 | 
             
                  current_data['UserInputs'] += value.select { |i| i.respond_to? :to_hash }
         | 
| @@ -5,7 +5,7 @@ module Applitools | |
| 5 5 | 
             
                include Applitools::Jsonable
         | 
| 6 6 | 
             
                json_fields :batchInfo, :agentId, :appIdOrName, :verId, :environment, :environmentName, :branchName, :defaultMatchSettings,
         | 
| 7 7 | 
             
                  :scenarioIdOrName, :properties, :parentBranchName, :compareWithParentBranch, :baselineEnvName, :saveDiffs, :sessionType,
         | 
| 8 | 
            -
                  :baselineBranchName
         | 
| 8 | 
            +
                  :baselineBranchName, :agentRunId
         | 
| 9 9 |  | 
| 10 10 | 
             
                wrap_data do |value|
         | 
| 11 11 | 
             
                  { startInfo: value }
         | 
| @@ -28,6 +28,7 @@ module Applitools | |
| 28 28 | 
             
                  self.save_diffs = options[:save_diffs]
         | 
| 29 29 | 
             
                  self.session_type = options[:session_type]
         | 
| 30 30 | 
             
                  self.baseline_branch_name = options[:baseline_branch_name]
         | 
| 31 | 
            +
                  self.agentRunId = options[:agent_run_id] if options[:agent_run_id]
         | 
| 31 32 | 
             
                end
         | 
| 32 33 |  | 
| 33 34 | 
             
                def to_hash
         | 
| @@ -26,8 +26,8 @@ module Applitools | |
| 26 26 | 
             
                  @mismatches = results.fetch('mismatches', 0)
         | 
| 27 27 | 
             
                  @missing = results.fetch('missing', 0)
         | 
| 28 28 | 
             
                  @status = results.fetch('status', 0)
         | 
| 29 | 
            -
                  @is_new = nil
         | 
| 30 | 
            -
                  @url = nil
         | 
| 29 | 
            +
                  @is_new = results.fetch('isNew', nil)
         | 
| 30 | 
            +
                  @url = results.fetch('url', nil)
         | 
| 31 31 | 
             
                end
         | 
| 32 32 |  | 
| 33 33 | 
             
                def passed?
         | 
| @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Applitools
         | 
| 4 | 
            +
              module UniversalEyesChecks
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                # Takes a snapshot and matches it with the expected output.
         | 
| 7 | 
            +
                #
         | 
| 8 | 
            +
                # @param [String] name The name of the tag.
         | 
| 9 | 
            +
                # @param [Applitools::Selenium::Target] target which area of the window to check.
         | 
| 10 | 
            +
                # @return [Applitools::MatchResult] The match results.
         | 
| 11 | 
            +
                def universal_check(name, target)
         | 
| 12 | 
            +
                  return disabled_result if respond_to?(:disabled?) && disabled?
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  raise Applitools::EyesNotOpenException.new('Eyes not open!') if @universal_eyes.nil?
         | 
| 15 | 
            +
                  Applitools::EyesLogger.logger.info "#{test_name} : check(#{name}) started  ..."
         | 
| 16 | 
            +
                  # require 'pry'
         | 
| 17 | 
            +
                  # binding.pry
         | 
| 18 | 
            +
                  check_result = @universal_eyes.check(get_universal_check_settings(name, target))
         | 
| 19 | 
            +
                  if server_error?(check_result)
         | 
| 20 | 
            +
                    # require 'pry'
         | 
| 21 | 
            +
                    # binding.pry
         | 
| 22 | 
            +
                    raise Applitools::EyesError.new("Request failed: #{check_result[:message]}")
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  if check_result != {}
         | 
| 26 | 
            +
                    result = Applitools::MatchResult.new(Applitools::Utils.deep_stringify_keys(check_result))
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                    check_fail_result_processing(name) unless result.as_expected?
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  logger.info 'Done!'
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                private
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                def disabled_result
         | 
| 37 | 
            +
                  logger.info "#{__method__} Ignored"
         | 
| 38 | 
            +
                  result = Applitools::MatchResults.new
         | 
| 39 | 
            +
                  result.as_expected = true
         | 
| 40 | 
            +
                  result
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def get_universal_check_settings(name, target)
         | 
| 44 | 
            +
                  universal_check_settings = Applitools::UniversalCheckSettings.new(name: name)
         | 
| 45 | 
            +
                  universal_check_settings.from_original_target(target, self)
         | 
| 46 | 
            +
                  # require 'pry'
         | 
| 47 | 
            +
                  # binding.pry
         | 
| 48 | 
            +
                  universal_check_settings.to_hash
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                def check_fail_result_processing(name)
         | 
| 52 | 
            +
                  self.failed = true
         | 
| 53 | 
            +
                  logger.info "Mistmatch! #{name}" #unless running_session.new_session?
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  if failure_reports == :immediate
         | 
| 56 | 
            +
                    raise Applitools::TestFailedException.new "Mistmatch found in #{test_name} of #{app_name}"
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                def server_error?(universal_results)
         | 
| 61 | 
            +
                  universal_results.is_a?(Hash) && universal_results[:message] && universal_results[:stack]
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
            end
         | 
| 66 | 
            +
            # U-Notes : Added internal Applitools::UniversalEyesChecks
         | 
| @@ -0,0 +1,100 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Applitools
         | 
| 4 | 
            +
              module UniversalEyesOpen
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                # Starts a test
         | 
| 7 | 
            +
                #
         | 
| 8 | 
            +
                # @param options [Hash] options
         | 
| 9 | 
            +
                # @option options :driver The driver that controls the browser hosting the application
         | 
| 10 | 
            +
                #   under the test. (*Required* option)
         | 
| 11 | 
            +
                # @option options [String] :app_name The name of the application under the test. (*Required* option)
         | 
| 12 | 
            +
                # @option options [String] :test_name The test name (*Required* option)
         | 
| 13 | 
            +
                # @option options [String | Hash] :viewport_size The required browser's viewport size
         | 
| 14 | 
            +
                #   (i.e., the visible part of the document's body) or +nil+ to use the current window's viewport.
         | 
| 15 | 
            +
                # @option options :session_type The type of the test (e.g., standard test / visual performance test).
         | 
| 16 | 
            +
                #   Default value is 'SEQUENTAL'
         | 
| 17 | 
            +
                # @return [Applitools::Selenium::Driver] A wrapped web driver which enables Eyes
         | 
| 18 | 
            +
                #   trigger recording and frame handling
         | 
| 19 | 
            +
                def universal_open(options = {})
         | 
| 20 | 
            +
                  original_driver = options.delete(:driver)
         | 
| 21 | 
            +
                  Applitools::ArgumentGuard.not_nil original_driver, 'options[:driver]'
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  if respond_to?(:disabled?) && disabled?
         | 
| 24 | 
            +
                    logger.info('Ignored')
         | 
| 25 | 
            +
                    return original_driver
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  self.driver = Applitools::Selenium::SeleniumEyes.eyes_driver(original_driver, self)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  update_config_from_options(options)
         | 
| 31 | 
            +
                  universal_driver_config = driver.universal_driver_config
         | 
| 32 | 
            +
                  universal_eyes_manager = runner.get_universal_eyes_manager
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  universal_eyes_config = Applitools::UniversalEyesConfig.new
         | 
| 35 | 
            +
                  universal_eyes_config.from_original_sdk(self)
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  # require('pry')
         | 
| 38 | 
            +
                  # binding.pry
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  @universal_eyes = universal_eyes_manager.open_eyes(universal_driver_config, universal_eyes_config.to_hash)
         | 
| 41 | 
            +
                  raise Applitools::EyesNotOpenException.new('Eyes not open!') if @universal_eyes.nil?
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  self.open = true if respond_to?(:open=, true)
         | 
| 44 | 
            +
                  self.running_session = true if respond_to?(:running_session=, true)
         | 
| 45 | 
            +
                  driver
         | 
| 46 | 
            +
                rescue Applitools::EyesError => e
         | 
| 47 | 
            +
                  logger.error e.message
         | 
| 48 | 
            +
                  raise e
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                def universal_sdk_abort
         | 
| 52 | 
            +
                  if respond_to?(:disabled?) && disabled?
         | 
| 53 | 
            +
                    logger.info "#{__method__} Ignore disabled"
         | 
| 54 | 
            +
                    return false
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                  # raise Applitools::EyesNotOpenException.new('Eyes not open!') if @eyes.nil?
         | 
| 57 | 
            +
                  return if @universal_eyes.nil?
         | 
| 58 | 
            +
                  result = @universal_eyes.abort
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  if result.is_a? Hash
         | 
| 61 | 
            +
                    logger.info "---Test aborted" if !result[:message] && !result[:stack]
         | 
| 62 | 
            +
                  else
         | 
| 63 | 
            +
                    # TestCheckFrameInFrame_Fully_Fluent_VG\
         | 
| 64 | 
            +
                    # require('pry')
         | 
| 65 | 
            +
                    # binding.pry
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                private
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                def update_config_from_options(options)
         | 
| 72 | 
            +
                  default_options = { session_type: 'SEQUENTIAL' }
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                  options = default_options.merge options
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                  self.app_name = options[:app_name] if options[:app_name]
         | 
| 77 | 
            +
                  self.test_name = options[:test_name] if options[:test_name]
         | 
| 78 | 
            +
                  if (config.viewport_size.nil? || config.viewport_size&.empty?) && options[:viewport_size]
         | 
| 79 | 
            +
                    self.viewport_size = Applitools::RectangleSize.from_any_argument options[:viewport_size]
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
                  self.session_type = options[:session_type] if options[:session_type]
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                  raise Applitools::EyesIllegalArgument, config.validation_errors.values.join('/n') unless config.valid?
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                  logger.info "Agent = #{full_agent_id}"
         | 
| 86 | 
            +
                  logger.info "open(app_name: #{app_name}, test_name: #{test_name}," \
         | 
| 87 | 
            +
                      " viewport_size: #{viewport_size})"
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                  raise Applitools::EyesError.new 'API key is missing! Please set it using api_key=' if
         | 
| 90 | 
            +
                    api_key.nil? || (api_key && api_key.empty?)
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  logger.info "Batch is #{@batch}" if @batch
         | 
| 93 | 
            +
                  app_env = app_environment if respond_to? :app_environment
         | 
| 94 | 
            +
                  logger.info "Application environment is #{app_env}"
         | 
| 95 | 
            +
                  test_info = "'#{test_name}' of '#{app_name}' #{app_env}"
         | 
| 96 | 
            +
                  logger.info "--- New test started - #{test_info}"
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
              end
         | 
| 100 | 
            +
            end
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            # frozen_string_literal: false
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Applitools
         | 
| 4 | 
            +
              module UniversalNewApi
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                # export type OCRExtractSettings<TElement, TSelector> = {
         | 
| 7 | 
            +
                #   target: RegionReference<TElement, TSelector>
         | 
| 8 | 
            +
                #   hint?: string
         | 
| 9 | 
            +
                #   minMatch?: number
         | 
| 10 | 
            +
                #   language?: string
         | 
| 11 | 
            +
                # }
         | 
| 12 | 
            +
                def extract_text(targets_array)
         | 
| 13 | 
            +
                  targets_array.map do |target|
         | 
| 14 | 
            +
                    target['target'] = { elementId: target['target'].ref } if target['target'].is_a?(::Selenium::WebDriver::Element)
         | 
| 15 | 
            +
                    target
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                  universal_eyes.extract_text(targets_array)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
             | 
| 21 | 
            +
                # export type OCRSearchSettings<TPattern extends string> = {
         | 
| 22 | 
            +
                #   patterns: TPattern[]
         | 
| 23 | 
            +
                #   ignoreCase?: boolean
         | 
| 24 | 
            +
                #   firstOnly?: boolean
         | 
| 25 | 
            +
                #   language?: string
         | 
| 26 | 
            +
                # }
         | 
| 27 | 
            +
                def extract_text_regions(patterns_array)
         | 
| 28 | 
            +
                  results = universal_eyes.extract_text_regions(patterns_array)
         | 
| 29 | 
            +
                  Applitools::Utils.deep_stringify_keys(results)
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
             | 
| 33 | 
            +
                def locate(locate_settings)
         | 
| 34 | 
            +
                  settings = {
         | 
| 35 | 
            +
                    locatorNames: locate_settings[:locator_names],
         | 
| 36 | 
            +
                    firstOnly: !!locate_settings[:first_only]
         | 
| 37 | 
            +
                  }
         | 
| 38 | 
            +
                  results = universal_eyes.locate(settings)
         | 
| 39 | 
            +
                  Applitools::Utils.deep_stringify_keys(results)
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
            end
         |