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

feat: Integrated Visual Regression with ember-backstop #94

Merged
merged 40 commits into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9b73395
Integrating Visual Regression
sharath-sriram Jan 28, 2020
ad8a677
Removed lerna since flag
sharath-sriram Jan 28, 2020
198d79a
Merge branch 'master' into visual-regression
sharath-sriram Jan 28, 2020
06aecbb
Merge branch 'master' into visual-regression
shibulijack-fd Jan 29, 2020
907b60a
made change to .gitignore
sharath-sriram Jan 29, 2020
58ac0fb
Backstop ref changes
sharath-sriram Jan 29, 2020
805479f
Made all computed properties computed
sharath-sriram Jan 29, 2020
241ebb6
Checking an artifact workflow
sharath-sriram Jan 29, 2020
ea94eed
Changed artifact workflow with path
sharath-sriram Jan 29, 2020
6ec4cb2
Changed backstop config
sharath-sriram Jan 29, 2020
728f21d
Backstop Debug
sharath-sriram Jan 29, 2020
4c1a25c
Backstop Debug Window Eliminated
sharath-sriram Jan 29, 2020
2aff9ba
Enabled CI Reporting
sharath-sriram Jan 29, 2020
536bc96
Reduced async limit
sharath-sriram Jan 29, 2020
a3756fa
Trial with max threshold
sharath-sriram Jan 29, 2020
0747420
Trial check for screenshots
sharath-sriram Jan 29, 2020
109872d
Full threshold
sharath-sriram Jan 29, 2020
33e9e6d
New inline banner
sharath-sriram Jan 29, 2020
2e116de
no tests for banners
sharath-sriram Jan 30, 2020
593cf75
Run 2 VR tests
sharath-sriram Jan 30, 2020
2da6b11
Removed workflow downloads
sharath-sriram Jan 30, 2020
bcc7829
Experiments I with async
sharath-sriram Jan 30, 2020
0d5b5a4
Experiments II with async
sharath-sriram Jan 30, 2020
00c3322
Experiments III with async
sharath-sriram Jan 30, 2020
55b2cb6
Experiments IV with async
sharath-sriram Jan 30, 2020
5bb53d6
Experiments V with async
sharath-sriram Jan 30, 2020
6de0928
Experiments VI
sharath-sriram Jan 30, 2020
dcda609
Experiments VII
sharath-sriram Jan 30, 2020
fad0279
Parallel process
sharath-sriram Jan 30, 2020
eff5c5a
Normal threshold limits
sharath-sriram Jan 30, 2020
2f355b1
fix(tests): concurrency
Jan 30, 2020
732df7a
fix(lerna): removed --no-bail
Jan 30, 2020
4d53e0c
New ref images
sharath-sriram Jan 30, 2020
750b14e
fix: button ref images
Jan 30, 2020
882a22b
changed threshold
sharath-sriram Jan 30, 2020
c2cb9ed
Merge branch 'visual-regression' of github.com:freshdesk/nucleus into…
sharath-sriram Jan 30, 2020
2e3ac71
Update continuous-integration-workflow.yml
shibulijack-fd Jan 30, 2020
3eae0ef
Hopefully final ref images
sharath-sriram Jan 31, 2020
1491341
Cleanup for final review
sharath-sriram Jan 31, 2020
cfa96d8
Made required changes
sharath-sriram Jan 31, 2020
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
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v2

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ tmp
/bower.json.ember-try
/package.json.ember-try
.DS_Store

#backstopjs
html_report
bitmaps_test
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"scripts": {
"start": "yarn workspace nucleus start",
"test": "lerna run test --parallel --no-private",
"test": "lerna run test --no-private --stream --concurrency 1",
"build": "lerna run build --parallel --no-private",
"lint": "lerna run lint:hbs",
"lerna:version": "lerna version prerelease --preid beta",
Expand All @@ -21,7 +21,7 @@
"ember-cli": "~3.11.0",
"ember-source-channel-url": "^2.0.0",
"ember-try": "^1.1.0",
"lerna": "^3.18.4"
"lerna": "^3.20.2"
},
"engines": {
"node": "^10.13.0",
Expand Down
38 changes: 38 additions & 0 deletions packages/banner/ember-backstop/backstop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require('path');
sharath-sriram marked this conversation as resolved.
Show resolved Hide resolved

module.exports = {
id: `ember-backstop test`,
viewports: [
{
label: 'webview',
width: 1440,
height: 900,
},
],
onBeforeScript: `puppet/onBefore.js`,
onReadyScript: `puppet/onReady.js`,
scenarios: [
{
label: '{testName}',
cookiePath: 'backstop_data/engine_scripts/cookies.json',
url: '{origin}/backstop/dview/{testId}/{scenarioId}',
delay: 500,
},
],
paths: {
bitmaps_reference: 'backstop_data/bitmaps_reference',
bitmaps_test: 'backstop_data/bitmaps_test',
engine_scripts: 'backstop_data/engine_scripts',
html_report: 'backstop_data/html_report',
ci_report: 'backstop_data/ci_report',
},
report: [],
engine: 'puppet',
engineOptions: {
args: ['--no-sandbox'],
},
asyncCaptureLimit: 10,
asyncCompareLimit: 50,
debug: false,
debugWindow: false,
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-env browser, node */

module.exports = async (page, scenario) => {
const hoverSelector = scenario.hoverSelectors || scenario.hoverSelector;
const clickSelector = scenario.clickSelectors || scenario.clickSelector;
const keyPressSelector = scenario.keyPressSelectors || scenario.keyPressSelector;
const scrollToSelector = scenario.scrollToSelector;
const postInteractionWait = scenario.postInteractionWait; // selector [str] | ms [int]

if (keyPressSelector) {
for (const keyPressSelectorItem of [].concat(keyPressSelector)) {
await page.waitFor(keyPressSelectorItem.selector);
await page.type(keyPressSelectorItem.selector, keyPressSelectorItem.keyPress);
}
}

if (hoverSelector) {
for (const hoverSelectorIndex of [].concat(hoverSelector)) {
await page.waitFor(hoverSelectorIndex);
await page.hover(hoverSelectorIndex);
}
}

if (clickSelector) {
for (const clickSelectorIndex of [].concat(clickSelector)) {
await page.waitFor(clickSelectorIndex);
await page.click(clickSelectorIndex);
}
}

if (postInteractionWait) {
await page.waitFor(postInteractionWait);
}

if (scrollToSelector) {
await page.waitFor(scrollToSelector);
await page.evaluate(scrollToSelector => {
document.querySelector(scrollToSelector).scrollIntoView();
}, scrollToSelector);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-env browser, node */

const debug = require('debug')('BackstopJS');

module.exports = async (page, scenario, vp) => {
debug('SCENARIO > ' + scenario.label);
await require('./overrideCSS')(page, scenario);
await require('./clickAndHoverHelper')(page, scenario);

// add more ready handlers here...
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-env browser, node */
sharath-sriram marked this conversation as resolved.
Show resolved Hide resolved

module.exports = function(page, scenario) {
// inject arbitrary css to override styles
page.evaluate(() => {
const BACKSTOP_TEST_CSS_OVERRIDE = `#ember-testing {width: 100% !important; height: 100% !important; -webkit-transform: scale(1) !important; transform: scale(1) !important;}`;
let style = document.createElement('style');
style.type = 'text/css';
let styleNode = document.createTextNode(BACKSTOP_TEST_CSS_OVERRIDE);
style.appendChild(styleNode);
document.head.appendChild(style);
});
};
1 change: 1 addition & 0 deletions packages/banner/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
module.exports = function(defaults) {
let app = new EmberAddon(defaults,
{
hinting: false,
stylelint: {
linterConfig:{
syntax: 'scss'
Expand Down
4 changes: 3 additions & 1 deletion packages/banner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"lint:js": "eslint .",
"start": "ember serve -p 4003",
"deploy": "ember deploy production",
"test": "COVERAGE=TRUE ember test --test-port=1512",
"test": "ember backstop-remote & COVERAGE=TRUE ember test --test-port=1512",
"posttest": "ember backstop-stop",
"test:dev": "ember test --server -launch=false"
},
"dependencies": {
Expand All @@ -41,6 +42,7 @@
"broccoli-funnel": "^2.0.2",
"broccoli-merge-trees": "^3.0.2",
"ember-a11y-testing": "^1.0.0",
"ember-backstop": "^1.3.4",
"ember-cli": "~3.13.1",
"ember-cli-autoprefixer": "^0.8.1",
"ember-cli-code-coverage": "^1.0.0-beta.8",
Expand Down
6 changes: 6 additions & 0 deletions packages/banner/testem.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@ module.exports = {
'--window-size=1440,900'
].filter(Boolean)
}
},
proxies: {
'/backstop': {
target: 'http://localhost:1512',
secure: false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import hbs from 'htmlbars-inline-precompile';
import a11yAudit from 'ember-a11y-testing/test-support/audit';
import setupBanner from '../../helpers/setup-banner';
import { ITEMS } from '../../constants/nucleus-banner';
import backstop from 'ember-backstop/test-support/backstop';

let StubMapsService = Service.extend({
items: ITEMS
Expand Down Expand Up @@ -50,4 +51,41 @@ module('Integration | Component | nucleus-banner', function(hooks) {
assert.ok(true, 'no a11y errors found!');
});
});

test('normal banner passes visual regression tests', async function(assert){
var bannerObject = [{title:'This is a banner', type:'success'}]
const nucleusBanner = Service.extend({
items: bannerObject,
});
this.owner.register('service:nucleusBanner', nucleusBanner);

await render(hbs`
{{nucleus-banner}}
`);
await backstop(assert, {scenario: {misMatchThreshold: 0.1}});
});

test('banner with link passes visual regression tests', async function(assert){
let closeAction = this.spy();
let displayedItems = [{ title: 'This is another banner',
type: 'danger',
isDismissible: true,
content: {
linkAction: closeAction,
linkText: 'Click here'
},
}, {
title:"This is another banner",
type: 'danger',
isDismissible: true
}]
const nucleusBanner = Service.extend({
items: displayedItems,
});
this.owner.register('service:nucleusBanner', nucleusBanner);
await render(hbs`
{{nucleus-banner}}
`);
await backstop(assert,{scenario: {misMatchThreshold: 0.1}});
});
});
38 changes: 38 additions & 0 deletions packages/button/ember-backstop/backstop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require('path');
sharath-sriram marked this conversation as resolved.
Show resolved Hide resolved

module.exports = {
id: `ember-backstop test`,
viewports: [
{
label: 'webview',
width: 1440,
height: 900,
},
],
onBeforeScript: `puppet/onBefore.js`,
onReadyScript: `puppet/onReady.js`,
scenarios: [
{
label: '{testName}',
cookiePath: 'backstop_data/engine_scripts/cookies.json',
url: '{origin}/backstop/dview/{testId}/{scenarioId}',
delay: 500,
},
],
paths: {
bitmaps_reference: 'backstop_data/bitmaps_reference',
bitmaps_test: 'backstop_data/bitmaps_test',
engine_scripts: 'backstop_data/engine_scripts',
html_report: 'backstop_data/html_report',
ci_report: 'backstop_data/ci_report',
},
report: [],
engine: 'puppet',
engineOptions: {
args: ['--no-sandbox'],
},
asyncCaptureLimit: 10,
asyncCompareLimit: 50,
debug: false,
debugWindow: false,
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-env browser, node */

module.exports = async (page, scenario) => {
const hoverSelector = scenario.hoverSelectors || scenario.hoverSelector;
const clickSelector = scenario.clickSelectors || scenario.clickSelector;
const keyPressSelector = scenario.keyPressSelectors || scenario.keyPressSelector;
const scrollToSelector = scenario.scrollToSelector;
const postInteractionWait = scenario.postInteractionWait; // selector [str] | ms [int]

if (keyPressSelector) {
for (const keyPressSelectorItem of [].concat(keyPressSelector)) {
await page.waitFor(keyPressSelectorItem.selector);
await page.type(keyPressSelectorItem.selector, keyPressSelectorItem.keyPress);
}
}

if (hoverSelector) {
for (const hoverSelectorIndex of [].concat(hoverSelector)) {
await page.waitFor(hoverSelectorIndex);
await page.hover(hoverSelectorIndex);
}
}

if (clickSelector) {
for (const clickSelectorIndex of [].concat(clickSelector)) {
await page.waitFor(clickSelectorIndex);
await page.click(clickSelectorIndex);
}
}

if (postInteractionWait) {
await page.waitFor(postInteractionWait);
}

if (scrollToSelector) {
await page.waitFor(scrollToSelector);
await page.evaluate(scrollToSelector => {
document.querySelector(scrollToSelector).scrollIntoView();
}, scrollToSelector);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-env browser, node */

const debug = require('debug')('BackstopJS');

module.exports = async (page, scenario, vp) => {
debug('SCENARIO > ' + scenario.label);
await require('./overrideCSS')(page, scenario);
await require('./clickAndHoverHelper')(page, scenario);

// add more ready handlers here...
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-env browser, node */

module.exports = function(page, scenario) {
// inject arbitrary css to override styles
page.evaluate(() => {
const BACKSTOP_TEST_CSS_OVERRIDE = `#ember-testing {width: 100% !important; height: 100% !important; -webkit-transform: scale(1) !important; transform: scale(1) !important;}`;
let style = document.createElement('style');
style.type = 'text/css';
let styleNode = document.createTextNode(BACKSTOP_TEST_CSS_OVERRIDE);
style.appendChild(styleNode);
document.head.appendChild(style);
});
};
1 change: 1 addition & 0 deletions packages/button/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
module.exports = function(defaults) {
let app = new EmberAddon(defaults,
{
hinting: false,
stylelint: {
linterConfig:{
syntax: 'scss'
Expand Down
4 changes: 3 additions & 1 deletion packages/button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"lint:js": "eslint .",
"start": "ember serve -p 4003",
"deploy": "ember deploy production",
"test": "COVERAGE=TRUE ember test --test-port=1509",
"test": "ember backstop-remote & COVERAGE=TRUE ember test --test-port=1509",
"posttest": "ember backstop-stop",
"test:dev": "COVERAGE=TRUE ember test --server -launch=false"
},
"dependencies": {
Expand All @@ -39,6 +40,7 @@
"broccoli-funnel": "^2.0.2",
"broccoli-merge-trees": "^3.0.2",
"ember-a11y-testing": "^1.0.0",
"ember-backstop": "^1.3.4",
"ember-cli": "~3.13.1",
"ember-cli-autoprefixer": "^0.8.1",
"ember-cli-code-coverage": "^1.0.0-beta.8",
Expand Down
6 changes: 6 additions & 0 deletions packages/button/testem.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@ module.exports = {
'--window-size=1440,900'
].filter(Boolean)
}
},
proxies: {
'/backstop': {
target: 'http://localhost:1509',
secure: false
}
}
}
Loading