Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Integration test with SDK Regression #9

Merged
merged 13 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ name: Test
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
inputs:
branch:
required: false
type: string
default: master
jobs:
test:
name: Test
Expand All @@ -23,4 +27,30 @@ jobs:
path: "./vendor/bundle"
key: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/${{ hashFiles('**/Gemfile.lock') }}
restore-keys: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/
- run: bundle exec rspec
- uses: actions/setup-node@v3
with:
node-version: 14
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: v1/${{ runner.os }}/node-${{ matrix.node }}/${{ hashFiles('**/yarn.lock') }}
restore-keys: v1/${{ runner.os }}/node-${{ matrix.node }}/
- run: yarn
- name: Set up @percy/cli from git
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
cd /tmp
git clone --branch ${{ github.event.inputs.branch }} --depth 1 https://github.com/percy/cli
cd cli
PERCY_PACKAGES=`find packages -mindepth 1 -maxdepth 1 -type d | sed -e 's/packages/@percy/g' | tr '\n' ' '`
git log -1
yarn
yarn build
yarn global:link
cd ${{ github.workspace }}
yarn remove @percy/cli && yarn link `echo $PERCY_PACKAGES`
npx percy --version
- run: npx percy exec --testing -- bundle exec rspec
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ gem "guard-rspec", require: false

group :test, :development do
gem "webmock"
gem "puma"
gem "puma", '~> 5.6'
gem "rackup"
gem "pry"
gem "simplecov", require: false
end
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"private": true,
"scripts": {
"test": "percy exec --testing -- bundle exec rspec"
},
"devDependencies": {
"@percy/cli": "^1.16.0"
}
}

29 changes: 29 additions & 0 deletions spec/lib/percy/percy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# rubocop:disable RSpec/MultipleDescribes
RSpec.describe Percy, type: :feature do
before(:each) do
WebMock.disable_net_connect!(allow: '127.0.0.1', disallow: 'localhost')
Expand Down Expand Up @@ -106,3 +107,31 @@
end
end
end

RSpec.describe Percy, type: :feature do
before(:each) do
WebMock.reset!
WebMock.allow_net_connect!
Percy._clear_cache!
end

describe 'integration', type: :feature do
it 'sends snapshots to percy server' do
visit 'index.html'
Percy.snapshot(page, 'Name', widths: [375])
sleep 5 # wait for percy server to process
resp = Net::HTTP.get_response(URI("#{Percy::PERCY_SERVER_ADDRESS}/test/requests"))
requests = JSON.parse(resp.body)['requests']
healthcheck = requests[0]
expect(healthcheck['url']).to eq('/percy/healthcheck')

snap = requests[2]['body']
expect(snap['name']).to eq('Name')
expect(snap['url']).to eq('http://127.0.0.1:3003/index.html')
expect(snap['client_info']).to include('percy-selenium-ruby')
expect(snap['environment_info']).to include('selenium')
expect(snap['widths']).to eq([375])
end
end
itsjwala marked this conversation as resolved.
Show resolved Hide resolved
end
# rubocop:enable RSpec/MultipleDescribes