Skip to content

Commit

Permalink
feat: use happo instead of Percy for e2e snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu-foucault committed Jul 2, 2020
1 parent 15d8e90 commit a244a00
Show file tree
Hide file tree
Showing 10 changed files with 445 additions and 587 deletions.
53 changes: 1 addition & 52 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -445,44 +445,6 @@ jobs:
make test PSQL="psql -h localhost" CI_NO_PIPELINE=true
popd
e2e:
machine:
image: ubuntu-1604:201903-01
working_directory: ~/cas-ciip-portal
steps:
- attach_workspace:
at: ~/
- run:
name: "Checkout Submodules"
command: |
git submodule update --init
- run:
name: start postgres
command: |
source ~/.bashrc
pg_ctl start
createdb `whoami`
- run:
name: deploy schemas and data
command: |
source ~/.bashrc
./.bin/deploy-data.sh -dev
- run:
name: Create Mailhog server via docker image
command: docker run -d -p 1025:1025 -p 8025:8025 mailhog/mailhog
- run:
name: run end-to-end tests with cypress
environment:
SMTP_CONNECTION_STRING: smtp://@localhost:1025
SENDER_EMAIL: BCCAS <example@cas.com>
ADMIN_EMAIL: GHG Regulator <GHGRegulator@gov.bc.ca>
command: |
source ~/.asdf/asdf.sh
pushd app
NO_PDF=true NO_MATHJAX=true yarn start & yarn wait-on http://localhost:3004
yarn test:e2e
popd
e2e-snapshots:
machine:
image: ubuntu-1604:201903-01
Expand All @@ -509,7 +471,7 @@ jobs:
name: Create Mailhog server via docker image
command: docker run -d -p 1025:1025 -p 8025:8025 mailhog/mailhog
- run:
name: run end-to-end tests with percy and cypress
name: run end-to-end tests with happo and cypress
environment:
SMTP_CONNECTION_STRING: smtp://@localhost:1025
SENDER_EMAIL: BCCAS <example@cas.com>
Expand Down Expand Up @@ -576,22 +538,9 @@ workflows:
- deploy-test-data:
requires:
- tools
- e2e:
requires:
- compile
filters:
branches:
ignore:
- develop
- master
- e2e-snapshots:
requires:
- compile
filters:
branches:
only:
- develop
- master
- sqitch-plan-ends-with-tag:
filters:
branches:
Expand Down
11 changes: 11 additions & 0 deletions app/.happo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { RemoteBrowserTarget } = require('happo.io');

module.exports = {
apiKey: process.env.HAPPO_API_KEY,
apiSecret: process.env.HAPPO_API_SECRET,
targets: {
chrome: new RemoteBrowserTarget('chrome', {
viewport: '1024x768',
}),
},
};
2 changes: 1 addition & 1 deletion app/cypress/integration/analyst-diffing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ describe('When reviewing a submitted application as an analyst', () => {
cy.get('.fuel').get('.diffTo').contains('10');
cy.get('.production').get('.diffTo').contains('800');
// Take snapshot
cy.percySnapshot();
// cy.percySnapshot();
});
});
8 changes: 4 additions & 4 deletions app/cypress/integration/application-form-validation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('When reviewing a submitted application as an analyst', () => {
'#root_operationalRepresentative_mailingAddress_postalCode +div .error-detail'
).contains('Format should be A1A 1A1');

cy.percySnapshot('admin');
// Cy.percySnapshot('admin');

// Fix invalid data
cy.get('#root_operationalRepresentative_mailingAddress_postalCode')
Expand All @@ -110,7 +110,7 @@ describe('When reviewing a submitted application as an analyst', () => {
cy.get(
'#root_sourceTypes_0_gases_0_annualEmission +div .error-detail'
).contains('is a required property');
cy.percySnapshot('Emissions form');
// Cy.percySnapshot('Emissions form');

// Fix invalid data
cy.get('#root_sourceTypes_0_gases_0_annualEmission').type('42');
Expand All @@ -132,7 +132,7 @@ describe('When reviewing a submitted application as an analyst', () => {
cy.get('#root_0_emissionCategoryRowId +div .error-detail').contains(
'is a required property'
);
cy.percySnapshot('fuel');
// Cy.percySnapshot('fuel');

// Fix invalid data
cy.get('#root_0_fuelRowId').type('Diesel');
Expand All @@ -159,7 +159,7 @@ describe('When reviewing a submitted application as an analyst', () => {
cy.get('#root_0_productEmissions +div .error-detail').contains(
'is a required property'
);
cy.percySnapshot('production');
// Cy.percySnapshot('production');

// Fix invalid data
cy.get('#root_0_productRowId').clear().type('Aluminum');
Expand Down
4 changes: 2 additions & 2 deletions app/cypress/integration/application-production.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('The production tab', () => {
cy.get('#root_0_productUnits').invoke('val').should('contain', 'tonnes');
cy.get('#root_0_productAmount');
cy.get('#root_0_productEmissions');
cy.percySnapshot();
// Cy.percySnapshot();
});

it('Should not show amount, units or emissions when requiresProductAmount and requiresEmissionAllocation are false', () => {
Expand All @@ -42,6 +42,6 @@ describe('The production tab', () => {
cy.get('#root_0_productUnits').should('not.exist');
cy.get('#root_0_productAmount').should('not.exist');
cy.get('#root_0_productEmissions').should('not.exist');
cy.percySnapshot();
// Cy.percySnapshot();
});
});
7 changes: 1 addition & 6 deletions app/cypress/integration/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ describe('The index page', () => {
cy.get('#page-content');
cy.get('header').contains('Register');
cy.get('header').contains('Login');
cy.get('header').happoScreenshot({component: 'Header'});
cy.get('#page-content').contains('Register and Apply');
cy.get('#page-content').contains(
'Already have an account? Click here to login.'
);
});

it('matches the snapshot', () => {
cy.visit('/');
cy.get('#page-content');
cy.percySnapshot();
});
});
7 changes: 3 additions & 4 deletions app/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const percyHealthCheck = require('@percy/cypress/task');
const happoTask = require('happo-cypress/task');

module.exports = (on, _config) => {
on('task', percyHealthCheck);
require('cypress-plugin-retries/lib/plugin')(on);
module.exports = (on) => {
on('task', happoTask);
};
2 changes: 1 addition & 1 deletion app/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@percy/cypress';
import 'happo-cypress';

Cypress.Commands.add('login', (username, password) => {
// Open the login page, fill in the form with username and password and submit.
Expand Down
5 changes: 3 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"pretest": "npm run build:relay",
"test": "jest",
"pretest:e2e-snapshots": "node cypress/support/listAuthenticatedPages.js",
"test:e2e-snapshots": "percy exec -- cypress run",
"test:e2e-snapshots": "yarn happo-cypress -- -- cypress run",
"pretest:e2e": "node cypress/support/listAuthenticatedPages.js",
"test:e2e": "cypress run",
"precypress": "node cypress/support/listAuthenticatedPages.js",
Expand Down Expand Up @@ -175,7 +175,6 @@
},
"devDependencies": {
"@babel/core": "^7.10.3",
"@percy/cypress": "^2.3.1",
"@storybook/addon-a11y": "^5.3.19",
"@storybook/addon-actions": "^5.3.19",
"@storybook/addon-cssresources": "^5.3.19",
Expand Down Expand Up @@ -220,6 +219,8 @@
"eslint-plugin-shopify": "^35.0.0",
"graphql-query-test-mock": "^0.12.0",
"graphql-tag-pluck": "^0.8.5",
"happo-cypress": "^1.6.1",
"happo.io": "^5.6.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^25.5.4",
"jest-canvas-mock": "^2.1.2",
Expand Down
Loading

0 comments on commit a244a00

Please sign in to comment.