percy-selenium 1.0.1 → 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 +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +12 -4
- data/.github/workflows/Semgrep.yml +48 -0
- data/.github/workflows/test.yml +41 -2
- data/CODEOWNERS +1 -0
- data/Gemfile +2 -1
- data/lib/percy.rb +8 -1
- data/lib/version.rb +1 -1
- data/package.json +10 -0
- data/spec/lib/percy/percy_spec.rb +65 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0606f4bf32f8297b9ed4a33dd99a6ac6807a67e3c5753c1d53aebca197bc916
|
4
|
+
data.tar.gz: c2cf614fd642b15c293f55891405c8d101c220155ef3e8eabbe8abbdc11be1b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09ec0b88cbee30f308e8936ec9cacc066de599dbf781648bb0399c7cfa6a515041fbfc433a04f6cc936b07ff0c488dc638c9162ec61c764d12191f4f7afb6179'
|
7
|
+
data.tar.gz: 15f97893d187ccdf06f59ec50941b953e2b348346e533464f2bf31d34d05dcbbe7c20e1ed90d1ae8a605c275392fda0e1772c686ad4239835c73b8965059f90a
|
@@ -5,7 +5,14 @@ title: ''
|
|
5
5
|
labels: ''
|
6
6
|
assignees: ''
|
7
7
|
---
|
8
|
+
|
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
|
+
|
9
16
|
## Reach out to Percy support instead?
|
10
17
|
|
11
18
|
If you’re having issues that _aren’t SDK bugs_, it would be best for you to
|
@@ -35,10 +42,11 @@ If necessary, describe the problem you have been experiencing in more detail.
|
|
35
42
|
|
36
43
|
## Debug logs
|
37
44
|
|
38
|
-
If you are reporting a bug, _always_ include logs!
|
39
|
-
|
40
|
-
|
41
|
-
|
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.
|
42
50
|
|
43
51
|
## Code to reproduce issue
|
44
52
|
|
@@ -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()
|
data/.github/workflows/test.yml
CHANGED
@@ -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
|
-
-
|
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
data/lib/percy.rb
CHANGED
@@ -31,6 +31,9 @@ module Percy
|
|
31
31
|
unless response.body.to_json['success']
|
32
32
|
raise StandardError, data['error']
|
33
33
|
end
|
34
|
+
|
35
|
+
body = JSON.parse(response.body)
|
36
|
+
body['data']
|
34
37
|
rescue StandardError => e
|
35
38
|
log("Could not take DOM snapshot '#{name}'")
|
36
39
|
|
@@ -90,7 +93,11 @@ module Percy
|
|
90
93
|
uri = URI("#{PERCY_SERVER_ADDRESS}/#{url}")
|
91
94
|
|
92
95
|
response = if data
|
93
|
-
Net::HTTP.
|
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)
|
94
101
|
else
|
95
102
|
Net::HTTP.get_response(uri)
|
96
103
|
end
|
data/lib/version.rb
CHANGED
data/package.json
ADDED
@@ -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', widths: [944])
|
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(
|
@@ -103,6 +104,69 @@ RSpec.describe Percy, type: :feature do
|
|
103
104
|
widths: [944],
|
104
105
|
}.to_json,
|
105
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])
|
106
169
|
end
|
107
170
|
end
|
108
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.
|
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:
|
11
|
+
date: 2024-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
105
105
|
- ".github/dependabot.yml"
|
106
106
|
- ".github/release-drafter.yml"
|
107
|
+
- ".github/workflows/Semgrep.yml"
|
107
108
|
- ".github/workflows/changelog.yml"
|
108
109
|
- ".github/workflows/lint.yml"
|
109
110
|
- ".github/workflows/release.yml"
|
@@ -113,6 +114,7 @@ files:
|
|
113
114
|
- ".rspec"
|
114
115
|
- ".rubocop.yml"
|
115
116
|
- ".yardopts"
|
117
|
+
- CODEOWNERS
|
116
118
|
- Gemfile
|
117
119
|
- Guardfile
|
118
120
|
- LICENSE
|
@@ -121,6 +123,7 @@ files:
|
|
121
123
|
- Rakefile
|
122
124
|
- lib/percy.rb
|
123
125
|
- lib/version.rb
|
126
|
+
- package.json
|
124
127
|
- percy-selenium.gemspec
|
125
128
|
- spec/fixture/index.html
|
126
129
|
- spec/lib/percy/percy_spec.rb
|
@@ -131,7 +134,7 @@ licenses:
|
|
131
134
|
metadata:
|
132
135
|
bug_tracker_uri: https://github.com/percy/percy-selenium-ruby/issues
|
133
136
|
source_code_uri: https://github.com/percy/percy-selenium-ruby
|
134
|
-
post_install_message:
|
137
|
+
post_install_message:
|
135
138
|
rdoc_options: []
|
136
139
|
require_paths:
|
137
140
|
- lib
|
@@ -146,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
149
|
- !ruby/object:Gem::Version
|
147
150
|
version: '0'
|
148
151
|
requirements: []
|
149
|
-
rubygems_version: 3.
|
150
|
-
signing_key:
|
152
|
+
rubygems_version: 3.5.3
|
153
|
+
signing_key:
|
151
154
|
specification_version: 4
|
152
155
|
summary: Percy visual testing for Ruby Selenium
|
153
156
|
test_files:
|