percy-appium-app 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e78f2676c90003ca32a0a765f50825da64db7127bf7413c6836470b270323e92
4
- data.tar.gz: 30aa4ab566db291ff462d230f6ea1d2a78a37f8dd5da6968c44eea90aa3296de
3
+ metadata.gz: 8894474b866e7988f60b776f782f3c04887b4aa626cf2a384f2c97d983a534fc
4
+ data.tar.gz: 461ea9e2bf18840893f9b805ea93e8005874b4c9ddbcdf447d71e691051a015f
5
5
  SHA512:
6
- metadata.gz: e2dc8e58117d35b93c3239fece03898ebc4599d0bc0c0ce8694ac8a4924cea8109e58def6ac93a5853ce235ea6a20db231995a293ae6cd43740387cbb37c511f
7
- data.tar.gz: 82b18011008074818858a9120b25e026f34e7aac23bfc757155faaba52b6c033a00cc1aeba45710fdaca486506dc42d35cd0c21206516031ad14ac1c4f828e4c
6
+ metadata.gz: c91b292ad5b7a2ba6d04a64294d539caf6da3a9da7809663625a07f441563d242e00a37025ef2a96bdeafe3f604af7b286709676debeb18ca0834f22590e790c
7
+ data.tar.gz: e670e5434e2d4ace31348e736134f6976d8fa2bc1548febe7b7d70faeab6f057b833fc1809c84cf1c3b7b5a21922f41d75df3134b4fc7d2167a9354775da8d86
@@ -37,4 +37,4 @@ jobs:
37
37
  key: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/${{ hashFiles('**/Gemfile.lock') }}
38
38
  restore-keys: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/
39
39
  - run: bundle install
40
- - run: for file in specs/*.rb; do ruby $file; done
40
+ - run: for file in specs/*.rb; do echo $file; bundle exec ruby $file; done
@@ -2,14 +2,13 @@
2
2
 
3
3
  require 'dotenv/load'
4
4
 
5
- PERCY_LOGLEVEL = ENV['PERCY_LOGLEVEL']
6
- PERCY_DEBUG = PERCY_LOGLEVEL == 'debug'
7
- LABEL = "[\e[35m#{PERCY_DEBUG ? 'percy:ruby' : 'percy'}\e[39m]"
8
5
 
9
6
  def log(message, on_debug: nil)
10
- return unless on_debug.nil? || (on_debug.is_a?(TrueClass) && PERCY_DEBUG)
7
+ return unless on_debug.nil? || (on_debug.is_a?(TrueClass) && percy_debug)
11
8
 
12
- puts "#{LABEL} #{message}"
9
+ label = "[\e[35m#{percy_debug ? 'percy:ruby' : 'percy'}\e[39m]"
10
+
11
+ puts "#{label} #{message}"
13
12
  end
14
13
 
15
14
  def hashed(object)
@@ -17,3 +16,7 @@ def hashed(object)
17
16
 
18
17
  object
19
18
  end
19
+
20
+ def percy_debug
21
+ ENV['PERCY_LOGLEVEL'] == 'debug'
22
+ end
@@ -103,7 +103,10 @@ module Percy
103
103
  return @device_info unless @device_info.empty?
104
104
 
105
105
  @device_info = DEVICE_INFO[device_name.downcase] || {}
106
- log("#{device_name.downcase} does not exist in config.") if @device_info.empty?
106
+ if @device_info.empty?
107
+ log("#{device_name.downcase} does not exist in config. Making driver call to get the device info.",
108
+ on_debug: true)
109
+ end
107
110
  @device_info
108
111
  end
109
112
  end
@@ -106,8 +106,8 @@ module Percy
106
106
 
107
107
  def get_region_object(selector, element)
108
108
  scale_factor = metadata.scale_factor
109
- location = hashed(element.location)
110
- size = hashed(element.size)
109
+ location = { 'x' => element.location.x, 'y' => element.location.y }
110
+ size = { 'height' => element.size.height, 'width' => element.size.width }
111
111
  coordinates = {
112
112
  'top' => location['y'] * scale_factor,
113
113
  'bottom' => (location['y'] + size['height']) * scale_factor,
@@ -133,7 +133,9 @@ module Percy
133
133
 
134
134
  def get_regions_by_ids(elements_array, ids)
135
135
  ids.each do |id|
136
- element = driver.find_element(Appium::Core::Base::SearchContext::FINDERS[:accessibility_id], id)
136
+ # Appium::Core::Base::SearchContext::FINDERS[:xpath] returns `accessibility id`
137
+ # instead of `:accessibility_id`, causes error
138
+ element = driver.find_element(:accessibility_id, id)
137
139
  selector = "id: #{id}"
138
140
  region = get_region_object(selector, element)
139
141
  elements_array << region
data/percy/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Percy
4
- VERSION = '0.0.5'.freeze
4
+ VERSION = '0.0.7'.freeze
5
5
  end
@@ -233,8 +233,10 @@ class TestGenericProvider < Minitest::Test
233
233
 
234
234
  def test_get_region_object
235
235
  mock_element = Minitest::Mock.new
236
- mock_element.expect(:location, { 'x' => 10, 'y' => 20 })
237
- mock_element.expect(:size, { 'width' => 100, 'height' => 200 })
236
+ 2.times do
237
+ mock_element.expect(:location, Selenium::WebDriver::Point.new(10, 20))
238
+ mock_element.expect(:size, Selenium::WebDriver::Dimension.new(100, 200))
239
+ end
238
240
 
239
241
  result = @generic_provider.get_region_object('my-selector', mock_element)
240
242
  expected_result = {
@@ -248,8 +250,10 @@ class TestGenericProvider < Minitest::Test
248
250
 
249
251
  def test_get_regions_by_xpath
250
252
  mock_element = Minitest::Mock.new
251
- mock_element.expect(:location, { 'x' => 10, 'y' => 20 })
252
- mock_element.expect(:size, { 'width' => 100, 'height' => 200 })
253
+ 2.times do
254
+ mock_element.expect(:location, Selenium::WebDriver::Point.new(10, 20))
255
+ mock_element.expect(:size, Selenium::WebDriver::Dimension.new(100, 200))
256
+ end
253
257
 
254
258
  @mock_webdriver.expect(:find_element, mock_element,
255
259
  [Appium::Core::Base::SearchContext::FINDERS[:xpath], '//path/to/element'])
@@ -279,11 +283,12 @@ class TestGenericProvider < Minitest::Test
279
283
 
280
284
  def test_get_regions_by_ids
281
285
  mock_element = Minitest::Mock.new
282
- mock_element.expect(:location, { 'x' => 10, 'y' => 20 })
283
- mock_element.expect(:size, { 'width' => 100, 'height' => 200 })
286
+ 2.times do
287
+ mock_element.expect(:location, Selenium::WebDriver::Point.new(10, 20))
288
+ mock_element.expect(:size, Selenium::WebDriver::Dimension.new(100, 200))
289
+ end
284
290
 
285
- @mock_webdriver.expect(:find_element, mock_element,
286
- [Appium::Core::Base::SearchContext::FINDERS[:accessibility_id], 'some_id'])
291
+ @mock_webdriver.expect(:find_element, mock_element, [:accessibility_id, 'some_id'])
287
292
 
288
293
  elements_array = []
289
294
  ids = ['some_id']
@@ -299,8 +304,10 @@ class TestGenericProvider < Minitest::Test
299
304
 
300
305
  def test_get_regions_by_ids_with_non_existing_element
301
306
  mock_element = Minitest::Mock.new
302
- mock_element.expect(:location, { 'x' => 10, 'y' => 20 })
303
- mock_element.expect(:size, { 'width' => 100, 'height' => 200 })
307
+ 2.times do
308
+ mock_element.expect(:location, Selenium::WebDriver::Point.new(10, 20))
309
+ mock_element.expect(:size, Selenium::WebDriver::Dimension.new(100, 200))
310
+ end
304
311
 
305
312
  @mock_webdriver.expect(:find_element, [Appium::Core::Base::SearchContext::FINDERS[:accessibility_id], 'id1']) do
306
313
  raise Appium::Core::Error::NoSuchElementError, 'Test error'
@@ -315,8 +322,10 @@ class TestGenericProvider < Minitest::Test
315
322
 
316
323
  def test_get_regions_by_elements
317
324
  mock_element = Minitest::Mock.new
318
- mock_element.expect(:location, { 'x' => 10, 'y' => 20 })
319
- mock_element.expect(:size, { 'width' => 100, 'height' => 200 })
325
+ 2.times do
326
+ mock_element.expect(:location, Selenium::WebDriver::Point.new(10, 20))
327
+ mock_element.expect(:size, Selenium::WebDriver::Dimension.new(100, 200))
328
+ end
320
329
  mock_element.expect(:attribute, 'textView', ['class'])
321
330
 
322
331
  elements_array = []
data/specs/metadata.rb CHANGED
@@ -28,11 +28,39 @@ class TestMetadata < Minitest::Test
28
28
  ENV['PERCY_LOGLEVEL'] = 'debug'
29
29
  end
30
30
 
31
- def test_get_device_info_device_not_present
31
+ def test_get_device_info_device_not_present_when_log_level_is_debug
32
+ # redirecting the standard output temporarily and capture the output in a string.
33
+ captured_output = StringIO.new
34
+ $stdout = captured_output
35
+ ENV['PERCY_LOGLEVEL'] = 'debug'
32
36
  device_name = 'Some Phone 123'
33
- assert_output(/#{Regexp.escape(device_name.downcase)} does not exist in config\./) do
34
- @metadata.get_device_info(device_name)
35
- end
37
+ @metadata.get_device_info(device_name)
38
+ # Restore standard output
39
+ $stdout = STDOUT
40
+
41
+ # Get the captured output as a string
42
+ output = captured_output.string
43
+ regex_pattern = /#{Regexp.escape(device_name.downcase)} does not exist in config\. Making driver call to get the device info\./
44
+
45
+ assert_match(regex_pattern, output)
46
+ ENV['PERCY_LOGLEVEL'] = nil
47
+ end
48
+
49
+ def test_get_device_info_device_not_present_when_log_level_is_info
50
+ # redirecting the standard output temporarily and capture the output in a string.
51
+ captured_output = StringIO.new
52
+ $stdout = captured_output
53
+ ENV['PERCY_LOGLEVEL'] = nil
54
+ device_name = 'Some Phone 123'
55
+ @metadata.get_device_info(device_name)
56
+
57
+ # Restore standard output
58
+ $stdout = STDOUT
59
+
60
+ # Get the captured output as a string
61
+ output = captured_output.string
62
+
63
+ assert_equal(output, '')
36
64
  end
37
65
 
38
66
  def test_metadata_get_orientation
data/specs/screenshot.rb CHANGED
@@ -339,8 +339,10 @@ class TestPercyScreenshot < Minitest::Test
339
339
  mock_screenshot
340
340
 
341
341
  mock_element = Minitest::Mock.new
342
- mock_element.expect(:location, { 'x' => 10, 'y' => 20 })
343
- mock_element.expect(:size, { 'width' => 200, 'height' => 400 })
342
+ 2.times do
343
+ mock_element.expect(:location, Selenium::WebDriver::Point.new(10, 20))
344
+ mock_element.expect(:size, Selenium::WebDriver::Dimension.new(200, 400))
345
+ end
344
346
 
345
347
  xpaths = ['//path/to/element']
346
348
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percy-appium-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - BroswerStack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appium_lib