eyes_core 4.6.3 → 6.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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +504 -0
  3. data/Rakefile +35 -0
  4. data/eyes_core.gemspec +60 -0
  5. data/lib/applitools/core/batch_info.rb +2 -0
  6. data/lib/applitools/core/classic_runner.rb +1 -3
  7. data/lib/applitools/core/eyes_base.rb +110 -22
  8. data/lib/applitools/core/eyes_base_configuration.rb +9 -1
  9. data/lib/applitools/core/eyes_runner.rb +3 -2
  10. data/lib/applitools/core/test_result_summary.rb +7 -7
  11. data/lib/applitools/core/test_results.rb +19 -3
  12. data/lib/applitools/core/universal_eyes_checks.rb +2 -1
  13. data/lib/applitools/core/universal_eyes_open.rb +5 -1
  14. data/lib/applitools/eyes_core/version.rb +10 -0
  15. data/lib/applitools/universal_sdk/universal_client.rb +26 -10
  16. data/lib/applitools/universal_sdk/universal_eyes.rb +5 -0
  17. data/lib/applitools/universal_sdk/universal_eyes_config.rb +10 -9
  18. data/lib/applitools/universal_sdk/universal_eyes_manager.rb +1 -1
  19. data/lib/eyes_core.rb +1 -3
  20. metadata +14 -58
  21. data/ext/eyes_core/extconf.rb +0 -5
  22. data/ext/eyes_core/eyes_core.c +0 -252
  23. data/ext/eyes_core/eyes_core.h +0 -28
  24. data/lib/applitools/appium/android_region_provider.rb +0 -32
  25. data/lib/applitools/appium/android_screenshot.rb +0 -21
  26. data/lib/applitools/appium/driver.rb +0 -12
  27. data/lib/applitools/appium/eyes.rb +0 -189
  28. data/lib/applitools/appium/ios_region_provider.rb +0 -25
  29. data/lib/applitools/appium/ios_screenshot.rb +0 -10
  30. data/lib/applitools/appium/region_provider.rb +0 -51
  31. data/lib/applitools/appium/screenshot.rb +0 -30
  32. data/lib/applitools/appium/target.rb +0 -240
  33. data/lib/applitools/appium/utils.rb +0 -64
  34. data/lib/applitools/calabash/calabash_element.rb +0 -64
  35. data/lib/applitools/calabash/calabash_screenshot_provider.rb +0 -83
  36. data/lib/applitools/calabash/environment_detector.rb +0 -25
  37. data/lib/applitools/calabash/eyes.rb +0 -194
  38. data/lib/applitools/calabash/eyes_calabash_android_screenshot.rb +0 -68
  39. data/lib/applitools/calabash/eyes_calabash_ios_screenshot.rb +0 -30
  40. data/lib/applitools/calabash/eyes_calabash_screenshot.rb +0 -80
  41. data/lib/applitools/calabash/eyes_hooks.rb +0 -51
  42. data/lib/applitools/calabash/eyes_settings.rb +0 -45
  43. data/lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb +0 -95
  44. data/lib/applitools/calabash/full_page_capture_algorithm/base.rb +0 -51
  45. data/lib/applitools/calabash/full_page_capture_algorithm/ios_ui_table_view.rb +0 -150
  46. data/lib/applitools/calabash/full_page_capture_algorithm.rb +0 -26
  47. data/lib/applitools/calabash/os_versions.rb +0 -25
  48. data/lib/applitools/calabash/rspec_matchers.rb +0 -25
  49. data/lib/applitools/calabash/steps/android_eyes_session.rb +0 -37
  50. data/lib/applitools/calabash/steps/android_matchers.rb +0 -36
  51. data/lib/applitools/calabash/steps/eyes_session.rb +0 -42
  52. data/lib/applitools/calabash/steps/eyes_settings.rb +0 -59
  53. data/lib/applitools/calabash/steps/ios_eyes_session.rb +0 -15
  54. data/lib/applitools/calabash/steps/ios_matchers.rb +0 -17
  55. data/lib/applitools/calabash/steps/matchers.rb +0 -71
  56. data/lib/applitools/calabash/target.rb +0 -69
  57. data/lib/applitools/calabash/utils.rb +0 -74
  58. data/lib/applitools/calabash_steps.rb +0 -16
  59. data/lib/applitools/capybara/capybara_settings.rb +0 -25
  60. data/lib/applitools/capybara/driver.rb +0 -39
  61. data/lib/applitools/rspec/target_matcher.rb +0 -25
  62. data/lib/applitools/universal_sdk/executable_finder.rb +0 -57
  63. data/lib/applitools/universal_sdk/universal_server_control.rb +0 -79
  64. data/lib/applitools/version.rb +0 -8
  65. data/lib/eyes_consts.rb +0 -4
  66. data/lib/eyes_rspec.rb +0 -4
@@ -49,7 +49,7 @@ module Applitools
49
49
  begin
50
50
  driver_config_json = driver.universal_driver_config
51
51
  required_size = Applitools::RectangleSize.from_any_argument viewport_size
52
- @universal_client = Applitools::Connectivity::UniversalClient.new
52
+ @universal_client = Applitools::Connectivity::UniversalClient.new(self)
53
53
  @universal_client.core_set_viewport_size(driver_config_json, required_size.to_hash)
54
54
  rescue => e
55
55
  Applitools::EyesLogger.error e.class
@@ -64,7 +64,7 @@ module Applitools
64
64
  server_url = options[:server_url] || default_configs[:server_url]
65
65
  api_key = options[:api_key] || default_configs[:api_key]
66
66
  proxy = options[:proxy]
67
- @universal_client = Applitools::Connectivity::UniversalClient.new
67
+ @universal_client = Applitools::Connectivity::UniversalClient.new(self)
68
68
  core_ec_client = @universal_client.core_make_ec_client(server_url, api_key, proxy)
69
69
  core_ec_client[:url]
70
70
  end
@@ -150,6 +150,13 @@ module Applitools
150
150
  self.universal_driver = nil # eyes.open
151
151
  end
152
152
 
153
+ def self.environment_sdk
154
+ {
155
+ name: :eyes_core,
156
+ currentVersion: Applitools::EyesCore::VERSION
157
+ }
158
+ end
159
+
153
160
  def ensure_config
154
161
  self.config = Applitools::EyesBaseConfiguration.new
155
162
  end
@@ -213,10 +220,10 @@ module Applitools
213
220
  end
214
221
 
215
222
 
216
- if running_session.nil?
217
- logger.info 'Closed'
218
- return false
219
- end
223
+ # if running_session.nil?
224
+ # logger.info 'Closed'
225
+ # return false
226
+ # end
220
227
 
221
228
  logger.info 'Aborting server session...'
222
229
  universal_sdk_abort
@@ -441,11 +448,6 @@ module Applitools
441
448
  logger.info "close(#{throw_exception})"
442
449
  raise Applitools::EyesError.new 'Eyes not open' unless open?
443
450
 
444
- self.open = false
445
- self.last_screenshot = nil
446
-
447
- clear_user_inputs
448
-
449
451
  if !running_session && !universal_eyes
450
452
  be_silent || logger.info('Server session was not started')
451
453
  be_silent || logger.info('--- Empty test ended')
@@ -463,26 +465,112 @@ module Applitools
463
465
 
464
466
  # U-Notes : universal server returns Array ; keys as sym
465
467
  universal_eyes.close # nil
468
+ results = get_results(throw_exception)
469
+ # universal_results = universal_eyes.eyes_get_results # Array even for one test
470
+ # # require 'pry'
471
+ # # binding.pry
472
+ # # error from universal server
473
+ # if universal_results.is_a?(Hash) && universal_results[:message] && universal_results[:stack] && universal_results[:reason]
474
+ # logger.error "--- Error (#{universal_results[:reason]}) : #{universal_results[:message]}"
475
+ # error_message = "Test '#{test_name}' of '#{app_name}' " \
476
+ # "is failed! Details : #{universal_results[:message]}"
477
+ # raise Applitools::TestFailedError.new error_message, results if throw_exception
478
+ # return universal_results
479
+ # end
480
+ # key_transformed_results = Applitools::Utils.deep_stringify_keys(universal_results)
481
+ # results = key_transformed_results.map {|result| Applitools::TestResults.new(result) }
482
+ # results = results.first if results.size >= 1
483
+ #
484
+ # session_results_url = results.url
485
+ # # results = server_connector.stop_session running_session, false, save
486
+ # runner.aggregate_result(results) if runner
487
+ #
488
+ # # results.is_new = is_new_session
489
+ # # results.url = session_results_url
490
+ # save = results.new? && save_new_tests || !results.new? && failed && save_failed_tests
491
+ # logger.info "Automatically save test? #{save}"
492
+ #
493
+ # logger.info results.to_s(verbose_results)
494
+ #
495
+ # if results.unresolved?
496
+ # if results.new?
497
+ # logger.error "--- New test ended. see details at #{session_results_url}"
498
+ # error_message = "New test '#{test_name}' " \
499
+ # "of '#{app_name}' " \
500
+ # "Please approve the baseline at #{session_results_url} "
501
+ # raise Applitools::NewTestError.new error_message, results if throw_exception
502
+ # else
503
+ # logger.error "--- Differences are found. see details at #{session_results_url}"
504
+ # error_message = "Test '#{test_name}' " \
505
+ # "of '#{app_name}' " \
506
+ # "detected differences! See details at #{session_results_url}"
507
+ # raise Applitools::DiffsFoundError.new error_message, results if throw_exception
508
+ # end
509
+ # return results
510
+ # end
511
+ #
512
+ # if results.failed?
513
+ # logger.error "--- Failed test ended. see details at #{session_results_url}"
514
+ # error_message = "Test '#{test_name}' of '#{app_name}' " \
515
+ # "is failed! See details at #{session_results_url}"
516
+ # raise Applitools::TestFailedError.new error_message, results if throw_exception
517
+ # return results
518
+ # end
519
+
520
+ logger.info '--- Test passed'
521
+ self.results.push results
522
+
523
+ # match old style one result
524
+ if results.is_a?(Array) && results.first.is_a?(Applitools::TestResults)
525
+ return results.first if results.size >= 1
526
+ end
527
+ return results
528
+ ensure
529
+ self.running_session = nil
530
+ self.app_name = ''
531
+ end
532
+
533
+ def get_results(throw_exception = true)
534
+ if disabled?
535
+ logger.info "#{__method__} Ignored"
536
+ return false
537
+ end
538
+
539
+ self.open = false
540
+ self.last_screenshot = nil
541
+ clear_user_inputs
542
+
543
+ logger.info 'Getting results...'
544
+
466
545
  universal_results = universal_eyes.eyes_get_results # Array even for one test
467
546
  # require 'pry'
468
547
  # binding.pry
548
+ # error from universal server
549
+ if universal_results.is_a?(Hash) && universal_results[:message] && universal_results[:stack] && universal_results[:reason]
550
+ logger.error "--- Error (#{universal_results[:reason]}) : #{universal_results[:message]}"
551
+ error_message = "Test '#{test_name}' of '#{app_name}' " \
552
+ "is failed! Details : #{universal_results[:message]}"
553
+ raise Applitools::TestFailedError.new error_message, results if throw_exception
554
+ return universal_results
555
+ end
469
556
  key_transformed_results = Applitools::Utils.deep_stringify_keys(universal_results)
470
557
  results = key_transformed_results.map {|result| Applitools::TestResults.new(result) }
471
- results = results.first if results.size >= 1
558
+ # results = results.first if results.size >= 1
472
559
 
473
- session_results_url = results.url
560
+ session_results_url = results.first.url
474
561
  # results = server_connector.stop_session running_session, false, save
475
- runner.aggregate_result(results) if runner
562
+
563
+ results.each { |result| runner.aggregate_result(result) } if runner
476
564
 
477
565
  # results.is_new = is_new_session
478
566
  # results.url = session_results_url
479
- save = results.new? && save_new_tests || !results.new? && failed && save_failed_tests
567
+ save = (results.any?(&:new?) && save_new_tests) || (!results.any?(&:new?) && failed && save_failed_tests)
480
568
  logger.info "Automatically save test? #{save}"
481
569
 
482
- logger.info results.to_s(verbose_results)
570
+ logger.info results.first.to_s(verbose_results)
483
571
 
484
- if results.unresolved?
485
- if results.new?
572
+ if results.any?(&:unresolved?)
573
+ if results.any?(&:new?)
486
574
  logger.error "--- New test ended. see details at #{session_results_url}"
487
575
  error_message = "New test '#{test_name}' " \
488
576
  "of '#{app_name}' " \
@@ -498,16 +586,16 @@ module Applitools
498
586
  return results
499
587
  end
500
588
 
501
- if results.failed?
589
+ if results.any?(&:failed?)
502
590
  logger.error "--- Failed test ended. see details at #{session_results_url}"
503
591
  error_message = "Test '#{test_name}' of '#{app_name}' " \
504
- "is failed! See details at #{session_results_url}"
592
+ "is failed! See details at #{session_results_url}"
505
593
  raise Applitools::TestFailedError.new error_message, results if throw_exception
506
594
  return results
507
595
  end
508
596
 
509
- logger.info '--- Test passed'
510
- self.results.push results
597
+ # logger.info '--- Test passed'
598
+ # self.results.push results
511
599
  return results
512
600
  ensure
513
601
  self.running_session = nil
@@ -207,7 +207,15 @@ module Applitools
207
207
 
208
208
  # layoutBreakpoints?: boolean | number[]
209
209
  def layout_breakpoints=(value)
210
- config_hash[:layout_breakpoints] = (value.is_a?(Array) && value.all? {|v| v.is_a?(Numeric)}) ? value : !!value
210
+ config_hash[:layout_breakpoints] = { breakpoints: value } if value === true || value === false
211
+ config_hash[:layout_breakpoints] = { breakpoints: value } if value.is_a?(Array) && value.all? {|v| v.is_a?(Numeric)}
212
+ if value.is_a?(Hash)
213
+ if value.has_key?(:breakpoints) || value.has_key?('breakpoints')
214
+ config_hash[:layout_breakpoints] = value
215
+ else
216
+ config_hash[:layout_breakpoints] = { breakpoints: value }
217
+ end
218
+ end
211
219
  end
212
220
  def layout_breakpoints
213
221
  config_hash[:layout_breakpoints]
@@ -8,7 +8,7 @@ module Applitools
8
8
 
9
9
  def initialize
10
10
  self.batches_server_connectors_map = {}
11
- self.universal_client = Applitools::Connectivity::UniversalClient.new
11
+ self.universal_client = nil # eyes.open
12
12
  self.universal_eyes_manager = nil # eyes.open
13
13
  end
14
14
 
@@ -20,8 +20,9 @@ module Applitools
20
20
  batches_server_connectors_map.each_value { |v| v.call if v.respond_to? :call }
21
21
  end
22
22
 
23
- def get_universal_eyes_manager
23
+ def get_universal_eyes_manager(eyes=nil)
24
24
  return universal_eyes_manager if universal_eyes_manager
25
+ self.universal_client = Applitools::Connectivity::UniversalClient.new(eyes) if universal_client.nil?
25
26
  self.universal_eyes_manager = universal_client.make_manager(universal_eyes_manager_config.to_hash)
26
27
  end
27
28
 
@@ -2,11 +2,14 @@
2
2
 
3
3
  module Applitools
4
4
  class TestResultSummary
5
+ extend Forwardable
5
6
  attr_accessor :results, :passed, :unresolved, :failed, :exceptions, :mismatches, :missing, :matches
6
7
  attr_accessor :original_test_results
8
+ def_delegators :results, :[], :length
9
+
7
10
  def initialize(all_test_results)
8
11
  @original_test_results = all_test_results
9
- @results = all_test_results[:results]
12
+ @results = all_test_results[:results].map {|r| Applitools::TestResults.new(r) }
10
13
  @passed = all_test_results[:passed]
11
14
  @unresolved = all_test_results[:unresolved]
12
15
  @failed = all_test_results[:failed]
@@ -16,12 +19,9 @@ module Applitools
16
19
  @matches = all_test_results[:matches]
17
20
  end
18
21
 
19
- def old_style_results_array
20
- Applitools::Utils.deep_stringify_keys(results).map do |e|
21
- r = e['result'] ? e['result'] : {}
22
- r['isAborted'] = true unless e['error'].nil? # fix for get_all_test_results
23
- Applitools::TestResults.new(r)
24
- end
22
+ def to_a
23
+ @results
25
24
  end
25
+
26
26
  end
27
27
  end
@@ -17,9 +17,13 @@ module Applitools
17
17
  end
18
18
  end
19
19
  attr_accessor :is_new, :url, :screenshot
20
- attr_reader :status, :steps, :matches, :mismatches, :missing, :original_results
20
+ attr_reader :status, :steps, :matches, :mismatches, :missing, :original_results, :browser_info, :renderer
21
21
 
22
- def initialize(results = {})
22
+ def initialize(init_results = {})
23
+ environment = init_results[:environment] || {}
24
+ @renderer = Applitools::Utils.deep_stringify_keys(Applitools::Utils.underscore_hash_keys(environment[:requested]))
25
+ @browser_info = JSON.parse(@renderer.to_json, object_class: OpenStruct)
26
+ results = Applitools::Utils.deep_stringify_keys(init_results[:result] ? init_results[:result] : init_results)
23
27
  @original_results = results
24
28
  @steps = results.fetch('steps', 0)
25
29
  @matches = results.fetch('matches', 0)
@@ -30,6 +34,10 @@ module Applitools
30
34
  @url = results.fetch('url', nil)
31
35
  end
32
36
 
37
+ def test_results
38
+ self
39
+ end
40
+
33
41
  def passed?
34
42
  status == 'Passed'
35
43
  end
@@ -51,7 +59,7 @@ module Applitools
51
59
  end
52
60
 
53
61
  def aborted?
54
- original_results['isAborted']
62
+ original_results['isAborted'] || !errors.nil?
55
63
  end
56
64
 
57
65
  def api_session_url
@@ -66,6 +74,14 @@ module Applitools
66
74
  original_results['name']
67
75
  end
68
76
 
77
+ def errors
78
+ original_results['error']
79
+ end
80
+
81
+ def app_name
82
+ original_results['appName']
83
+ end
84
+
69
85
  def session_accessibility_status
70
86
  @accessibility_status ||= original_results['accessibilityStatus'] && AccessibilityStatus.new(original_results['accessibilityStatus'] || {})
71
87
  end
@@ -12,6 +12,7 @@ module Applitools
12
12
  return disabled_result if respond_to?(:disabled?) && disabled?
13
13
 
14
14
  raise Applitools::EyesNotOpenException.new('Eyes not open!') if @universal_eyes.nil?
15
+ raise Applitools::EyesNotOpenException.new('Eyes not open') unless open?
15
16
  Applitools::EyesLogger.logger.info "#{test_name} : check(#{name}) started ..."
16
17
  settings = get_universal_check_settings(name, target)
17
18
  image_target = settings[:image].nil? ? {} : { image: settings.delete(:image) }
@@ -24,7 +25,7 @@ module Applitools
24
25
  raise Applitools::EyesError.new("Request failed: #{check_result[:message]}")
25
26
  end
26
27
 
27
- if check_result != {}
28
+ if check_result != {} && !check_result.nil?
28
29
  result = Applitools::MatchResult.new(Applitools::Utils.deep_stringify_keys(check_result[0]))
29
30
 
30
31
  check_fail_result_processing(name) unless result.as_expected?
@@ -31,7 +31,7 @@ module Applitools
31
31
 
32
32
  update_config_from_options(options)
33
33
  universal_driver_config = driver.universal_driver_config if self.class.name != 'Applitools::Images::Eyes'
34
- universal_eyes_manager = runner.get_universal_eyes_manager
34
+ universal_eyes_manager = runner.get_universal_eyes_manager(self)
35
35
 
36
36
  universal_eyes_config = Applitools::UniversalEyesConfig.new
37
37
  universal_eyes_config.from_original_sdk(self)
@@ -43,6 +43,7 @@ module Applitools
43
43
  raise Applitools::EyesNotOpenException.new('Eyes not open!') if @universal_eyes.nil?
44
44
 
45
45
  self.open = true if respond_to?(:open=, true)
46
+ self.opened = true if respond_to?(:opened=, true)
46
47
  self.running_session = true if respond_to?(:running_session=, true)
47
48
  if self.class.name != 'Applitools::Images::Eyes'
48
49
  driver
@@ -61,6 +62,7 @@ module Applitools
61
62
  end
62
63
  # raise Applitools::EyesNotOpenException.new('Eyes not open!') if @eyes.nil?
63
64
  return if @universal_eyes.nil?
65
+ closed_or_aborted = @universal_eyes.closed_or_aborted
64
66
  @universal_eyes.abort
65
67
  result = @universal_eyes.eyes_get_results
66
68
  result = result[0] if result.is_a?(Array)
@@ -72,6 +74,8 @@ module Applitools
72
74
  # require('pry')
73
75
  # binding.pry
74
76
  end
77
+ return nil if closed_or_aborted
78
+ Applitools::Utils.deep_stringify_keys(result)
75
79
  end
76
80
 
77
81
  private
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: false
2
+
3
+ module Applitools
4
+ module EyesCore
5
+ VERSION = '6.0.0'.freeze
6
+ UNIVERSAL_VERSION = '4.3.0'.freeze
7
+ end
8
+
9
+ VERSION = Applitools::EyesCore::VERSION
10
+ end
@@ -8,6 +8,7 @@ require 'securerandom'
8
8
  require 'colorize'
9
9
  require 'websocket'
10
10
  require 'uri'
11
+ require 'eyes_universal'
11
12
 
12
13
 
13
14
  module Applitools::Connectivity
@@ -40,9 +41,9 @@ module Applitools::Connectivity
40
41
 
41
42
  attr_accessor :commands_config
42
43
 
43
- def initialize
44
+ def initialize(eyes=nil)
44
45
  # @socket = Applitools::Connectivity::UniversalClientSocket.new
45
- prepare_socket
46
+ prepare_socket(eyes)
46
47
  # store on open for next check calls
47
48
  @open_config = nil
48
49
  @commands_config = {
@@ -68,7 +69,7 @@ module Applitools::Connectivity
68
69
  # },
69
70
  # }
70
71
  ec_client_capabilities = {}
71
- ec_client_capabilities[:serverUrl] = server_url unless server_url.nil?
72
+ ec_client_capabilities[:ecServerUrl] = server_url unless server_url.nil?
72
73
  ec_client_capabilities[:apiKey] = api_key unless api_key.nil?
73
74
  ec_client_settings = {}
74
75
  ec_client_settings[:options] = ec_client_capabilities unless ec_client_capabilities.empty?
@@ -115,7 +116,7 @@ module Applitools::Connectivity
115
116
 
116
117
  def map_open_eyes_config_to_commands_config(config)
117
118
  [
118
- :serverUrl, :apiKey, :proxy, :connectionTimeout, :removeSession, :agentId, :appName, :testName, :displayName,
119
+ :eyesServerUrl, :apiKey, :proxy, :connectionTimeout, :removeSession, :agentId, :appName, :testName, :displayName,
119
120
  :userTestId, :sessionType, :properties, :batch, :keepBatchOpen, :environmentName, :environment, :branchName,
120
121
  :parentBranchName, :baselineEnvName, :baselineBranchName, :compareWithParentBranch, :ignoreBaseline,
121
122
  :ignoreGitBranching, :saveDiffs, :abortIdleTestTimeout
@@ -130,7 +131,7 @@ module Applitools::Connectivity
130
131
  config_mapping(config, commands_config[:check], k)
131
132
  end
132
133
 
133
- commands_config[:check][:renderers] = config.delete(:browsersInfo) unless config[:browsersInfo].nil?
134
+ commands_config[:check][:environments] = config.delete(:browsersInfo) unless config[:browsersInfo].nil?
134
135
 
135
136
  unless config[:defaultMatchSettings].nil?
136
137
  if config[:defaultMatchSettings][:accessibilitySettings]
@@ -326,6 +327,7 @@ module Applitools::Connectivity
326
327
  batch_ids = [close_batch_settings] if close_batch_settings.is_a?(String)
327
328
  batch_ids = close_batch_settings if close_batch_settings.is_a?(Array)
328
329
  optional = [:serverUrl, :apiKey, :proxy].map {|k| [k, @open_config[k]] }.to_h
330
+ optional[:eyesServerUrl] = optional.delete(:serverUrl) if optional[:serverUrl] # v4
329
331
  close_batch_settings = { settings: ({ batchIds: batch_ids }.merge(optional).compact) }
330
332
  end
331
333
  command_with_result(CORE_CLOSE_BATCHES, close_batch_settings)
@@ -342,11 +344,11 @@ module Applitools::Connectivity
342
344
  private
343
345
 
344
346
 
345
- def prepare_socket
346
- @universal_server_control = Applitools::Connectivity::UniversalServerControl.instance
347
+ def prepare_socket(eyes=nil)
348
+ @universal_server_control = Applitools::EyesUniversal::UniversalServerControl.instance
347
349
  @web_socket = @universal_server_control.new_server_socket_connection
348
350
  socket_handshake
349
- session_init
351
+ session_init(eyes)
350
352
  # connect_and_configure_socket(socket_uri)
351
353
  end
352
354
 
@@ -385,12 +387,26 @@ module Applitools::Connectivity
385
387
  @handshake_version = handshake.version if handshake.finished? && handshake.valid?
386
388
  end
387
389
 
388
- def session_init
390
+ def session_init(eyes=nil)
391
+ sdk_name = Applitools::EyesBase.environment_sdk[:name]
392
+ sdk_version = Applitools::EyesBase.environment_sdk[:currentVersion]
393
+ if eyes
394
+ if eyes.respond_to?(:environment_sdk)
395
+ sdk_name = eyes.environment_sdk[:name]
396
+ sdk_version = eyes.environment_sdk[:currentVersion]
397
+ elsif eyes.class.respond_to?(:environment_sdk)
398
+ sdk_name = eyes.class.environment_sdk[:name]
399
+ sdk_version = eyes.class.environment_sdk[:currentVersion]
400
+ end
401
+ end
389
402
  init_agent_id = "eyes.ruby-sdk/#{Applitools::VERSION}".freeze
390
403
  make_core_payload = {
391
404
  agentId: init_agent_id,
392
405
  cwd: Dir.pwd,
393
- spec: :webdriver
406
+ spec: :webdriver,
407
+ environment: {
408
+ sdk: {lang: :ruby, name: sdk_name, currentVersion: sdk_version}
409
+ }
394
410
  }
395
411
  # interface MakeCorePayload {
396
412
  # agentId: string
@@ -6,9 +6,12 @@ module Applitools
6
6
  extend Forwardable
7
7
  def_delegators 'Applitools::EyesLogger', :logger
8
8
 
9
+ attr_accessor :closed_or_aborted
10
+
9
11
  def initialize(eyes, universal_client)
10
12
  @eyes = eyes
11
13
  @universal_client = universal_client
14
+ @closed_or_aborted = false
12
15
  end
13
16
 
14
17
  def check(settings, image_target = {})
@@ -21,10 +24,12 @@ module Applitools
21
24
  end
22
25
 
23
26
  def close
27
+ @closed_or_aborted = true
24
28
  @universal_client.eyes_close(@eyes)
25
29
  end
26
30
 
27
31
  def abort
32
+ @closed_or_aborted = true
28
33
  @universal_client.eyes_abort(@eyes)
29
34
  end
30
35
 
@@ -20,7 +20,7 @@ module Applitools
20
20
  :debugScreenshots,
21
21
  :agentId,
22
22
  :apiKey,
23
- :serverUrl,
23
+ :eyesServerUrl,
24
24
  :proxy,
25
25
  :isDisabled,
26
26
  :connectionTimeout,
@@ -133,7 +133,7 @@ module Applitools
133
133
  # 23 + 3 + 2 + 11 = 39
134
134
  FROM_ORIGINAL_EYES = [:api_key, :app_name, :batch, :browsers_info, :concurrent_sessions, :debug_screenshots,
135
135
  :force_full_page_screenshot, :hide_caret, :hide_scrollbars, :host_app, :host_os, :match_timeout, :proxy,
136
- :save_failed_tests, :save_new_tests, :scale_ratio, :send_dom, :server_url, :stitch_mode, :test_name,
136
+ :save_failed_tests, :save_new_tests, :scale_ratio, :send_dom, :stitch_mode, :test_name,
137
137
  :viewport_size, :visual_grid_options, :wait_before_screenshots, :wait_before_capture] + [
138
138
  :disabled?, # disabled? => is_disabled
139
139
  :stitching_overlap, # SeleniumEyes.stitching_overlap => stitch_overlap
@@ -192,6 +192,7 @@ module Applitools
192
192
  # self.display_name = original_eyes.app_name
193
193
  self.dont_close_batches = original_eyes.dont_close_batches unless original_eyes.dont_close_batches.nil?
194
194
  prepare_for_json!
195
+ self.eyes_server_url = original_eyes.server_url unless original_eyes.server_url.nil? # v4api_change
195
196
  end
196
197
 
197
198
  def copy_from(what, from)
@@ -208,20 +209,20 @@ module Applitools
208
209
  self.default_match_settings = default_match_settings.to_hash if default_match_settings.is_a?(Applitools::ImageMatchSettings)
209
210
  self.proxy = proxy.to_hash if proxy.is_a?(Applitools::Connectivity::Proxy)
210
211
  self.viewport_size = viewport_size.to_h if viewport_size.is_a?(Applitools::RectangleSize)
211
- v3api_change
212
+ api_change
212
213
  # require 'pry'
213
214
  # binding.pry
214
215
  end
215
216
 
216
- def v3api_change
217
+ def api_change
217
218
  # self.updateBaselineIfDifferent = saveFailedTests unless saveFailedTests.nil?
218
219
  # self.updateBaselineIfNew = saveNewTests unless saveNewTests.nil?
219
220
  environment = {}
220
- environment[:hostApp] = hostApp unless hostApp.nil?
221
- environment[:hostAppInfo] = hostAppInfo unless hostAppInfo.nil?
222
- environment[:hostOS] = hostOS unless hostOS.nil?
223
- environment[:hostOSInfo] = hostOSInfo unless hostOSInfo.nil?
224
- environment[:deviceInfo] = deviceInfo unless deviceInfo.nil?
221
+ environment[:hostingApp] = hostApp unless hostApp.nil?
222
+ environment[:displayHostingApp] = hostAppInfo unless hostAppInfo.nil?
223
+ environment[:os] = hostOS unless hostOS.nil?
224
+ environment[:displayOs] = hostOSInfo unless hostOSInfo.nil?
225
+ environment[:deviceName] = deviceInfo unless deviceInfo.nil?
225
226
  unless viewportSize.nil?
226
227
  environment[:viewportSize] = viewportSize
227
228
  self.viewportSize = nil
@@ -38,7 +38,7 @@ module Applitools
38
38
  end
39
39
 
40
40
  def close_all_eyes(remove_duplicate_tests)
41
- @opened_eyes.each {|universal_eye| universal_eye.close }
41
+ @opened_eyes.each {|universal_eye| universal_eye.closed_or_aborted = true }
42
42
  @universal_client.eyes_manager_close_all_eyes(@manager, remove_duplicate_tests)
43
43
  end
44
44
 
data/lib/eyes_core.rb CHANGED
@@ -4,7 +4,6 @@ require 'forwardable'
4
4
  require 'delegate'
5
5
  require 'time'
6
6
  require_relative 'require_utils'
7
- require_relative 'eyes_consts'
8
7
 
9
8
  module Applitools
10
9
  extend Applitools::RequireUtils
@@ -64,8 +63,7 @@ end
64
63
 
65
64
  require_relative 'applitools/method_tracer'
66
65
  require_relative 'applitools/extensions'
67
- require_relative 'applitools/version'
68
- # require_relative 'applitools/chunky_png_patch'
66
+ require_relative 'applitools/eyes_core/version'
69
67
 
70
68
  Applitools.require_dir 'utils'
71
69
  Applitools.require_dir 'core'