percy-appium-app 0.0.2.pre.beta.0 → 0.0.2
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.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +1 -193
- data/percy/lib/app_percy.rb +1 -0
- data/percy/lib/cli_wrapper.rb +5 -11
- data/percy/lib/percy_automate.rb +2 -3
- data/percy/providers/app_automate.rb +5 -7
- data/percy/providers/generic_provider.rb +3 -4
- data/percy/version.rb +1 -1
- data/specs/screenshot.rb +5 -83
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 977a7a790f27d4907f95f7fe43de80d9b22e755320f159a491615a642a836a1d
|
4
|
+
data.tar.gz: e9eb127a4f084f12bffc64aa4263928bf0931352a5ff60d408f91f9e955b0204
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e50bd2ad6f3fda122ef560e6e264bb2eb1bde38d48d6fcef7a3a53193d1af021d19bd60e04c8785e29cbeb0b5db4372b86ef43779d4716fb6c1006e60c5ab1ed
|
7
|
+
data.tar.gz: 1ce875348fe37874f4fa9d2089a7a9159aedd0977b7f9e5aa1c3042218b0778b098becdcc0fcd5aeb3767c3f0284276dbe170221d7b2beef797fe39a9ed32863
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,193 +1 @@
|
|
1
|
-
# percy-appium-ruby
|
2
|
-
|
3
|
-
[Percy](https://percy.io) visual testing for Ruby Appium.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
npm install `@percy/cli`:
|
8
|
-
|
9
|
-
```sh-session
|
10
|
-
$ npm install --save-dev @percy/cli
|
11
|
-
```
|
12
|
-
|
13
|
-
gem install Percy appium package:
|
14
|
-
|
15
|
-
```ssh-session
|
16
|
-
$ gem install percy-appium-app
|
17
|
-
```
|
18
|
-
|
19
|
-
|
20
|
-
## Usage
|
21
|
-
|
22
|
-
This is an example test using the `percy_screenshot` function.
|
23
|
-
|
24
|
-
``` ruby
|
25
|
-
require 'appium_lib'
|
26
|
-
require 'percy-appium-app'
|
27
|
-
|
28
|
-
username = '<BROWSERSTACK_USERNAME>'
|
29
|
-
access_key = '<ACCESS_KEY>'
|
30
|
-
|
31
|
-
capabilities = {
|
32
|
-
'platformName' => 'android',
|
33
|
-
'platformVersion' => '13.0',
|
34
|
-
'deviceName' => 'Google Pixel 7',
|
35
|
-
'bstack:options' => {
|
36
|
-
'appiumVersion' => '2.0.1'
|
37
|
-
},
|
38
|
-
'app' => '<APP LINK>',
|
39
|
-
'appium:percyOptions' => {
|
40
|
-
# enabled is default True. This can be used to disable visual testing for certain capabilities
|
41
|
-
'enabled' => true
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
appium_driver = Appium::Driver.new(
|
46
|
-
{
|
47
|
-
'caps' => capabilities,
|
48
|
-
'appium_lib' => {
|
49
|
-
server_url: "https://#{username}:#{access_key}@hub-cloud.browserstack.com/wd/hub"
|
50
|
-
}
|
51
|
-
}, true
|
52
|
-
)
|
53
|
-
driver = appium_driver.start_driver
|
54
|
-
|
55
|
-
# take a screenshot
|
56
|
-
percy_screenshot(driver, 'here is some name')
|
57
|
-
```
|
58
|
-
|
59
|
-
Running the test above normally will result in the following log:
|
60
|
-
|
61
|
-
```sh-session
|
62
|
-
[percy] Percy is not running, disabling screenshots
|
63
|
-
```
|
64
|
-
|
65
|
-
When running with [`percy
|
66
|
-
app:exec`](https://github.com/percy/cli/tree/master/packages/cli-exec#app-exec), and your project's
|
67
|
-
`PERCY_TOKEN`, a new Percy build will be created and screenshots will be uploaded to your project.
|
68
|
-
|
69
|
-
```sh-session
|
70
|
-
$ export PERCY_TOKEN=[your-project-token]
|
71
|
-
$ percy app:exec -- [ruby test command]
|
72
|
-
[percy] Percy has started!
|
73
|
-
[percy] Created build #1: https://percy.io/[your-project]
|
74
|
-
[percy] Screenshot taken "Ruby example"
|
75
|
-
[percy] Stopping percy...
|
76
|
-
[percy] Finalized build #1: https://percy.io/[your-project]
|
77
|
-
[percy] Done!
|
78
|
-
```
|
79
|
-
|
80
|
-
## Configuration
|
81
|
-
|
82
|
-
`percy_screenshot(driver, name[, **kwargs])`
|
83
|
-
|
84
|
-
- `driver` (**required**) - A appium driver instance
|
85
|
-
- `name` (**required**) - The screenshot name; must be unique to each screenshot
|
86
|
-
- `device_name` (**optional**) - The device name used for capturing screenshot
|
87
|
-
- `orientation` (**optional**) - Orientation of device while capturing screeenshot; Allowed values [`portrait` | `landscape`]
|
88
|
-
- `status_bar_height` (**optional**) - Height of status bar; int
|
89
|
-
- `nav_bar_height` (**optional**) - Height of navigation bar; int
|
90
|
-
- `fullpage` (**optional**) - [Alpha] Only supported on App Automate driver sessions [ needs @percy/cli 1.20.2+ ]; boolean
|
91
|
-
- `screen_lengths` (**optional**) - [Alpha] Max screen lengths for fullPage; int
|
92
|
-
- In case scrollview is overlapping with other app elements. Offsets can be provided to reduce the area which needs to be considered for scrolling:
|
93
|
-
- `top_scrollview_offset`: (**optional**) - [Alpha] Offset from top of scrollview; int
|
94
|
-
- `bottom_scrollview_offset` (**optional**) - [Alpha] Offset from bottom of scrollview; int
|
95
|
-
- `full_screen` (**optional**) - Indicate whether app is full screen; boolean [ needs @percy/cli 1.20.2+ ];
|
96
|
-
- `sync` (**optional**) - Waits for screenshot to be processed and gives the processed result of screenshot [needs @percy/cli v1.28.0-beta.0+]; boolean
|
97
|
-
- `scrollable_xpath` (**optional**) - [Alpha] Scrollable element xpath for fullpage [ needs @percy/cli 1.20.2+ ]; string
|
98
|
-
- `scrollable_id` (**optional**) - [Alpha] Scrollable element accessibility id for fullpage [ needs @percy/cli 1.20.2+ ]; string
|
99
|
-
- `ignore_regions_xpaths` (**optional**) - Elements xpaths that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string
|
100
|
-
- `ignore_region_accessibility_ids` (**optional**) - Elements accessibility_ids that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string
|
101
|
-
- `ignore_region_appium_elements` (**optional**) - Appium elements that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of appium element object
|
102
|
-
- `custom_ignore_regions` (**optional**) - Custom locations that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of ignore_region object
|
103
|
-
- IgnoreRegion:-
|
104
|
-
- Description: This class represents a rectangular area on a screen that needs to be ignored for visual diff.
|
105
|
-
- Constructor:
|
106
|
-
```
|
107
|
-
init(self, top, bottom, left, right)
|
108
|
-
```
|
109
|
-
- Parameters:
|
110
|
-
- `top` (int): Top coordinate of the ignore region.
|
111
|
-
- `bottom` (int): Bottom coordinate of the ignore region.
|
112
|
-
- `left` (int): Left coordinate of the ignore region.
|
113
|
-
- `right` (int): Right coordinate of the ignore region.
|
114
|
-
|
115
|
-
## Running with Hybrid Apps
|
116
|
-
|
117
|
-
For a hybrid app, we need to switch to native context before taking screenshot.
|
118
|
-
|
119
|
-
- Add a helper method similar to following for say flutter based hybrid app:
|
120
|
-
```ruby
|
121
|
-
def percy_screenshot_flutter(driver, name: str, **kwargs):
|
122
|
-
driver.switch_to.context('NATIVE_APP')
|
123
|
-
percy_screenshot(driver, name, **kwargs)
|
124
|
-
driver.switch_to.context('FLUTTER')
|
125
|
-
end
|
126
|
-
```
|
127
|
-
|
128
|
-
- Call PercyScreenshotFlutter helper function when you want to take screenshot.
|
129
|
-
```ruby
|
130
|
-
percy_screenshot_flutter(driver, name, **kwargs)
|
131
|
-
```
|
132
|
-
|
133
|
-
> Note:
|
134
|
-
>
|
135
|
-
> For other hybrid apps the `driver.switch_to.context('FLUTTER')` would change to context that it uses like say WEBVIEW etc.
|
136
|
-
>
|
137
|
-
|
138
|
-
## Running Percy on Automate
|
139
|
-
`percy_screenshot(driver, name, options)` [ needs @percy/cli 1.27.0-beta.0+ ];
|
140
|
-
- `driver` (**required**) - A appium driver instance
|
141
|
-
- `name` (**required**) - The screenshot name; must be unique to each screenshot
|
142
|
-
- `options` (**optional**) - There are various options supported by percy_screenshot to server further functionality.
|
143
|
-
- `sync` - Boolean value by default it falls back to `false`, Gives the processed result around screenshot [From CLI v1.28.0-beta.0+].
|
144
|
-
- `freeze_animated_image` - Boolean value by default it falls back to `false`, you can pass `true` and percy will freeze image based animations.
|
145
|
-
- `freeze_image_by_selectors` -List of selectors. Images will be freezed which are passed using selectors. For this to work `freeze_animated_image` must be set to true.
|
146
|
-
- `freeze_image_by_xpaths` - List of xpaths. Images will be freezed which are passed using xpaths. For this to work `freeze_animated_image` must be set to true.
|
147
|
-
- `percy_css` - Custom CSS to be added to DOM before the screenshot being taken. Note: This gets removed once the screenshot is taken.
|
148
|
-
- `ignore_region_xpaths` - List of xpaths. elements in the DOM can be ignored using xpath
|
149
|
-
- `ignore_region_selectors` - List of selectors. elements in the DOM can be ignored using selectors.
|
150
|
-
- `ignore_region_appium_elements` - List of appium web-element. elements can be ignored using appium_elements.
|
151
|
-
- `custom_ignore_regions` - List of custom objects. elements can be ignored using custom boundaries. Just passing a simple object for it like below.
|
152
|
-
- example: ```{"top": 10, "right": 10, "bottom": 120, "left": 10}```
|
153
|
-
- In above example it will draw rectangle of ignore region as per given coordinates.
|
154
|
-
- `top` (int): Top coordinate of the ignore region.
|
155
|
-
- `bottom` (int): Bottom coordinate of the ignore region.
|
156
|
-
- `left` (int): Left coordinate of the ignore region.
|
157
|
-
- `right` (int): Right coordinate of the ignore region.
|
158
|
-
- `consider_region_xpaths` - List of xpaths. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using xpaths.
|
159
|
-
- `consider_region_selectors` - List of selectors. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using selectors.
|
160
|
-
- `consider_region_appium_elements` - List of appium web-element. elements can be considered for diffing and will be ignored by Intelli Ignore using appium_elements.
|
161
|
-
- `custom_consider_regions` - List of custom objects. elements can be considered for diffing and will be ignored by Intelli Ignore using custom boundaries
|
162
|
-
- example:```{"top": 10, "right": 10, "bottom": 120, "left": 10}```
|
163
|
-
- In above example it will draw rectangle of consider region will be drawn.
|
164
|
-
- Parameters:
|
165
|
-
- `top` (int): Top coordinate of the consider region.
|
166
|
-
- `bottom` (int): Bottom coordinate of the consider region.
|
167
|
-
- `left` (int): Left coordinate of the consider region.
|
168
|
-
- `right` (int): Right coordinate of the consider region.
|
169
|
-
|
170
|
-
### Creating Percy on automate build
|
171
|
-
Note: Automate Percy Token starts with `auto` keyword. The command can be triggered using `exec` keyword.
|
172
|
-
|
173
|
-
```sh-session
|
174
|
-
$ export PERCY_TOKEN=[your-project-token]
|
175
|
-
$ percy exec -- [ruby test command]
|
176
|
-
[percy] Percy has started!
|
177
|
-
[percy] [Ruby example] : Starting automate screenshot ...
|
178
|
-
[percy] Screenshot taken "Ruby example"
|
179
|
-
[percy] Stopping percy...
|
180
|
-
[percy] Finalized build #1: https://percy.io/[your-project]
|
181
|
-
[percy] Done!
|
182
|
-
```
|
183
|
-
|
184
|
-
Refer to docs here: [Percy on Automate](https://docs.percy.io/docs/integrate-functional-testing-with-visual-testing)
|
185
|
-
|
186
|
-
### Migrating Config
|
187
|
-
|
188
|
-
If you have a previous Percy configuration file, migrate it to the newest version with the
|
189
|
-
[`config:migrate`](https://github.com/percy/cli/tree/master/packages/cli-config#percy-configmigrate-filepath-output) command:
|
190
|
-
|
191
|
-
```sh-session
|
192
|
-
$ percy config:migrate
|
193
|
-
```
|
1
|
+
# percy-appium-ruby
|
data/percy/lib/app_percy.rb
CHANGED
data/percy/lib/cli_wrapper.rb
CHANGED
@@ -49,14 +49,13 @@ module Percy
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def post_screenshots(name, tag, tiles, external_debug_url = nil, ignored_elements_data = nil,
|
52
|
-
considered_elements_data = nil
|
53
|
-
body = request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data
|
52
|
+
considered_elements_data = nil)
|
53
|
+
body = request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data)
|
54
54
|
body['client_info'] = Percy::Environment.get_client_info
|
55
55
|
body['environment_info'] = Percy::Environment.get_env_info
|
56
56
|
|
57
57
|
uri = URI("#{PERCY_CLI_API}/percy/comparison")
|
58
58
|
http = Net::HTTP.new(uri.host, uri.port)
|
59
|
-
http.read_timeout = 600 # seconds
|
60
59
|
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
61
60
|
request.body = body.to_json
|
62
61
|
|
@@ -105,11 +104,7 @@ module Percy
|
|
105
104
|
body['environment_info'] = Percy::Environment.get_env_info
|
106
105
|
|
107
106
|
uri = URI("#{PERCY_CLI_API}/percy/automateScreenshot")
|
108
|
-
|
109
|
-
http.read_timeout = 600 # seconds
|
110
|
-
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
111
|
-
request.body = body.to_json
|
112
|
-
response = http.request(request)
|
107
|
+
response = Net::HTTP.post(uri, body.to_json, 'Content-Type' => 'application/json')
|
113
108
|
|
114
109
|
# Handle errors
|
115
110
|
raise CLIException, "Error: #{response.message}" unless response.is_a?(Net::HTTPSuccess)
|
@@ -124,7 +119,7 @@ module Percy
|
|
124
119
|
data
|
125
120
|
end
|
126
121
|
|
127
|
-
def request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data
|
122
|
+
def request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data)
|
128
123
|
tiles = tiles.map(&:to_h)
|
129
124
|
{
|
130
125
|
'name' => name,
|
@@ -132,8 +127,7 @@ module Percy
|
|
132
127
|
'tiles' => tiles,
|
133
128
|
'ignored_elements_data' => ignored_elements_data,
|
134
129
|
'external_debug_url' => external_debug_url,
|
135
|
-
'considered_elements_data' => considered_elements_data
|
136
|
-
'sync' => sync
|
130
|
+
'considered_elements_data' => considered_elements_data
|
137
131
|
}
|
138
132
|
end
|
139
133
|
end
|
data/percy/lib/percy_automate.rb
CHANGED
@@ -43,7 +43,7 @@ module Percy
|
|
43
43
|
'consider_region_elements' => consider_region_elements
|
44
44
|
}
|
45
45
|
|
46
|
-
|
46
|
+
Percy::CLIWrapper.new.post_poa_screenshots(
|
47
47
|
name,
|
48
48
|
metadata.session_id,
|
49
49
|
metadata.command_executor_url,
|
@@ -51,12 +51,11 @@ module Percy
|
|
51
51
|
metadata.session_capabilities,
|
52
52
|
options.merge(additional_options)
|
53
53
|
)
|
54
|
-
|
55
|
-
response['data']
|
56
54
|
rescue StandardError => e
|
57
55
|
log("Could not take Screenshot '#{name}'")
|
58
56
|
log(e.message, on_debug: true)
|
59
57
|
end
|
58
|
+
nil
|
60
59
|
end
|
61
60
|
end
|
62
61
|
end
|
@@ -29,10 +29,9 @@ module Percy
|
|
29
29
|
begin
|
30
30
|
response = super(name, **kwargs)
|
31
31
|
percy_screenshot_url = response.fetch('link', '')
|
32
|
-
execute_percy_screenshot_end(name, percy_screenshot_url, 'success'
|
33
|
-
response['data']
|
32
|
+
execute_percy_screenshot_end(name, percy_screenshot_url, 'success')
|
34
33
|
rescue StandardError => e
|
35
|
-
execute_percy_screenshot_end(name, percy_screenshot_url, 'failure',
|
34
|
+
execute_percy_screenshot_end(name, percy_screenshot_url, 'failure', e.message)
|
36
35
|
raise e
|
37
36
|
end
|
38
37
|
end
|
@@ -105,15 +104,14 @@ module Percy
|
|
105
104
|
end
|
106
105
|
end
|
107
106
|
|
108
|
-
def execute_percy_screenshot_end(name, percy_screenshot_url, status,
|
107
|
+
def execute_percy_screenshot_end(name, percy_screenshot_url, status, status_message = nil)
|
109
108
|
request_body = {
|
110
109
|
action: 'percyScreenshot',
|
111
110
|
arguments: {
|
112
111
|
state: 'end',
|
113
112
|
percyScreenshotUrl: percy_screenshot_url,
|
114
113
|
name: name,
|
115
|
-
status: status
|
116
|
-
sync: sync
|
114
|
+
status: status
|
117
115
|
}
|
118
116
|
}
|
119
117
|
request_body[:arguments][:statusMessage] = status_message if status_message
|
@@ -160,4 +158,4 @@ module Percy
|
|
160
158
|
end
|
161
159
|
end
|
162
160
|
end
|
163
|
-
end
|
161
|
+
end
|
@@ -42,9 +42,8 @@ module Percy
|
|
42
42
|
custom_locations: kwargs.fetch(:custom_consider_regions, [])
|
43
43
|
)
|
44
44
|
}
|
45
|
-
sync = kwargs.fetch(:sync, nil)
|
46
45
|
|
47
|
-
_post_screenshots(name, tag, tiles, get_debug_url, ignore_regions, consider_regions
|
46
|
+
_post_screenshots(name, tag, tiles, get_debug_url, ignore_regions, consider_regions)
|
48
47
|
end
|
49
48
|
|
50
49
|
def _get_tag(**kwargs)
|
@@ -94,8 +93,8 @@ module Percy
|
|
94
93
|
elements_array
|
95
94
|
end
|
96
95
|
|
97
|
-
def _post_screenshots(name, tag, tiles, debug_url, ignored_regions, considered_regions
|
98
|
-
Percy::CLIWrapper.new.post_screenshots(name, tag, tiles, debug_url, ignored_regions, considered_regions
|
96
|
+
def _post_screenshots(name, tag, tiles, debug_url, ignored_regions, considered_regions)
|
97
|
+
Percy::CLIWrapper.new.post_screenshots(name, tag, tiles, debug_url, ignored_regions, considered_regions)
|
99
98
|
end
|
100
99
|
|
101
100
|
def _write_screenshot(png_bytes, directory)
|
data/percy/version.rb
CHANGED
data/specs/screenshot.rb
CHANGED
@@ -6,7 +6,7 @@ require 'webmock/minitest'
|
|
6
6
|
require 'appium_lib'
|
7
7
|
require 'webrick'
|
8
8
|
|
9
|
-
require_relative '../percy/
|
9
|
+
require_relative '../percy/screenshot'
|
10
10
|
require_relative '../percy/lib/app_percy'
|
11
11
|
require_relative 'mocks/mock_methods'
|
12
12
|
|
@@ -54,14 +54,14 @@ def mock_healthcheck(fail: false, fail_how: 'error', type: 'Percy::AppPercy')
|
|
54
54
|
.to_return(status: health_status, body: health_body, headers: health_headers)
|
55
55
|
end
|
56
56
|
|
57
|
-
def mock_screenshot(fail: false
|
57
|
+
def mock_screenshot(fail: false)
|
58
58
|
stub_request(:post, 'http://localhost:5338/percy/comparison')
|
59
|
-
.to_return(body: "{\"success\": #{fail ? 'false, "error": "test"' : 'true'}
|
59
|
+
.to_return(body: "{\"success\": #{fail ? 'false, "error": "test"' : 'true'}}", status: (fail ? 500 : 200))
|
60
60
|
end
|
61
61
|
|
62
|
-
def mock_poa_screenshot(fail: false
|
62
|
+
def mock_poa_screenshot(fail: false)
|
63
63
|
stub_request(:post, 'http://localhost:5338/percy/automateScreenshot')
|
64
|
-
.to_return(body: "{\"success\": #{fail ? 'false, "error": "test"' : 'true'}
|
64
|
+
.to_return(body: "{\"success\": #{fail ? 'false, "error": "test"' : 'true'}}", status: (fail ? 500 : 200))
|
65
65
|
end
|
66
66
|
|
67
67
|
def mock_session_request
|
@@ -204,37 +204,6 @@ class TestPercyScreenshot < Minitest::Test
|
|
204
204
|
assert_equal(['Consider_Dummy_id'], s2['options']['consider_region_elements'])
|
205
205
|
end
|
206
206
|
|
207
|
-
def test_posts_screenshot_poa_with_sync
|
208
|
-
mock_healthcheck(type: 'automate')
|
209
|
-
mock_poa_screenshot(data: true)
|
210
|
-
mock_session_request
|
211
|
-
|
212
|
-
driver = Minitest::Mock.new
|
213
|
-
@bridge = Minitest::Mock.new
|
214
|
-
@http = Minitest::Mock.new
|
215
|
-
@server_url = Minitest::Mock.new
|
216
|
-
|
217
|
-
driver.expect(:is_a?, true, [Appium::Core::Base::Driver])
|
218
|
-
driver.expect(:desired_capabilities, { 'key' => 'value' })
|
219
|
-
driver.expect(:instance_variable_get, @bridge, [:@bridge])
|
220
|
-
@http.expect(:instance_variable_get, @server_url, [:@server_url])
|
221
|
-
@bridge.expect(:instance_variable_get, @http, [:@http])
|
222
|
-
@server_url.expect(:to_s, 'https://hub-cloud.browserstack.com/wd/hub')
|
223
|
-
|
224
|
-
10.times do
|
225
|
-
driver.expect(:session_id, 'Dummy_session_id')
|
226
|
-
end
|
227
|
-
2.times do
|
228
|
-
driver.expect(:capabilities, { 'key' => 'value' })
|
229
|
-
end
|
230
|
-
@mock_webdriver.expect(:capabilities, { 'key' => 'value' })
|
231
|
-
|
232
|
-
res = percy_screenshot(driver, 'Snapshot 1', options: { sync: true })
|
233
|
-
|
234
|
-
assert_equal('sync-data', res)
|
235
|
-
assert_equal('/percy/automateScreenshot', @requests.last.uri.path)
|
236
|
-
end
|
237
|
-
|
238
207
|
def test_posts_multiple_screenshots_to_the_local_percy_server
|
239
208
|
mock_healthcheck
|
240
209
|
mock_screenshot
|
@@ -287,53 +256,6 @@ class TestPercyScreenshot < Minitest::Test
|
|
287
256
|
assert_match(%r{ruby/\d+\.\d+\.\d+}, body['environment_info'][1])
|
288
257
|
end
|
289
258
|
|
290
|
-
def test_post_screenshot_with_sync
|
291
|
-
mock_healthcheck
|
292
|
-
mock_screenshot(data: true)
|
293
|
-
|
294
|
-
driver = Minitest::Mock.new
|
295
|
-
|
296
|
-
driver.expect(:is_a?, true, [Appium::Core::Base::Driver])
|
297
|
-
driver.expect(:instance_variable_get, @bridge, [:@bridge])
|
298
|
-
@http.expect(:instance_variable_get, @server_url, [:@server_url])
|
299
|
-
@bridge.expect(:instance_variable_get, @http, [:@http])
|
300
|
-
@server_url.expect(:to_s, 'https://hub-cloud.browserstack.com/wd/hub')
|
301
|
-
|
302
|
-
5.times do
|
303
|
-
driver.expect(:session_id, 'Dummy_session_id')
|
304
|
-
end
|
305
|
-
|
306
|
-
13.times do
|
307
|
-
driver.expect(:capabilities, get_android_capabilities)
|
308
|
-
end
|
309
|
-
|
310
|
-
3.times do
|
311
|
-
driver.expect(
|
312
|
-
:execute_script,
|
313
|
-
'{"success":true,"result":"[{\"sha\":\"sha-something\",\"status_bar\":null'\
|
314
|
-
',\"nav_bar\":null,\"header_height\":0,\"footer_height\":0,\"index\":0}]"}',
|
315
|
-
[String]
|
316
|
-
)
|
317
|
-
end
|
318
|
-
|
319
|
-
2.times do
|
320
|
-
driver.expect(:get_system_bars, {
|
321
|
-
'statusBar' => { 'height' => 10, 'width' => 20 },
|
322
|
-
'navigationBar' => { 'height' => 10, 'width' => 20 }
|
323
|
-
})
|
324
|
-
end
|
325
|
-
|
326
|
-
res = percy_screenshot(driver, 'screenshot 2', sync: true)
|
327
|
-
|
328
|
-
assert_equal('sync-data', res)
|
329
|
-
assert_equal('/percy/comparison', @requests.last.uri.path)
|
330
|
-
|
331
|
-
body = JSON.parse(@requests[-1].body)
|
332
|
-
assert_match(%r{percy-appium-app/\d+}, body['client_info'])
|
333
|
-
assert_match(%r{appium/\d+}, body['environment_info'][0])
|
334
|
-
assert_match(%r{ruby/\d+\.\d+\.\d+}, body['environment_info'][1])
|
335
|
-
end
|
336
|
-
|
337
259
|
def test_ignore_region_screenshots_to_the_local_percy_server
|
338
260
|
mock_healthcheck
|
339
261
|
mock_screenshot
|
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.2
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BroswerStack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appium_lib
|
@@ -197,11 +197,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
197
|
version: 2.6.0
|
198
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
|
-
- - "
|
200
|
+
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
202
|
+
version: '0'
|
203
203
|
requirements: []
|
204
|
-
rubygems_version: 3.
|
204
|
+
rubygems_version: 3.2.3
|
205
205
|
signing_key:
|
206
206
|
specification_version: 4
|
207
207
|
summary: Percy visual testing for Ruby Appium Mobile Apps
|