percy-appium-app 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +191 -1
- data/percy/environment.rb +15 -13
- data/percy/exceptions/exceptions.rb +0 -2
- data/percy/lib/app_percy.rb +36 -34
- data/percy/lib/cache.rb +42 -41
- data/percy/lib/cli_wrapper.rb +94 -92
- data/percy/lib/ignore_region.rb +4 -3
- data/percy/lib/percy_automate.rb +44 -42
- data/percy/lib/percy_options.rb +30 -28
- data/percy/lib/region.rb +15 -13
- data/percy/lib/tile.rb +24 -22
- data/percy/metadata/android_metadata.rb +60 -58
- data/percy/metadata/driver_metadata.rb +29 -27
- data/percy/metadata/ios_metadata.rb +64 -62
- data/percy/metadata/metadata.rb +80 -78
- data/percy/metadata/metadata_resolver.rb +14 -12
- data/percy/{screenshot.rb → percy-appium-app.rb} +3 -3
- data/percy/providers/app_automate.rb +131 -129
- data/percy/providers/generic_provider.rb +166 -164
- data/percy/providers/provider_resolver.rb +9 -7
- data/percy/version.rb +1 -1
- data/percy-appium-app.gemspec +1 -0
- data/specs/android_metadata.rb +2 -4
- data/specs/app_automate.rb +10 -13
- data/specs/app_percy.rb +20 -22
- data/specs/cache.rb +16 -16
- data/specs/cli_wrapper.rb +6 -8
- data/specs/driver_metadata.rb +2 -4
- data/specs/generic_providers.rb +9 -12
- data/specs/ignore_regions.rb +10 -12
- data/specs/ios_metadata.rb +2 -2
- data/specs/metadata.rb +2 -5
- data/specs/metadata_resolver.rb +6 -6
- data/specs/mocks/mock_methods.rb +0 -2
- data/specs/percy_options.rb +16 -16
- data/specs/screenshot.rb +7 -10
- data/specs/tile.rb +2 -2
- metadata +17 -3
data/specs/cache.rb
CHANGED
@@ -5,52 +5,52 @@ require 'minitest/mock'
|
|
5
5
|
require 'time'
|
6
6
|
require_relative '../percy/lib/cache'
|
7
7
|
|
8
|
-
# Test suite for the Cache class
|
8
|
+
# Test suite for the Percy::Cache class
|
9
9
|
class TestCache < Minitest::Test
|
10
10
|
def setup
|
11
|
-
@cache = Cache.new
|
11
|
+
@cache = Percy::Cache.new
|
12
12
|
@session_id = 'session_id_123'
|
13
13
|
@prop = 'window_size'
|
14
14
|
@value = { 'top' => 'Top Value' }
|
15
|
-
Cache.set_cache(@session_id, @prop, @value)
|
15
|
+
Percy::Cache.set_cache(@session_id, @prop, @value)
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_set_cache
|
19
|
-
assert_raises(Exception) { Cache.set_cache(123, 123, 123) }
|
20
|
-
assert_raises(Exception) { Cache.set_cache(@session_id, 123, 123) }
|
19
|
+
assert_raises(Exception) { Percy::Cache.set_cache(123, 123, 123) }
|
20
|
+
assert_raises(Exception) { Percy::Cache.set_cache(@session_id, 123, 123) }
|
21
21
|
|
22
22
|
assert_includes @cache.cache, @session_id
|
23
23
|
assert_equal @cache.cache[@session_id][@prop], @value
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_get_cache_invalid_args
|
27
|
-
assert_raises(Exception) { Cache.get_cache(123, 123) }
|
28
|
-
assert_raises(Exception) { Cache.get_cache(@session_id, 123) }
|
27
|
+
assert_raises(Exception) { Percy::Cache.get_cache(123, 123) }
|
28
|
+
assert_raises(Exception) { Percy::Cache.get_cache(@session_id, 123) }
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_get_cache_success
|
32
32
|
mock_cleanup_cache = Minitest::Mock.new
|
33
33
|
mock_cleanup_cache.expect(:call, nil)
|
34
34
|
|
35
|
-
Cache.stub(:cleanup_cache, -> { mock_cleanup_cache.call }) do
|
36
|
-
window_size = Cache.get_cache(@session_id, @prop)
|
35
|
+
Percy::Cache.stub(:cleanup_cache, -> { mock_cleanup_cache.call }) do
|
36
|
+
window_size = Percy::Cache.get_cache(@session_id, @prop)
|
37
37
|
assert_equal @value, window_size
|
38
38
|
mock_cleanup_cache.verify
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_cleanup_cache
|
43
|
-
previous_value = Cache::CACHE_TIMEOUT
|
44
|
-
Cache.send(:remove_const, :CACHE_TIMEOUT)
|
45
|
-
Cache.const_set(:CACHE_TIMEOUT, 1)
|
43
|
+
previous_value = Percy::Cache::CACHE_TIMEOUT
|
44
|
+
Percy::Cache.send(:remove_const, :CACHE_TIMEOUT)
|
45
|
+
Percy::Cache.const_set(:CACHE_TIMEOUT, 1)
|
46
46
|
|
47
|
-
cache_timeout = Cache::CACHE_TIMEOUT
|
47
|
+
cache_timeout = Percy::Cache::CACHE_TIMEOUT
|
48
48
|
sleep(cache_timeout + 1)
|
49
49
|
assert_includes @cache.cache, @session_id
|
50
|
-
Cache.cleanup_cache
|
50
|
+
Percy::Cache.cleanup_cache
|
51
51
|
refute_includes @cache.cache, @session_id
|
52
52
|
|
53
|
-
Cache.send(:remove_const, :CACHE_TIMEOUT)
|
54
|
-
Cache.const_set(:CACHE_TIMEOUT, previous_value)
|
53
|
+
Percy::Cache.send(:remove_const, :CACHE_TIMEOUT)
|
54
|
+
Percy::Cache.const_set(:CACHE_TIMEOUT, previous_value)
|
55
55
|
end
|
56
56
|
end
|
data/specs/cli_wrapper.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
4
|
-
|
5
3
|
require 'minitest/autorun'
|
6
4
|
require 'webmock/minitest'
|
7
5
|
require 'json'
|
@@ -18,10 +16,10 @@ def mock_poa_screenshot(fail: false)
|
|
18
16
|
.to_return(body: "{\"success\": #{fail ? 'false, "error": "test"' : 'true'}}", status: (fail ? 500 : 200))
|
19
17
|
end
|
20
18
|
|
21
|
-
# Test suite for the CLIWrapper class
|
19
|
+
# Test suite for the Percy::CLIWrapper class
|
22
20
|
class TestCLIWrapper < Minitest::Test
|
23
21
|
def setup
|
24
|
-
@cli_wrapper = CLIWrapper.new
|
22
|
+
@cli_wrapper = Percy::CLIWrapper.new
|
25
23
|
@ignored_elements_data = {
|
26
24
|
'ignore_elements_data' => {
|
27
25
|
'selector' => 'xpath: some_xpath',
|
@@ -85,7 +83,7 @@ class TestCLIWrapper < Minitest::Test
|
|
85
83
|
mock_screenshot
|
86
84
|
|
87
85
|
assert_equal(
|
88
|
-
@cli_wrapper.post_screenshots('some-name', {}, [Tile.new(10, 10, 20, 20, filepath: 'some-file-path')],
|
86
|
+
@cli_wrapper.post_screenshots('some-name', {}, [Percy::Tile.new(10, 10, 20, 20, filepath: 'some-file-path')],
|
89
87
|
'some-debug-url'),
|
90
88
|
{ 'link' => 'snapshot-url-link', 'success' => true }
|
91
89
|
)
|
@@ -95,14 +93,14 @@ class TestCLIWrapper < Minitest::Test
|
|
95
93
|
mock_screenshot
|
96
94
|
|
97
95
|
assert_equal(
|
98
|
-
@cli_wrapper.post_screenshots('some-name', {}, [Tile.new(10, 10, 20, 20, filepath: 'some-file-path')],
|
96
|
+
@cli_wrapper.post_screenshots('some-name', {}, [Percy::Tile.new(10, 10, 20, 20, filepath: 'some-file-path')],
|
99
97
|
'some-debug-url', @ignored_elements_data),
|
100
98
|
{ 'link' => 'snapshot-url-link', 'success' => true }
|
101
99
|
)
|
102
100
|
end
|
103
101
|
|
104
102
|
def test_request_body
|
105
|
-
tile = Tile.new(10, 10, 20, 20, filepath: 'some-file-path')
|
103
|
+
tile = Percy::Tile.new(10, 10, 20, 20, filepath: 'some-file-path')
|
106
104
|
tag = { 'name' => 'Tag' }
|
107
105
|
name = 'some-name'
|
108
106
|
debug_url = 'debug-url'
|
@@ -117,7 +115,7 @@ class TestCLIWrapper < Minitest::Test
|
|
117
115
|
end
|
118
116
|
|
119
117
|
def test_request_body_when_optional_values_are_null
|
120
|
-
tile = Tile.new(10, 10, 20, 20, filepath: 'some-file-path')
|
118
|
+
tile = Percy::Tile.new(10, 10, 20, 20, filepath: 'some-file-path')
|
121
119
|
tag = { 'name' => 'Tag' }
|
122
120
|
name = 'some-name'
|
123
121
|
debug_url = nil
|
data/specs/driver_metadata.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
4
|
-
|
5
3
|
require 'minitest/autorun'
|
6
4
|
require 'minitest/mock'
|
7
5
|
require 'appium_lib'
|
8
6
|
|
9
7
|
require_relative '../percy/metadata/driver_metadata'
|
10
8
|
|
11
|
-
# Test suite for the DriverMetadata class
|
9
|
+
# Test suite for the Percy::DriverMetadata class
|
12
10
|
class TestDriverMetadata < Minitest::Test
|
13
11
|
def setup
|
14
12
|
@mock_webdriver = Minitest::Mock.new
|
@@ -16,7 +14,7 @@ class TestDriverMetadata < Minitest::Test
|
|
16
14
|
@bridge = Minitest::Mock.new
|
17
15
|
@server_url = Minitest::Mock.new
|
18
16
|
|
19
|
-
@metadata = DriverMetadata.new(@mock_webdriver)
|
17
|
+
@metadata = Percy::DriverMetadata.new(@mock_webdriver)
|
20
18
|
end
|
21
19
|
|
22
20
|
def test_session_id
|
data/specs/generic_providers.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
4
|
-
# rubocop:disable Metrics/AbcSize
|
5
|
-
|
6
3
|
require 'minitest/autorun'
|
7
4
|
require 'securerandom'
|
8
5
|
require 'appium_lib'
|
@@ -11,7 +8,7 @@ require_relative '../percy/metadata/android_metadata'
|
|
11
8
|
require_relative '../percy/lib/region'
|
12
9
|
require_relative 'mocks/mock_methods'
|
13
10
|
|
14
|
-
# Test suite for the GenericProvider class
|
11
|
+
# Test suite for the Percy::GenericProvider class
|
15
12
|
class TestGenericProvider < Minitest::Test
|
16
13
|
include Appium
|
17
14
|
COMPARISON_RESPONSE = { 'comparison' => { 'id' => 123, 'url' => 'https://percy-build-url' } }.freeze
|
@@ -31,8 +28,8 @@ class TestGenericProvider < Minitest::Test
|
|
31
28
|
png_bytes = 'some random bytes'
|
32
29
|
@mock_webdriver.expect(:screenshot_as, png_bytes, [:png])
|
33
30
|
|
34
|
-
@android_metadata = AndroidMetadata.new(@mock_webdriver)
|
35
|
-
@generic_provider = GenericProvider.new(@mock_webdriver, @android_metadata)
|
31
|
+
@android_metadata = Percy::AndroidMetadata.new(@mock_webdriver)
|
32
|
+
@generic_provider = Percy::GenericProvider.new(@mock_webdriver, @android_metadata)
|
36
33
|
end
|
37
34
|
|
38
35
|
def teardown
|
@@ -166,13 +163,13 @@ class TestGenericProvider < Minitest::Test
|
|
166
163
|
@mock_webdriver.expect(:capabilities, get_android_capabilities)
|
167
164
|
end
|
168
165
|
|
169
|
-
Metadata.class_eval do
|
166
|
+
Percy::Metadata.class_eval do
|
170
167
|
define_method(:session_id) do
|
171
168
|
mock.session_id
|
172
169
|
end
|
173
170
|
end
|
174
171
|
|
175
|
-
AndroidMetadata.class_eval do
|
172
|
+
Percy::AndroidMetadata.class_eval do
|
176
173
|
6.times do
|
177
174
|
define_method(:get_system_bars) do
|
178
175
|
mock.get_system_bars
|
@@ -192,7 +189,7 @@ class TestGenericProvider < Minitest::Test
|
|
192
189
|
end
|
193
190
|
|
194
191
|
def test_supports
|
195
|
-
assert GenericProvider.supports('some-dummy-url')
|
192
|
+
assert Percy::GenericProvider.supports('some-dummy-url')
|
196
193
|
end
|
197
194
|
|
198
195
|
def test_non_app_automate
|
@@ -202,7 +199,7 @@ class TestGenericProvider < Minitest::Test
|
|
202
199
|
mock.expect(:session_id, session_id)
|
203
200
|
end
|
204
201
|
|
205
|
-
Metadata.class_eval do
|
202
|
+
Percy::Metadata.class_eval do
|
206
203
|
4.times do
|
207
204
|
define_method(:session_id) do
|
208
205
|
mock.session_id
|
@@ -353,8 +350,8 @@ class TestGenericProvider < Minitest::Test
|
|
353
350
|
@mock_webdriver.expect(:capabilities, get_android_capabilities)
|
354
351
|
@mock_webdriver.expect(:capabilities, get_android_capabilities)
|
355
352
|
@mock_webdriver.expect(:capabilities, get_android_capabilities)
|
356
|
-
valid_ignore_region = Region.new(100, 200, 200, 300)
|
357
|
-
invalid_ignore_region = Region.new(100, 2390, 200, 300)
|
353
|
+
valid_ignore_region = Percy::Region.new(100, 200, 200, 300)
|
354
|
+
invalid_ignore_region = Percy::Region.new(100, 2390, 200, 300)
|
358
355
|
|
359
356
|
elements_array = []
|
360
357
|
custom_locations = [valid_ignore_region, invalid_ignore_region]
|
data/specs/ignore_regions.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
4
|
-
|
5
3
|
require 'minitest/autorun'
|
6
4
|
require_relative '../percy/lib/ignore_region'
|
7
5
|
|
@@ -12,7 +10,7 @@ class TestIgnoreRegion < Minitest::Test
|
|
12
10
|
bottom = 20
|
13
11
|
left = 30
|
14
12
|
right = 40
|
15
|
-
ignore_region = IgnoreRegion.new(top, bottom, left, right)
|
13
|
+
ignore_region = Percy::IgnoreRegion.new(top, bottom, left, right)
|
16
14
|
|
17
15
|
assert_equal ignore_region.top, top
|
18
16
|
assert_equal ignore_region.bottom, bottom
|
@@ -21,29 +19,29 @@ class TestIgnoreRegion < Minitest::Test
|
|
21
19
|
end
|
22
20
|
|
23
21
|
def test_ignore_region_negative_input
|
24
|
-
assert_raises(ArgumentError) { IgnoreRegion.new(-10, 20, 30, 40) }
|
25
|
-
assert_raises(ArgumentError) { IgnoreRegion.new(10, 20, -30, 40) }
|
26
|
-
assert_raises(ArgumentError) { IgnoreRegion.new(10, 20, 30, -40) }
|
27
|
-
assert_raises(ArgumentError) { IgnoreRegion.new(-10, -20, -30, -40) }
|
22
|
+
assert_raises(ArgumentError) { Percy::IgnoreRegion.new(-10, 20, 30, 40) }
|
23
|
+
assert_raises(ArgumentError) { Percy::IgnoreRegion.new(10, 20, -30, 40) }
|
24
|
+
assert_raises(ArgumentError) { Percy::IgnoreRegion.new(10, 20, 30, -40) }
|
25
|
+
assert_raises(ArgumentError) { Percy::IgnoreRegion.new(-10, -20, -30, -40) }
|
28
26
|
end
|
29
27
|
|
30
28
|
def test_ignore_region_invalid_input
|
31
|
-
assert_raises(ArgumentError) { IgnoreRegion.new(20, 10, 30, 40) } # bottom < top
|
32
|
-
assert_raises(ArgumentError) { IgnoreRegion.new(10, 20, 40, 30) } # right < left
|
29
|
+
assert_raises(ArgumentError) { Percy::IgnoreRegion.new(20, 10, 30, 40) } # bottom < top
|
30
|
+
assert_raises(ArgumentError) { Percy::IgnoreRegion.new(10, 20, 40, 30) } # right < left
|
33
31
|
end
|
34
32
|
|
35
33
|
def test_ignore_region_is_valid
|
36
|
-
ignore_region = IgnoreRegion.new(10, 20, 30, 40)
|
34
|
+
ignore_region = Percy::IgnoreRegion.new(10, 20, 30, 40)
|
37
35
|
screen_height = 100
|
38
36
|
screen_width = 200
|
39
37
|
assert_equal true, ignore_region.valid?(screen_height, screen_width)
|
40
38
|
|
41
|
-
ignore_region = IgnoreRegion.new(10, 200, 30, 400)
|
39
|
+
ignore_region = Percy::IgnoreRegion.new(10, 200, 30, 400)
|
42
40
|
height = 100
|
43
41
|
width = 200
|
44
42
|
assert_equal false, ignore_region.valid?(height, width)
|
45
43
|
|
46
|
-
ignore_region = IgnoreRegion.new(10, 20, 30, 40)
|
44
|
+
ignore_region = Percy::IgnoreRegion.new(10, 20, 30, 40)
|
47
45
|
screen_height = 5
|
48
46
|
screen_width = 10
|
49
47
|
assert_equal false, ignore_region.valid?(screen_height, screen_width)
|
data/specs/ios_metadata.rb
CHANGED
@@ -5,14 +5,14 @@ require 'minitest/mock'
|
|
5
5
|
require_relative 'mocks/mock_methods'
|
6
6
|
require_relative '../percy/metadata/ios_metadata'
|
7
7
|
|
8
|
-
# Test suite for the IOSMetadata class
|
8
|
+
# Test suite for the Percy::IOSMetadata class
|
9
9
|
class TestIOSMetadata < Minitest::Test
|
10
10
|
def setup
|
11
11
|
@mock_webdriver = Minitest::Mock.new
|
12
12
|
@bridge = Minitest::Mock.new
|
13
13
|
@http = Minitest::Mock.new
|
14
14
|
@server_url = Minitest::Mock.new
|
15
|
-
@ios_metadata = IOSMetadata.new(@mock_webdriver)
|
15
|
+
@ios_metadata = Percy::IOSMetadata.new(@mock_webdriver)
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_ios_execute_script
|
data/specs/metadata.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
4
|
-
# rubocop:disable Metrics/AbcSize
|
5
|
-
|
6
3
|
require 'minitest/autorun'
|
7
4
|
require_relative '../percy/metadata/metadata'
|
8
5
|
|
9
|
-
# Test suite for the Metadata class
|
6
|
+
# Test suite for the Percy::Metadata class
|
10
7
|
class TestMetadata < Minitest::Test
|
11
8
|
def setup
|
12
9
|
@mock_webdriver = Minitest::Mock.new
|
13
|
-
@metadata = Metadata.new(@mock_webdriver)
|
10
|
+
@metadata = Percy::Metadata.new(@mock_webdriver)
|
14
11
|
end
|
15
12
|
|
16
13
|
def test_metadata_properties
|
data/specs/metadata_resolver.rb
CHANGED
@@ -6,7 +6,7 @@ require_relative '../percy/metadata/android_metadata'
|
|
6
6
|
require_relative '../percy/metadata/ios_metadata'
|
7
7
|
require_relative '../percy/metadata/metadata_resolver'
|
8
8
|
|
9
|
-
# Test suite for the MetadataResolver class
|
9
|
+
# Test suite for the Percy::MetadataResolver class
|
10
10
|
class MetadataResolverTestCase < Minitest::Test
|
11
11
|
def setup
|
12
12
|
@mock_webdriver = Minitest::Mock.new
|
@@ -15,17 +15,17 @@ class MetadataResolverTestCase < Minitest::Test
|
|
15
15
|
def test_android_resolved
|
16
16
|
@mock_webdriver.expect(:capabilities, { 'platformName' => 'Android' })
|
17
17
|
@mock_webdriver.expect(:capabilities, { 'platformName' => 'Android' })
|
18
|
-
resolved_metadata = MetadataResolver.resolve(@mock_webdriver)
|
18
|
+
resolved_metadata = Percy::MetadataResolver.resolve(@mock_webdriver)
|
19
19
|
|
20
|
-
assert_instance_of(AndroidMetadata, resolved_metadata)
|
20
|
+
assert_instance_of(Percy::AndroidMetadata, resolved_metadata)
|
21
21
|
@mock_webdriver.verify
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_ios_resolved
|
25
25
|
@mock_webdriver.expect(:capabilities, { 'platformName' => 'iOS' })
|
26
|
-
resolved_metadata = MetadataResolver.resolve(@mock_webdriver)
|
26
|
+
resolved_metadata = Percy::MetadataResolver.resolve(@mock_webdriver)
|
27
27
|
|
28
|
-
assert_instance_of(IOSMetadata, resolved_metadata)
|
28
|
+
assert_instance_of(Percy::IOSMetadata, resolved_metadata)
|
29
29
|
@mock_webdriver.verify
|
30
30
|
end
|
31
31
|
|
@@ -33,7 +33,7 @@ class MetadataResolverTestCase < Minitest::Test
|
|
33
33
|
@mock_webdriver.expect(:capabilities, { 'platformName' => 'Something Random' })
|
34
34
|
|
35
35
|
assert_raises(Exception) do
|
36
|
-
MetadataResolver.resolve(@mock_webdriver)
|
36
|
+
Percy::MetadataResolver.resolve(@mock_webdriver)
|
37
37
|
end
|
38
38
|
|
39
39
|
@mock_webdriver.verify
|
data/specs/mocks/mock_methods.rb
CHANGED
data/specs/percy_options.rb
CHANGED
@@ -4,110 +4,110 @@ require 'minitest/autorun'
|
|
4
4
|
require 'minitest/mock'
|
5
5
|
require_relative '../percy/lib/percy_options'
|
6
6
|
|
7
|
-
# Test suite for the PercyOptions class
|
7
|
+
# Test suite for the Percy::PercyOptions class
|
8
8
|
class TestPercyOptions < Minitest::Test
|
9
9
|
# Defaults
|
10
10
|
def test_percy_options_not_provided
|
11
11
|
capabilities = {}
|
12
|
-
percy_options = PercyOptions.new(capabilities)
|
12
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
13
13
|
assert_equal true, percy_options.enabled
|
14
14
|
assert_equal true, percy_options.ignore_errors
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_percy_options_w3c_enabled
|
18
18
|
capabilities = { 'percy:options' => { 'enabled' => true } }
|
19
|
-
percy_options = PercyOptions.new(capabilities)
|
19
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
20
20
|
assert_equal true, percy_options.enabled
|
21
21
|
assert_equal true, percy_options.ignore_errors
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_percy_options_json_wire_enabled
|
25
25
|
capabilities = { 'percy.enabled' => true }
|
26
|
-
percy_options = PercyOptions.new(capabilities)
|
26
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
27
27
|
assert_equal true, percy_options.enabled
|
28
28
|
assert_equal true, percy_options.ignore_errors
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_percy_options_w3c_not_enabled
|
32
32
|
capabilities = { 'percy:options' => { 'enabled' => false } }
|
33
|
-
percy_options = PercyOptions.new(capabilities)
|
33
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
34
34
|
assert_equal false, percy_options.enabled
|
35
35
|
assert_equal true, percy_options.ignore_errors
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_percy_options_json_wire_not_enabled
|
39
39
|
capabilities = { 'percy.enabled' => false }
|
40
|
-
percy_options = PercyOptions.new(capabilities)
|
40
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
41
41
|
assert_equal false, percy_options.enabled
|
42
42
|
assert_equal true, percy_options.ignore_errors
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_percy_options_w3c_ignore_errors
|
46
46
|
capabilities = { 'percy:options' => { 'ignoreErrors' => true } }
|
47
|
-
percy_options = PercyOptions.new(capabilities)
|
47
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
48
48
|
assert_equal true, percy_options.ignore_errors
|
49
49
|
assert_equal true, percy_options.enabled
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_percy_options_json_wire_ignore_errors
|
53
53
|
capabilities = { 'percy.ignoreErrors' => true }
|
54
|
-
percy_options = PercyOptions.new(capabilities)
|
54
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
55
55
|
assert_equal true, percy_options.ignore_errors
|
56
56
|
assert_equal true, percy_options.enabled
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_percy_options_w3c_not_ignore_errors
|
60
60
|
capabilities = { 'percy:options' => { 'ignoreErrors' => false } }
|
61
|
-
percy_options = PercyOptions.new(capabilities)
|
61
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
62
62
|
assert_equal false, percy_options.ignore_errors
|
63
63
|
assert_equal true, percy_options.enabled
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_percy_options_json_wire_not_ignore_errors
|
67
67
|
capabilities = { 'percy.ignoreErrors' => false }
|
68
|
-
percy_options = PercyOptions.new(capabilities)
|
68
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
69
69
|
assert_equal false, percy_options.ignore_errors
|
70
70
|
assert_equal true, percy_options.enabled
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_percy_options_w3c_all_options_false
|
74
74
|
capabilities = { 'percy:options' => { 'ignoreErrors' => false, 'enabled' => false } }
|
75
|
-
percy_options = PercyOptions.new(capabilities)
|
75
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
76
76
|
assert_equal false, percy_options.ignore_errors
|
77
77
|
assert_equal false, percy_options.enabled
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_percy_options_json_wire_all_options_false
|
81
81
|
capabilities = { 'percy.ignoreErrors' => false, 'percy.enabled' => false }
|
82
|
-
percy_options = PercyOptions.new(capabilities)
|
82
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
83
83
|
assert_equal false, percy_options.ignore_errors
|
84
84
|
# assert_equal false, percy_options.enabled
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_percy_options_w3c_all_options_true
|
88
88
|
capabilities = { 'percy:options' => { 'ignoreErrors' => true, 'enabled' => true } }
|
89
|
-
percy_options = PercyOptions.new(capabilities)
|
89
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
90
90
|
assert_equal true, percy_options.ignore_errors
|
91
91
|
assert_equal true, percy_options.enabled
|
92
92
|
end
|
93
93
|
|
94
94
|
def test_percy_options_json_wire_all_options_true
|
95
95
|
capabilities = { 'percy.ignoreErrors' => true, 'percy.enabled' => true }
|
96
|
-
percy_options = PercyOptions.new(capabilities)
|
96
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
97
97
|
assert_equal true, percy_options.ignore_errors
|
98
98
|
assert_equal true, percy_options.enabled
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_percy_options_json_wire_and_w3c_case_1
|
102
102
|
capabilities = { 'percy.ignoreErrors' => false, 'percy:options' => { 'enabled' => false } }
|
103
|
-
percy_options = PercyOptions.new(capabilities)
|
103
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
104
104
|
assert_equal false, percy_options.ignore_errors
|
105
105
|
assert_equal false, percy_options.enabled
|
106
106
|
end
|
107
107
|
|
108
108
|
def test_percy_options_json_wire_and_w3c_case_2
|
109
109
|
capabilities = { 'percy.enabled' => false, 'percy:options' => { 'ignoreErrors' => false } }
|
110
|
-
percy_options = PercyOptions.new(capabilities)
|
110
|
+
percy_options = Percy::PercyOptions.new(capabilities)
|
111
111
|
assert_equal false, percy_options.ignore_errors
|
112
112
|
assert_equal false, percy_options.enabled
|
113
113
|
end
|
data/specs/screenshot.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
4
|
-
# rubocop:disable Metrics/AbcSize
|
5
|
-
|
6
3
|
require 'minitest/autorun'
|
7
4
|
require 'json'
|
8
5
|
require 'webmock/minitest'
|
@@ -27,7 +24,7 @@ mock_server.mount('/', MockServerRequestHandler)
|
|
27
24
|
mock_server_thread = Thread.new { mock_server.start }
|
28
25
|
|
29
26
|
# Mock helpers
|
30
|
-
def mock_healthcheck(fail: false, fail_how: 'error', type: 'AppPercy')
|
27
|
+
def mock_healthcheck(fail: false, fail_how: 'error', type: 'Percy::AppPercy')
|
31
28
|
health_body = JSON.dump(success: true, build: { 'id' => '123', 'url' => 'dummy_url' }, type: type)
|
32
29
|
health_headers = { 'X-Percy-Core-Version' => '1.27.0-beta.1' }
|
33
30
|
health_status = 200
|
@@ -104,12 +101,12 @@ class TestPercyScreenshot < Minitest::Test
|
|
104
101
|
@server_url.expect(:to_s, 'https://hub-cloud.browserstack.com/wd/hub')
|
105
102
|
end
|
106
103
|
|
107
|
-
assert_raises(TypeError) { AppPercy.new(@mock_webdriver).screenshot(123) }
|
108
|
-
assert_raises(TypeError) { AppPercy.new(@mock_webdriver).screenshot('screenshot 1', device_name: 123) }
|
109
|
-
assert_raises(TypeError) { AppPercy.new(@mock_webdriver).screenshot('screenshot 1', full_screen: 123) }
|
110
|
-
assert_raises(TypeError) { AppPercy.new(@mock_webdriver).screenshot('screenshot 1', orientation: 123) }
|
111
|
-
assert_raises(TypeError) { AppPercy.new(@mock_webdriver).screenshot('screenshot 1', status_bar_height: 'height') }
|
112
|
-
assert_raises(TypeError) { AppPercy.new(@mock_webdriver).screenshot('screenshot 1', nav_bar_height: 'height') }
|
104
|
+
assert_raises(TypeError) { Percy::AppPercy.new(@mock_webdriver).screenshot(123) }
|
105
|
+
assert_raises(TypeError) { Percy::AppPercy.new(@mock_webdriver).screenshot('screenshot 1', device_name: 123) }
|
106
|
+
assert_raises(TypeError) { Percy::AppPercy.new(@mock_webdriver).screenshot('screenshot 1', full_screen: 123) }
|
107
|
+
assert_raises(TypeError) { Percy::AppPercy.new(@mock_webdriver).screenshot('screenshot 1', orientation: 123) }
|
108
|
+
assert_raises(TypeError) { Percy::AppPercy.new(@mock_webdriver).screenshot('screenshot 1', status_bar_height: 'height') }
|
109
|
+
assert_raises(TypeError) { Percy::AppPercy.new(@mock_webdriver).screenshot('screenshot 1', nav_bar_height: 'height') }
|
113
110
|
end
|
114
111
|
|
115
112
|
def test_throws_error_when_a_driver_is_not_provided
|
data/specs/tile.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require_relative '../percy/lib/tile'
|
5
5
|
|
6
|
-
# Test suite for the Tile class.
|
6
|
+
# Test suite for the Percy::Tile class.
|
7
7
|
class TileTest < Minitest::Test
|
8
8
|
def setup
|
9
|
-
@tile = Tile.new(20, 120, 150, 0, filepath: 'some-file-path', sha: 'some-sha')
|
9
|
+
@tile = Percy::Tile.new(20, 120, 150, 0, filepath: 'some-file-path', sha: 'some-sha')
|
10
10
|
@hash_tile = @tile.to_h
|
11
11
|
end
|
12
12
|
|
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.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BroswerStack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appium_lib
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '12.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dotenv
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.8'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,10 +160,10 @@ files:
|
|
146
160
|
- percy/metadata/ios_metadata.rb
|
147
161
|
- percy/metadata/metadata.rb
|
148
162
|
- percy/metadata/metadata_resolver.rb
|
163
|
+
- percy/percy-appium-app.rb
|
149
164
|
- percy/providers/app_automate.rb
|
150
165
|
- percy/providers/generic_provider.rb
|
151
166
|
- percy/providers/provider_resolver.rb
|
152
|
-
- percy/screenshot.rb
|
153
167
|
- percy/version.rb
|
154
168
|
- specs/android_metadata.rb
|
155
169
|
- specs/app_automate.rb
|