percy-selenium 1.0.0 → 1.0.2.pre.beta.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8f68750e4ecba2e810753f97e39f038a2e798201e326e5b01b2dbcb71abdcf4
4
- data.tar.gz: 3d152a595681acfb6849a48f2aaa0f74583f70f11c2e5ddbce5591c32b9c4c20
3
+ metadata.gz: d0606f4bf32f8297b9ed4a33dd99a6ac6807a67e3c5753c1d53aebca197bc916
4
+ data.tar.gz: c2cf614fd642b15c293f55891405c8d101c220155ef3e8eabbe8abbdc11be1b2
5
5
  SHA512:
6
- metadata.gz: 88c54fc694e3b02508bd1f8b3812543dd3eabc7b1fbad6a85a5b7fb3b3dc014f1bbdee89c799088b9c175719df586d926875d0678d659b3f31404c05fc7092a0
7
- data.tar.gz: ddfd1237e437efe2fd5f8789983374a0793180e3aa4a751633122c20883c80fc38291459540e66e75167f89de6ee4f3d73c9fdaed6c517874ad56b9c2e9d28e5
6
+ metadata.gz: '09ec0b88cbee30f308e8936ec9cacc066de599dbf781648bb0399c7cfa6a515041fbfc433a04f6cc936b07ff0c488dc638c9162ec61c764d12191f4f7afb6179'
7
+ data.tar.gz: 15f97893d187ccdf06f59ec50941b953e2b348346e533464f2bf31d34d05dcbbe7c20e1ed90d1ae8a605c275392fda0e1772c686ad4239835c73b8965059f90a
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us fix the issue
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+ ---
8
+
9
+ <!--
10
+ ## Have you read the "Debugging SDKs" doc yet?
11
+
12
+ There are common setup gotchas that happen with Percy's SDKs, it would be worth reading
13
+ the debugging document, which might already answer your question:
14
+ https://docs.percy.io/docs/debugging-sdk
15
+
16
+ ## Reach out to Percy support instead?
17
+
18
+ If you’re having issues that _aren’t SDK bugs_, it would be best for you to
19
+ reach out to support instead: support@percy.io or
20
+ https://www.browserstack.com/contact#technical-support
21
+ -->
22
+
23
+ ## The problem
24
+
25
+ Briefly describe the issue you are experiencing (or the feature you want to see
26
+ added to Percy). Tell us what you were trying to do and what happened
27
+ instead. Remember, this is _not_ a place to ask questions. For that, go to
28
+ https://github.com/percy/cli/discussions/new
29
+
30
+ ## Environment
31
+
32
+ - Node version:
33
+ - `@percy/cli` version:
34
+ - Version of Percy SDK you’re using:
35
+ - If needed, a build or snapshot ID:
36
+ - OS version:
37
+ - Type of shell command-line [interface]:
38
+
39
+ ## Details
40
+
41
+ If necessary, describe the problem you have been experiencing in more detail.
42
+
43
+ ## Debug logs
44
+
45
+ If you are reporting a bug, _always_ include logs! [Give the "Debugging SDKs"
46
+ document a quick read for how to gather logs](https://docs.percy.io/docs/debugging-sdks#debugging-sdks)
47
+
48
+ Please do not trim or edit these logs, often times there are hints in the full
49
+ logs that help debug what is going on.
50
+
51
+ ## Code to reproduce issue
52
+
53
+ Given the nature of testing/environment bugs, it’s best to try and isolate the
54
+ issue in a reproducible repo. This will make it much easier for us to diagnose
55
+ and fix.
@@ -3,28 +3,26 @@ tag-template: 'v$RESOLVED_VERSION'
3
3
  categories:
4
4
  - title: '💥 Breaking Changes'
5
5
  labels:
6
- - breaking
6
+ - 💥 breaking
7
7
  - title: '✨ Enhancements'
8
8
  labels:
9
- - feature
10
- - enhancement
9
+ - ✨ enhancement
11
10
  - title: '🐛 Bug Fixes'
12
11
  labels:
13
- - fix
14
- - bugfix
15
- - bug
16
- - title: '🏗 Maintenance'
12
+ - 🐛 bug
13
+ - title: '🏗 Maintenance'
17
14
  labels:
18
- - chore
19
- - dependencies
15
+ - 🧹 maintenance
16
+ - title: '⬆️⬇️ Dependency Updates'
17
+ labels:
18
+ - ⬆️⬇️ dependencies
20
19
  change-title-escapes: '\<*_&#@'
21
20
  version-resolver:
22
21
  major:
23
22
  labels:
24
- - breaking
23
+ - 💥 breaking
25
24
  minor:
26
25
  labels:
27
- - feature
28
- - enhancement
26
+ - ✨ enhancement
29
27
  default: patch
30
28
  template: '$CHANGES'
@@ -0,0 +1,48 @@
1
+ # Name of this GitHub Actions workflow.
2
+ name: Semgrep
3
+
4
+ on:
5
+ # Scan changed files in PRs (diff-aware scanning):
6
+ # The branches below must be a subset of the branches above
7
+ pull_request:
8
+ branches: ["master", "main"]
9
+ push:
10
+ branches: ["master", "main"]
11
+ schedule:
12
+ - cron: '0 6 * * *'
13
+
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ semgrep:
20
+ # User definable name of this GitHub Actions job.
21
+ permissions:
22
+ contents: read # for actions/checkout to fetch code
23
+ security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
24
+ name: semgrep/ci
25
+ # If you are self-hosting, change the following `runs-on` value:
26
+ runs-on: ubuntu-latest
27
+
28
+ container:
29
+ # A Docker image with Semgrep installed. Do not change this.
30
+ image: returntocorp/semgrep
31
+
32
+ # Skip any PR created by dependabot to avoid permission issues:
33
+ if: (github.actor != 'dependabot[bot]')
34
+
35
+ steps:
36
+ # Fetch project source with GitHub Actions Checkout.
37
+ - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
38
+ # Run the "semgrep ci" command on the command line of the docker image.
39
+ - run: semgrep ci --sarif --output=semgrep.sarif
40
+ env:
41
+ # Add the rules that Semgrep uses by setting the SEMGREP_RULES environment variable.
42
+ SEMGREP_RULES: p/default # more at semgrep.dev/explore
43
+
44
+ - name: Upload SARIF file for GitHub Advanced Security Dashboard
45
+ uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2.20.0
46
+ with:
47
+ sarif_file: semgrep.sarif
48
+ if: always()
@@ -0,0 +1,30 @@
1
+ name: 'Close stale issues and PRs'
2
+ on:
3
+ schedule:
4
+ - cron: '0 19 * * 2'
5
+
6
+ jobs:
7
+ stale:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/stale@v4
11
+ with:
12
+ stale-issue-message: >-
13
+ This issue is stale because it has been open for more than 14 days with no activity.
14
+ Remove stale label or comment or this will be closed in 14 days.
15
+ stale-pr-message: >-
16
+ This PR is stale because it has been open for more than 14 days with no activity.
17
+ Remove stale label or comment or this will be closed in 14 days.
18
+ close-issue-message: >-
19
+ This issue was closed because it has been stalled for 28 days with no activity.
20
+ close-pr-message: >-
21
+ This PR was closed because it has been stalled for 28 days with no activity.
22
+ days-before-issue-stale: 14
23
+ days-before-pr-stale: 14
24
+ # close 14 days _after_ initial warning
25
+ days-before-issue-close: 14
26
+ days-before-pr-close: 14
27
+ exempt-pr-labels: '❄️ on ice'
28
+ exempt-issue-labels: '🐛 bug,❄️ on ice,✨ enhancement'
29
+ exempt-all-assignees: true
30
+ stale-pr-label: '🍞 stale'
@@ -2,8 +2,12 @@ name: Test
2
2
  on:
3
3
  push:
4
4
  branches: [main]
5
- pull_request:
6
5
  workflow_dispatch:
6
+ inputs:
7
+ branch:
8
+ required: false
9
+ type: string
10
+ default: master
7
11
  jobs:
8
12
  test:
9
13
  name: Test
@@ -13,6 +17,15 @@ jobs:
13
17
  ruby: ['2.6', '2.7']
14
18
  runs-on: ${{ matrix.os }}
15
19
  steps:
20
+ - uses: actions-ecosystem/action-regex-match@v2
21
+ id: regex-match
22
+ if: ${{ github.event_name == 'workflow_dispatch' }}
23
+ with:
24
+ text: ${{ github.event.inputs.branch }}
25
+ regex: '^[a-zA-Z0-9_/\-]+$'
26
+ - name: Break on invalid branch name
27
+ run: exit 1
28
+ if: ${{ github.event_name == 'workflow_dispatch' && steps.regex-match.outputs && steps.regex-match.outputs.match == '' }}
16
29
  - uses: actions/checkout@v2
17
30
  - uses: ruby/setup-ruby@v1
18
31
  with:
@@ -23,4 +36,30 @@ jobs:
23
36
  path: "./vendor/bundle"
24
37
  key: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/${{ hashFiles('**/Gemfile.lock') }}
25
38
  restore-keys: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/
26
- - run: bundle exec rspec
39
+ - uses: actions/setup-node@v3
40
+ with:
41
+ node-version: 16
42
+ - name: Get yarn cache directory path
43
+ id: yarn-cache-dir-path
44
+ run: echo "::set-output name=dir::$(yarn cache dir)"
45
+ - uses: actions/cache@v3
46
+ with:
47
+ path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
48
+ key: v1/${{ runner.os }}/node-${{ matrix.node }}/${{ hashFiles('**/yarn.lock') }}
49
+ restore-keys: v1/${{ runner.os }}/node-${{ matrix.node }}/
50
+ - run: yarn
51
+ - name: Set up @percy/cli from git
52
+ if: ${{ github.event_name == 'workflow_dispatch' }}
53
+ run: |
54
+ cd /tmp
55
+ git clone --branch ${{ github.event.inputs.branch }} --depth 1 https://github.com/percy/cli
56
+ cd cli
57
+ PERCY_PACKAGES=`find packages -mindepth 1 -maxdepth 1 -type d | sed -e 's/packages/@percy/g' | tr '\n' ' '`
58
+ git log -1
59
+ yarn
60
+ yarn build
61
+ yarn global:link
62
+ cd ${{ github.workspace }}
63
+ yarn remove @percy/cli && yarn link `echo $PERCY_PACKAGES`
64
+ npx percy --version
65
+ - run: npx percy exec --testing -- bundle exec rspec
data/CODEOWNERS ADDED
@@ -0,0 +1 @@
1
+ * @percy/percy-product-reviewers
data/Gemfile CHANGED
@@ -7,7 +7,8 @@ gem "guard-rspec", require: false
7
7
 
8
8
  group :test, :development do
9
9
  gem "webmock"
10
- gem "puma"
10
+ gem "puma", '~> 5.6'
11
+ gem "rackup"
11
12
  gem "pry"
12
13
  gem "simplecov", require: false
13
14
  end
data/README.md CHANGED
@@ -61,9 +61,4 @@ $ percy exec -- [ruby test command]
61
61
 
62
62
  - `driver` (**required**) - A selenium-webdriver driver instance
63
63
  - `name` (**required**) - The snapshot name; must be unique to each snapshot
64
- - `options` - Additional snapshot options (overrides any project options)
65
- - `widths` - An array of widths to take screenshots at
66
- - `min_height` - The minimum viewport height to take screenshots at
67
- - `percy_css` - Percy specific CSS only applied in Percy's rendering environment
68
- - `request_headers` - Headers that should be used during asset discovery
69
- - `enable_javascript` - Enable JavaScript in Percy's rendering environment
64
+ - `options` - [See per-snapshot configuration options](https://docs.percy.io/docs/cli-configuration#per-snapshot-configuration)
data/lib/percy.rb CHANGED
@@ -25,11 +25,15 @@ module Percy
25
25
  url: driver.current_url,
26
26
  dom_snapshot: dom_snapshot,
27
27
  client_info: CLIENT_INFO,
28
- environment_info: ENV_INFO,)
28
+ environment_info: ENV_INFO,
29
+ **options,)
29
30
 
30
31
  unless response.body.to_json['success']
31
32
  raise StandardError, data['error']
32
33
  end
34
+
35
+ body = JSON.parse(response.body)
36
+ body['data']
33
37
  rescue StandardError => e
34
38
  log("Could not take DOM snapshot '#{name}'")
35
39
 
@@ -89,7 +93,11 @@ module Percy
89
93
  uri = URI("#{PERCY_SERVER_ADDRESS}/#{url}")
90
94
 
91
95
  response = if data
92
- Net::HTTP.post(uri, data.to_json)
96
+ http = Net::HTTP.new(uri.host, uri.port)
97
+ http.read_timeout = 600 # seconds
98
+ request = Net::HTTP::Post.new(uri.path)
99
+ request.body = data.to_json
100
+ http.request(request)
93
101
  else
94
102
  Net::HTTP.get_response(uri)
95
103
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Percy
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.2-beta.0'.freeze
3
3
  end
data/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "private": true,
3
+ "scripts": {
4
+ "test": "percy exec --testing -- bundle exec rspec"
5
+ },
6
+ "devDependencies": {
7
+ "@percy/cli": "^1.16.0"
8
+ }
9
+ }
10
+
@@ -1,3 +1,4 @@
1
+ # rubocop:disable RSpec/MultipleDescribes
1
2
  RSpec.describe Percy, type: :feature do
2
3
  before(:each) do
3
4
  WebMock.disable_net_connect!(allow: '127.0.0.1', disallow: 'localhost')
@@ -89,7 +90,7 @@ RSpec.describe Percy, type: :feature do
89
90
  .to_return(status: 200, body: '{"success": "true" }', headers: {})
90
91
 
91
92
  visit 'index.html'
92
- Percy.snapshot(page, 'Name')
93
+ data = Percy.snapshot(page, 'Name', widths: [944])
93
94
 
94
95
  expect(WebMock).to have_requested(:post, "#{Percy::PERCY_SERVER_ADDRESS}/percy/snapshot")
95
96
  .with(
@@ -100,8 +101,72 @@ RSpec.describe Percy, type: :feature do
100
101
  "<html><head><title>I am a page</title></head><body>Snapshot me\n</body></html>",
101
102
  client_info: "percy-selenium-ruby/#{Percy::VERSION}",
102
103
  environment_info: "selenium/#{Selenium::WebDriver::VERSION} ruby/#{RUBY_VERSION}",
104
+ widths: [944],
103
105
  }.to_json,
104
106
  ).once
107
+
108
+ expect(data).to eq(nil)
109
+ end
110
+
111
+ it 'sends snapshots for sync' do
112
+ stub_request(:get, "#{Percy::PERCY_SERVER_ADDRESS}/percy/healthcheck")
113
+ .to_return(status: 200, body: '', headers: {'x-percy-core-version': '1.0.0'})
114
+
115
+ stub_request(:get, "#{Percy::PERCY_SERVER_ADDRESS}/percy/dom.js")
116
+ .to_return(
117
+ status: 200,
118
+ body: 'window.PercyDOM = { serialize: () => document.documentElement.outerHTML };',
119
+ headers: {},
120
+ )
121
+
122
+ stub_request(:post, 'http://localhost:5338/percy/snapshot')
123
+ .to_return(status: 200, body: '{"success": "true", "data": "sync_data" }', headers: {})
124
+
125
+ visit 'index.html'
126
+ data = Percy.snapshot(page, 'Name', {sync: true})
127
+
128
+ expect(WebMock).to have_requested(:post, "#{Percy::PERCY_SERVER_ADDRESS}/percy/snapshot")
129
+ .with(
130
+ body: {
131
+ name: 'Name',
132
+ url: 'http://127.0.0.1:3003/index.html',
133
+ dom_snapshot:
134
+ "<html><head><title>I am a page</title></head><body>Snapshot me\n</body></html>",
135
+ client_info: "percy-selenium-ruby/#{Percy::VERSION}",
136
+ environment_info: "selenium/#{Selenium::WebDriver::VERSION} ruby/#{RUBY_VERSION}",
137
+ widths: [944],
138
+ }.to_json,
139
+ ).once
140
+
141
+ expect(data).to eq('sync_data')
142
+ end
143
+ end
144
+ end
145
+
146
+ RSpec.describe Percy, type: :feature do
147
+ before(:each) do
148
+ WebMock.reset!
149
+ WebMock.allow_net_connect!
150
+ Percy._clear_cache!
151
+ end
152
+
153
+ describe 'integration', type: :feature do
154
+ it 'sends snapshots to percy server' do
155
+ visit 'index.html'
156
+ Percy.snapshot(page, 'Name', widths: [375])
157
+ sleep 5 # wait for percy server to process
158
+ resp = Net::HTTP.get_response(URI("#{Percy::PERCY_SERVER_ADDRESS}/test/requests"))
159
+ requests = JSON.parse(resp.body)['requests']
160
+ healthcheck = requests[0]
161
+ expect(healthcheck['url']).to eq('/percy/healthcheck')
162
+
163
+ snap = requests[2]['body']
164
+ expect(snap['name']).to eq('Name')
165
+ expect(snap['url']).to eq('http://127.0.0.1:3003/index.html')
166
+ expect(snap['client_info']).to include('percy-selenium-ruby')
167
+ expect(snap['environment_info']).to include('selenium')
168
+ expect(snap['widths']).to eq([375])
105
169
  end
106
170
  end
107
171
  end
172
+ # rubocop:enable RSpec/MultipleDescribes
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.0.0
4
+ version: 1.0.2.pre.beta.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Perceptual Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-28 00:00:00.000000000 Z
11
+ date: 2024-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -101,16 +101,20 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
104
105
  - ".github/dependabot.yml"
105
106
  - ".github/release-drafter.yml"
107
+ - ".github/workflows/Semgrep.yml"
106
108
  - ".github/workflows/changelog.yml"
107
109
  - ".github/workflows/lint.yml"
108
110
  - ".github/workflows/release.yml"
111
+ - ".github/workflows/stale.yml"
109
112
  - ".github/workflows/test.yml"
110
113
  - ".gitignore"
111
114
  - ".rspec"
112
115
  - ".rubocop.yml"
113
116
  - ".yardopts"
117
+ - CODEOWNERS
114
118
  - Gemfile
115
119
  - Guardfile
116
120
  - LICENSE
@@ -119,6 +123,7 @@ files:
119
123
  - Rakefile
120
124
  - lib/percy.rb
121
125
  - lib/version.rb
126
+ - package.json
122
127
  - percy-selenium.gemspec
123
128
  - spec/fixture/index.html
124
129
  - spec/lib/percy/percy_spec.rb
@@ -129,7 +134,7 @@ licenses:
129
134
  metadata:
130
135
  bug_tracker_uri: https://github.com/percy/percy-selenium-ruby/issues
131
136
  source_code_uri: https://github.com/percy/percy-selenium-ruby
132
- post_install_message:
137
+ post_install_message:
133
138
  rdoc_options: []
134
139
  require_paths:
135
140
  - lib
@@ -144,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
149
  - !ruby/object:Gem::Version
145
150
  version: '0'
146
151
  requirements: []
147
- rubygems_version: 3.0.3
148
- signing_key:
152
+ rubygems_version: 3.5.3
153
+ signing_key:
149
154
  specification_version: 4
150
155
  summary: Percy visual testing for Ruby Selenium
151
156
  test_files: