eyes_core 3.18.4 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/lib/applitools/appium/eyes.rb +1 -0
  3. data/lib/applitools/appium/target.rb +218 -193
  4. data/lib/applitools/connectivity/proxy.rb +11 -3
  5. data/lib/applitools/connectivity/server_connector.rb +2 -1
  6. data/lib/applitools/core/accessibility_level.rb +11 -0
  7. data/lib/applitools/core/batch_info.rb +24 -2
  8. data/lib/applitools/core/classic_runner.rb +8 -1
  9. data/lib/applitools/core/eyes_base.rb +80 -28
  10. data/lib/applitools/core/eyes_base_configuration.rb +22 -1
  11. data/lib/applitools/core/eyes_runner.rb +12 -0
  12. data/lib/applitools/core/floating_region.rb +17 -8
  13. data/lib/applitools/core/image_match_settings.rb +54 -0
  14. data/lib/applitools/core/match_level.rb +3 -1
  15. data/lib/applitools/core/test_results.rb +2 -2
  16. data/lib/applitools/core/universal_eyes_checks.rb +66 -0
  17. data/lib/applitools/core/universal_eyes_open.rb +100 -0
  18. data/lib/applitools/core/universal_new_api.rb +43 -0
  19. data/lib/applitools/universal_sdk/universal_check_settings.rb +184 -0
  20. data/lib/applitools/universal_sdk/universal_client.rb +142 -0
  21. data/lib/applitools/universal_sdk/universal_client_socket.rb +110 -0
  22. data/lib/applitools/universal_sdk/universal_eyes.rb +45 -0
  23. data/lib/applitools/universal_sdk/universal_eyes_config.rb +203 -0
  24. data/lib/applitools/universal_sdk/universal_eyes_manager.rb +40 -0
  25. data/lib/applitools/universal_sdk/universal_eyes_manager_config.rb +62 -0
  26. data/lib/applitools/universal_sdk/universal_server.rb +81 -0
  27. data/lib/applitools/utils/utils.rb +13 -0
  28. data/lib/applitools/version.rb +2 -1
  29. data/lib/eyes_core.rb +3 -0
  30. metadata +69 -2
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # require_relative 'universal_eyes'
4
+
5
+ module Applitools
6
+ class UniversalEyesManager
7
+
8
+ extend Forwardable
9
+ def_delegators 'Applitools::EyesLogger', :logger
10
+
11
+ def initialize(manager, universal_client)
12
+ @manager = manager
13
+ @universal_client = universal_client
14
+ end
15
+
16
+ def open_eyes(driver_config_json, config)
17
+ # Applitools::EyesLogger.logger.debug "Driver: #{driver_config_json}"
18
+ # Applitools::EyesLogger.logger.debug "open config: #{config}"
19
+
20
+ @eyes = @universal_client.eyes_manager_make_eyes(@manager, driver_config_json, config)
21
+
22
+ if @eyes[:message] && @eyes[:stack]
23
+ Applitools::EyesLogger.logger.debug "Eyes not opened: #{@eyes[:message]}"
24
+ Applitools::EyesLogger.logger.debug "Stack for #{Applitools::Connectivity::UniversalClient::EYES_MANAGER_MAKE_EYES} : #{@eyes[:stack]}"
25
+ return nil
26
+ end
27
+
28
+ Applitools::EyesLogger.logger.debug "Eyes applitools-ref-id: #{@eyes[:"applitools-ref-id"]}"
29
+ # U-Notes : !!! Eyes.new
30
+ Applitools::UniversalEyes.new(@eyes, @universal_client)
31
+ end
32
+
33
+ def close_all_eyes
34
+ @universal_client.eyes_manager_close_all_eyes(@manager)
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+ # U-Notes : Added internal Applitools::UniversalEyesManager
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Applitools
4
+ class UniversalEyesManagerConfig
5
+
6
+ def self.classic
7
+ new(type: CLASSIC)
8
+ end
9
+
10
+ def self.vg(concurrent_open_sessions=1)
11
+ new(type: VG, concurrency: concurrent_open_sessions, legacy: false)
12
+ end
13
+
14
+ # export type EyesManagerConfig<TType extends 'vg' | 'classic' = 'vg' | 'classic'> = {
15
+ # type: TType
16
+ # concurrency?: TType extends 'vg' ? number : never
17
+ # legacy?: TType extends 'vg' ? boolean : never
18
+ # }
19
+ attr_reader :type, :concurrency, :legacy
20
+
21
+ VG = 'vg'.freeze
22
+ CLASSIC = 'classic'.freeze
23
+ def type_enum_values
24
+ [VG, CLASSIC]
25
+ end
26
+
27
+ def initialize(*args)
28
+ options = Applitools::Utils.extract_options!(args)
29
+ self.type = options[:type].to_s
30
+ self.concurrency = options[:concurrency]
31
+ self.legacy = options[:legacy]
32
+ end
33
+
34
+ # enum_field :type, Applitools::UniversalEyesManagerConfig.type_enum_values
35
+ def type=(value)
36
+ available_values_array = type_enum_values
37
+ unless available_values_array.include? value
38
+ msg = "Unknown type #{value}. Allowed type values: #{available_values_array.join(', ')}"
39
+ raise(Applitools::EyesIllegalArgument, msg)
40
+ end
41
+ @type = value
42
+ end
43
+
44
+ def concurrency=(value)
45
+ @concurrency = value.to_i if type == VG
46
+ end
47
+
48
+ def legacy=(value)
49
+ @legacy = !!value if type == VG
50
+ end
51
+
52
+ def to_hash
53
+ result = {}
54
+ result[:type] = type
55
+ result[:concurrency] = concurrency if concurrency
56
+ result[:legacy] = legacy if legacy
57
+ result.compact
58
+ end
59
+
60
+ end
61
+ end
62
+ # U-Notes : Added internal Applitools::UniversalEyesManagerConfig
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open-uri'
4
+ require 'digest'
5
+ require 'fileutils'
6
+
7
+ module Applitools::Connectivity
8
+ module UniversalServer
9
+ extend self
10
+
11
+ DEFAULT_SERVER_IP = '127.0.0.1'
12
+ DEFAULT_SERVER_PORT = 21077
13
+
14
+ def run
15
+ raise 'Universal server unrecognized' unless find_server_file?
16
+ pid = spawn(filepath, '--singleton --lazy', [:out, :err] => ["log", 'w'])
17
+ Process.detach(pid)
18
+ end
19
+
20
+ def confirm_is_up(ip, port, attempt = 1)
21
+ raise 'Universal server unavailable' if (attempt === 16)
22
+ begin
23
+ TCPSocket.new(ip, port)
24
+ rescue Errno::ECONNREFUSED
25
+ sleep 1
26
+ confirm_is_up(ip, port, attempt + 1)
27
+ end
28
+ end
29
+
30
+ def check_or_run(ip = DEFAULT_SERVER_IP, port = DEFAULT_SERVER_PORT)
31
+ server_uri = "#{ip}:#{port}"
32
+ socket_uri = "ws://#{server_uri}/eyes"
33
+ begin
34
+ TCPSocket.new(ip, port)
35
+ msg = "Connect to #{server_uri}"
36
+ rescue Errno::ECONNREFUSED
37
+ run
38
+ confirm_is_up(ip, port)
39
+ msg = "Connect to #{server_libname} : #{filename}"
40
+ end
41
+
42
+ Applitools::EyesLogger.logger.debug(msg) if ENV['APPLITOOLS_SHOW_LOGS']
43
+ socket_uri
44
+ end
45
+
46
+ private
47
+
48
+ def filename
49
+ case RUBY_PLATFORM
50
+ when /mswin|windows/i
51
+ 'eyes-universal-win.exe'
52
+ when /linux|arch/i
53
+ 'eyes-universal-linux'
54
+ when /darwin/i
55
+ 'eyes-universal-macos'
56
+ else
57
+ raise 'Unsupported platform'
58
+ end
59
+ end
60
+
61
+ def server_libname
62
+ 'eyes_universal'
63
+ end
64
+
65
+ def server_lib
66
+ Gem::Specification.find_by_name(server_libname)
67
+ rescue Gem::MissingSpecError
68
+ nil
69
+ end
70
+
71
+ def filepath
72
+ server_lib ? File.join(server_lib.gem_dir, 'ext', 'eyes-universal', filename) : ''
73
+ end
74
+
75
+ def find_server_file?
76
+ File.exist?(filepath) && File.executable?(filepath)
77
+ end
78
+
79
+ end
80
+ end
81
+ # U-Notes : Added internal Applitools::Connectivity::UniversalServer
@@ -84,6 +84,19 @@ module Applitools::Utils
84
84
  end
85
85
  end
86
86
 
87
+ def deep_stringify_keys(value)
88
+ case value
89
+ when Hash
90
+ value.each_with_object({}) do |(key, val), result|
91
+ result[key.to_s] = deep_stringify_keys(val)
92
+ end
93
+ when Array
94
+ value.map { |e| deep_stringify_keys(e) }
95
+ else
96
+ value
97
+ end
98
+ end
99
+
87
100
  private
88
101
 
89
102
  def convert_hash_keys(value, method)
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Applitools
4
- VERSION = '3.18.4'.freeze
4
+ VERSION = '4.0.0'.freeze
5
+ UNIVERSAL_VERSION = '1.0.6'.freeze
5
6
  end
data/lib/eyes_core.rb CHANGED
@@ -31,6 +31,8 @@ module Applitools
31
31
  # @!visibility private
32
32
  class UnknownNetworkStackError < EyesError; end
33
33
 
34
+ class NotUniversalServerRequestError < EyesError; end
35
+
34
36
  # @!visibility private
35
37
  class AbstractMethodCalled < EyesError
36
38
  attr_accessor :method_name, :object
@@ -68,5 +70,6 @@ require_relative 'applitools/chunky_png_patch'
68
70
  Applitools.require_dir 'utils'
69
71
  Applitools.require_dir 'core'
70
72
  Applitools.require_dir 'connectivity'
73
+ Applitools.require_dir 'universal_sdk'
71
74
 
72
75
  require_relative 'applitools/eyes_logger'
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: 3.18.4
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Applitools Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-31 00:00:00.000000000 Z
11
+ date: 2022-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oily_png
@@ -94,6 +94,62 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: colorize
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: faye-websocket
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: eventmachine
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: eyes_universal
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 1.0.6
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 1.0.6
97
153
  - !ruby/object:Gem::Dependency
98
154
  name: bundler
99
155
  requirement: !ruby/object:Gem::Requirement
@@ -352,11 +408,22 @@ files:
352
408
  - lib/applitools/core/test_results.rb
353
409
  - lib/applitools/core/text_trigger.rb
354
410
  - lib/applitools/core/trigger.rb
411
+ - lib/applitools/core/universal_eyes_checks.rb
412
+ - lib/applitools/core/universal_eyes_open.rb
413
+ - lib/applitools/core/universal_new_api.rb
355
414
  - lib/applitools/extensions.rb
356
415
  - lib/applitools/eyes_logger.rb
357
416
  - lib/applitools/method_tracer.rb
358
417
  - lib/applitools/rspec/target_matcher.rb
359
418
  - lib/applitools/sauce.rb
419
+ - lib/applitools/universal_sdk/universal_check_settings.rb
420
+ - lib/applitools/universal_sdk/universal_client.rb
421
+ - lib/applitools/universal_sdk/universal_client_socket.rb
422
+ - lib/applitools/universal_sdk/universal_eyes.rb
423
+ - lib/applitools/universal_sdk/universal_eyes_config.rb
424
+ - lib/applitools/universal_sdk/universal_eyes_manager.rb
425
+ - lib/applitools/universal_sdk/universal_eyes_manager_config.rb
426
+ - lib/applitools/universal_sdk/universal_server.rb
360
427
  - lib/applitools/utils/eyes_selenium_utils.rb
361
428
  - lib/applitools/utils/image_delta_compressor.rb
362
429
  - lib/applitools/utils/image_utils.rb