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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d48523c91451a5f498c95bec1c937d275052d7f9ff4c6810bfae131fb0c6c23f
4
- data.tar.gz: f53f34f7cb9c9d100fcb9399cff0fe072b42eb27decd8cd87732b7331ccc3ebd
3
+ metadata.gz: 1182f98302b6e6a50148711618e377ca36e62ad06d8bfc8a6f3da3b7c34a8256
4
+ data.tar.gz: b8125cece8b3929bd8416bc15fcaac70fbf9b9f8832207ed47d95f88a167c013
5
5
  SHA512:
6
- metadata.gz: a0c7281c379dbecca1437da9ad73eb86ba1da0114fa5f8f5effbe72703a4d5702e4eb74d6d210ab0be5d11a48c274f6169c8452099aa77c09090f354a3f043bf
7
- data.tar.gz: 3f13093da87d137b2d47a86b25f46ae64d2d6681a5f2cab6531d6df1e6ee8b3878f8e29c160084efa95cde0f2a2f30efc49f95c22c87a054aac347def64521fd
6
+ metadata.gz: 3a5ffdebefdc4844c60e599bfda70a2375602970de16dbbf9dc5ca5be2d2b52a9cb5f9569215430431130345a43815a934037dd93efa934f4a12f67f9db76627
7
+ data.tar.gz: 4937624feab8efc33c64d4825204dc4a886dafca14b697be5343826260fb14f49eaad34dd74467a427fc38b7ebb40219b23805c3c43020af9ce844b3c85422d6
@@ -14,7 +14,7 @@ jobs:
14
14
  with:
15
15
  ruby-version: 2.6
16
16
  bundler-cache: true
17
- - uses: actions/cache@v2
17
+ - uses: actions/cache@v3
18
18
  with:
19
19
  path: "./vendor/bundle"
20
20
  key: v1/${{ runner.os }}/ruby-2.6/${{ hashFiles('**/Gemfile.lock') }}
@@ -11,7 +11,7 @@ jobs:
11
11
  with:
12
12
  ruby-version: 2.6
13
13
  bundler-cache: true
14
- - uses: actions/cache@v2
14
+ - uses: actions/cache@v3
15
15
  with:
16
16
  path: "./vendor/bundle"
17
17
  key: v1/${{ runner.os }}/ruby-2.6/${{ hashFiles('**/Gemfile.lock') }}
@@ -31,7 +31,7 @@ jobs:
31
31
  with:
32
32
  ruby-version: ${{matrix.ruby}}
33
33
  bundler-cache: true
34
- - uses: actions/cache@v2
34
+ - uses: actions/cache@v3
35
35
  with:
36
36
  path: "./vendor/bundle"
37
37
  key: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/${{ hashFiles('**/Gemfile.lock') }}
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
@@ -1,3 +1,3 @@
1
1
  module Percy
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
data/package.json CHANGED
@@ -4,6 +4,6 @@
4
4
  "test": "percy exec --testing -- bundle exec rspec"
5
5
  },
6
6
  "devDependencies": {
7
- "@percy/cli": "^1.29.5-beta.0"
7
+ "@percy/cli": "1.30.9"
8
8
  }
9
9
  }
@@ -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.0
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: 2024-10-07 00:00:00.000000000 Z
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.4.19
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