percy-selenium 1.1.0 → 1.1.1
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/.github/workflows/lint.yml +1 -1
- data/.github/workflows/release.yml +1 -1
- data/.github/workflows/test.yml +1 -1
- data/lib/percy.rb +36 -0
- data/lib/version.rb +1 -1
- data/package.json +1 -1
- data/spec/lib/percy/percy_spec.rb +58 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1182f98302b6e6a50148711618e377ca36e62ad06d8bfc8a6f3da3b7c34a8256
|
4
|
+
data.tar.gz: b8125cece8b3929bd8416bc15fcaac70fbf9b9f8832207ed47d95f88a167c013
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a5ffdebefdc4844c60e599bfda70a2375602970de16dbbf9dc5ca5be2d2b52a9cb5f9569215430431130345a43815a934037dd93efa934f4a12f67f9db76627
|
7
|
+
data.tar.gz: 4937624feab8efc33c64d4825204dc4a886dafca14b697be5343826260fb14f49eaad34dd74467a427fc38b7ebb40219b23805c3c43020af9ce844b3c85422d6
|
data/.github/workflows/lint.yml
CHANGED
data/.github/workflows/test.yml
CHANGED
data/lib/percy.rb
CHANGED
@@ -13,6 +13,42 @@ module Percy
|
|
13
13
|
LABEL = "[\u001b[35m" + (PERCY_DEBUG ? 'percy:ruby' : 'percy') + "\u001b[39m]"
|
14
14
|
RESONSIVE_CAPTURE_SLEEP_TIME = ENV['RESONSIVE_CAPTURE_SLEEP_TIME']
|
15
15
|
|
16
|
+
def self.create_region(
|
17
|
+
bounding_box: nil, element_xpath: nil, element_css: nil, padding: nil,
|
18
|
+
algorithm: 'ignore', diff_sensitivity: nil, image_ignore_threshold: nil,
|
19
|
+
carousels_enabled: nil, banners_enabled: nil, ads_enabled: nil, diff_ignore_threshold: nil
|
20
|
+
)
|
21
|
+
element_selector = {}
|
22
|
+
element_selector[:boundingBox] = bounding_box if bounding_box
|
23
|
+
element_selector[:elementXpath] = element_xpath if element_xpath
|
24
|
+
element_selector[:elementCSS] = element_css if element_css
|
25
|
+
|
26
|
+
region = {
|
27
|
+
algorithm: algorithm,
|
28
|
+
elementSelector: element_selector,
|
29
|
+
}
|
30
|
+
|
31
|
+
region[:padding] = padding if padding
|
32
|
+
|
33
|
+
if %w[standard intelliignore].include?(algorithm)
|
34
|
+
configuration = {
|
35
|
+
diffSensitivity: diff_sensitivity,
|
36
|
+
imageIgnoreThreshold: image_ignore_threshold,
|
37
|
+
carouselsEnabled: carousels_enabled,
|
38
|
+
bannersEnabled: banners_enabled,
|
39
|
+
adsEnabled: ads_enabled,
|
40
|
+
}.compact
|
41
|
+
|
42
|
+
region[:configuration] = configuration unless configuration.empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
assertion = {}
|
46
|
+
assertion[:diffIgnoreThreshold] = diff_ignore_threshold unless diff_ignore_threshold.nil?
|
47
|
+
region[:assertion] = assertion unless assertion.empty?
|
48
|
+
|
49
|
+
region
|
50
|
+
end
|
51
|
+
|
16
52
|
# Take a DOM snapshot and post it to the snapshot endpoint
|
17
53
|
def self.snapshot(driver, name, options = {})
|
18
54
|
return unless percy_enabled?
|
data/lib/version.rb
CHANGED
data/package.json
CHANGED
@@ -254,6 +254,64 @@ RSpec.describe Percy, type: :feature do
|
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
|
+
RSpec.describe Percy do
|
258
|
+
describe '.create_region' do
|
259
|
+
it 'creates a region with default values' do
|
260
|
+
region = Percy.create_region
|
261
|
+
|
262
|
+
expect(region[:algorithm]).to eq('ignore')
|
263
|
+
expect(region[:elementSelector]).to eq({})
|
264
|
+
expect(region).to_not have_key(:configuration)
|
265
|
+
expect(region).to_not have_key(:assertion)
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'creates a region with bounding_box, xpath, and css selectors' do
|
269
|
+
region = Percy.create_region(
|
270
|
+
bounding_box: {x: 10, y: 20, width: 100, height: 200},
|
271
|
+
element_xpath: '//div[@id="test"]',
|
272
|
+
element_css: '.test-class',
|
273
|
+
)
|
274
|
+
|
275
|
+
expect(region[:elementSelector][:boundingBox]).to eq({x: 10, y: 20, width: 100, height: 200})
|
276
|
+
expect(region[:elementSelector][:elementXpath]).to eq('//div[@id="test"]')
|
277
|
+
expect(region[:elementSelector][:elementCSS]).to eq('.test-class')
|
278
|
+
end
|
279
|
+
|
280
|
+
it 'creates a region with padding' do
|
281
|
+
region = Percy.create_region(padding: 10)
|
282
|
+
expect(region[:padding]).to eq(10)
|
283
|
+
end
|
284
|
+
|
285
|
+
it 'creates a region with configuration settings when algorithm is standard' do
|
286
|
+
region = Percy.create_region(
|
287
|
+
algorithm: 'standard',
|
288
|
+
diff_sensitivity: 0.5,
|
289
|
+
image_ignore_threshold: 0.3,
|
290
|
+
carousels_enabled: true,
|
291
|
+
banners_enabled: false,
|
292
|
+
ads_enabled: true,
|
293
|
+
)
|
294
|
+
|
295
|
+
expect(region[:configuration][:diffSensitivity]).to eq(0.5)
|
296
|
+
expect(region[:configuration][:imageIgnoreThreshold]).to eq(0.3)
|
297
|
+
expect(region[:configuration][:carouselsEnabled]).to eq(true)
|
298
|
+
expect(region[:configuration][:bannersEnabled]).to eq(false)
|
299
|
+
expect(region[:configuration][:adsEnabled]).to eq(true)
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'creates a region with assertion settings' do
|
303
|
+
region = Percy.create_region(diff_ignore_threshold: 0.2)
|
304
|
+
expect(region[:assertion][:diffIgnoreThreshold]).to eq(0.2)
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'does not add empty configuration or assertion keys' do
|
308
|
+
region = Percy.create_region(algorithm: 'ignore')
|
309
|
+
expect(region).to_not have_key(:configuration)
|
310
|
+
expect(region).to_not have_key(:assertion)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
257
315
|
RSpec.describe Percy, type: :feature do
|
258
316
|
before(:each) do
|
259
317
|
WebMock.reset!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percy-selenium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Perceptual Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
152
|
+
rubygems_version: 3.0.3.1
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Percy visual testing for Ruby Selenium
|