percy-appium-app 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/percy/common/common.rb +8 -5
- data/percy/lib/app_percy.rb +12 -0
- data/percy/lib/cli_wrapper.rb +8 -4
- data/percy/metadata/metadata.rb +4 -1
- data/percy/providers/generic_provider.rb +20 -4
- data/percy/version.rb +1 -1
- data/specs/cli_wrapper.rb +9 -3
- data/specs/metadata.rb +32 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b46a8c2b5a23c5a4171481451b2769eb6c60954ba7a9f1d43ad8d7ac72dc47a
|
4
|
+
data.tar.gz: 0e3480e5bebad1e1d3354792d818709f43b9040e8aee7b52ecb3f80af688db82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e139e6eac3e362ddeeadb9a36653e2a17dd2c2a85acdbb73e2f486afea8ee098b35db88127d35d95882beda8a825392f87ab1462e75da81709fb1f01824df974
|
7
|
+
data.tar.gz: 199703de73702fb3125607f6588a1abbeb146af01993d4d63b66b8dcc5fcf7607a5db18ee31d0008c18269c44db198dbf1fd6170a62c98bdcd972b7b3f66eefd
|
data/percy/common/common.rb
CHANGED
@@ -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) &&
|
7
|
+
return unless on_debug.nil? || (on_debug.is_a?(TrueClass) && percy_debug)
|
11
8
|
|
12
|
-
|
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
|
data/percy/lib/app_percy.rb
CHANGED
@@ -48,6 +48,18 @@ module Percy
|
|
48
48
|
'Argument orientation should be a String and portrait/landscape'
|
49
49
|
end
|
50
50
|
|
51
|
+
test_case = kwargs[:test_case]
|
52
|
+
if test_case && !test_case.is_a?(String)
|
53
|
+
raise TypeError,
|
54
|
+
'Argument test_case should be a String'
|
55
|
+
end
|
56
|
+
|
57
|
+
th_test_case_execution_id = kwargs[:th_test_case_execution_id]
|
58
|
+
if th_test_case_execution_id && !th_test_case_execution_id.is_a?(String)
|
59
|
+
raise TypeError,
|
60
|
+
'Argument th_test_case_execution_id should be a String'
|
61
|
+
end
|
62
|
+
|
51
63
|
@provider.screenshot(name, **kwargs)
|
52
64
|
end
|
53
65
|
|
data/percy/lib/cli_wrapper.rb
CHANGED
@@ -49,8 +49,9 @@ module Percy
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def post_screenshots(name, tag, tiles, external_debug_url = nil, ignored_elements_data = nil,
|
52
|
-
|
53
|
-
body = request_body(name, tag, tiles, external_debug_url, ignored_elements_data,
|
52
|
+
considered_elements_data = nil, sync = nil, test_case = nil, th_test_case_execution_id = nil)
|
53
|
+
body = request_body(name, tag, tiles, external_debug_url, ignored_elements_data,
|
54
|
+
considered_elements_data, sync, test_case, th_test_case_execution_id)
|
54
55
|
body['client_info'] = Percy::Environment.get_client_info
|
55
56
|
body['environment_info'] = Percy::Environment.get_env_info
|
56
57
|
|
@@ -124,7 +125,8 @@ module Percy
|
|
124
125
|
data
|
125
126
|
end
|
126
127
|
|
127
|
-
def request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data, sync
|
128
|
+
def request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data, sync,
|
129
|
+
test_case, th_test_case_execution_id)
|
128
130
|
tiles = tiles.map(&:to_h)
|
129
131
|
{
|
130
132
|
'name' => name,
|
@@ -133,7 +135,9 @@ module Percy
|
|
133
135
|
'ignored_elements_data' => ignored_elements_data,
|
134
136
|
'external_debug_url' => external_debug_url,
|
135
137
|
'considered_elements_data' => considered_elements_data,
|
136
|
-
'sync' => sync
|
138
|
+
'sync' => sync,
|
139
|
+
'test_case' => test_case,
|
140
|
+
'th_test_case_execution_id' => th_test_case_execution_id
|
137
141
|
}
|
138
142
|
end
|
139
143
|
end
|
data/percy/metadata/metadata.rb
CHANGED
@@ -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
|
-
|
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
|
@@ -43,8 +43,11 @@ module Percy
|
|
43
43
|
)
|
44
44
|
}
|
45
45
|
sync = kwargs.fetch(:sync, nil)
|
46
|
+
test_case = kwargs.fetch(:test_case, nil)
|
47
|
+
th_test_case_execution_id = kwargs.fetch(:th_test_case_execution_id, nil)
|
46
48
|
|
47
|
-
_post_screenshots(name, tag, tiles, get_debug_url, ignore_regions, consider_regions,
|
49
|
+
_post_screenshots(name, tag, tiles, get_debug_url, ignore_regions, consider_regions,
|
50
|
+
sync, test_case, th_test_case_execution_id)
|
48
51
|
end
|
49
52
|
|
50
53
|
def _get_tag(**kwargs)
|
@@ -81,7 +84,8 @@ module Percy
|
|
81
84
|
header_height = 0
|
82
85
|
footer_height = 0
|
83
86
|
[
|
84
|
-
Percy::Tile.new(status_bar_height, nav_bar_height, header_height, footer_height, filepath: path,
|
87
|
+
Percy::Tile.new(status_bar_height, nav_bar_height, header_height, footer_height, filepath: path,
|
88
|
+
fullscreen: fullscreen)
|
85
89
|
]
|
86
90
|
end
|
87
91
|
|
@@ -94,8 +98,20 @@ module Percy
|
|
94
98
|
elements_array
|
95
99
|
end
|
96
100
|
|
97
|
-
def _post_screenshots(
|
98
|
-
|
101
|
+
def _post_screenshots(
|
102
|
+
name,
|
103
|
+
tag,
|
104
|
+
tiles,
|
105
|
+
debug_url,
|
106
|
+
ignored_regions,
|
107
|
+
considered_regions,
|
108
|
+
sync,
|
109
|
+
test_case,
|
110
|
+
th_test_case_execution_id
|
111
|
+
)
|
112
|
+
Percy::CLIWrapper.new.post_screenshots(
|
113
|
+
name, tag, tiles, debug_url, ignored_regions, considered_regions, sync, test_case, th_test_case_execution_id
|
114
|
+
)
|
99
115
|
end
|
100
116
|
|
101
117
|
def _write_screenshot(png_bytes, directory)
|
data/percy/version.rb
CHANGED
data/specs/cli_wrapper.rb
CHANGED
@@ -105,8 +105,10 @@ class TestCLIWrapper < Minitest::Test
|
|
105
105
|
name = 'some-name'
|
106
106
|
debug_url = 'debug-url'
|
107
107
|
sync = false
|
108
|
+
test_case = 'test-case-1'
|
109
|
+
th_test_case_execution_id = 'uuid-1231231'
|
108
110
|
response = @cli_wrapper.request_body(name, tag, [tile], debug_url, @ignored_elements_data,
|
109
|
-
@considered_elements_data, sync)
|
111
|
+
@considered_elements_data, sync, test_case, th_test_case_execution_id)
|
110
112
|
assert_equal response['name'], name
|
111
113
|
assert_equal response['external_debug_url'], debug_url
|
112
114
|
assert_equal response['tag'], tag
|
@@ -114,6 +116,8 @@ class TestCLIWrapper < Minitest::Test
|
|
114
116
|
assert_equal response['ignored_elements_data'], @ignored_elements_data
|
115
117
|
assert_equal response['considered_elements_data'], @considered_elements_data
|
116
118
|
assert_equal response['sync'], sync
|
119
|
+
assert_equal response['test_case'], test_case
|
120
|
+
assert_equal response['th_test_case_execution_id'], th_test_case_execution_id
|
117
121
|
end
|
118
122
|
|
119
123
|
def test_request_body_when_optional_values_are_null
|
@@ -125,13 +129,15 @@ class TestCLIWrapper < Minitest::Test
|
|
125
129
|
considered_elements_data = nil
|
126
130
|
sync = nil
|
127
131
|
response = @cli_wrapper.send(:request_body, name, tag, [tile], debug_url, ignored_elements_data,
|
128
|
-
considered_elements_data, sync)
|
132
|
+
considered_elements_data, sync, nil, nil)
|
129
133
|
assert_equal response['name'], name
|
130
|
-
|
134
|
+
assert_nil response['external_debug_url']
|
131
135
|
assert_equal response['tag'], tag
|
132
136
|
assert_equal response['tiles'], [tile.to_h]
|
133
137
|
assert_nil response['ignored_elements_data']
|
134
138
|
assert_nil response['considered_elements_data']
|
135
139
|
assert_nil response['sync']
|
140
|
+
assert_nil response['test_case']
|
141
|
+
assert_nil response['th_test_case_execution_id']
|
136
142
|
end
|
137
143
|
end
|
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
|
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
|
-
|
34
|
-
|
35
|
-
|
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
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BroswerStack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appium_lib
|