Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #118 from Tripwire/feature/testing
Browse files Browse the repository at this point in the history
Feature/testing
  • Loading branch information
cdaringe authored Sep 7, 2017
2 parents a123f97 + a4b5656 commit ca5dfd8
Show file tree
Hide file tree
Showing 89 changed files with 4,748 additions and 2,725 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ storybook-static
lib
suir.stories.js
styleguide

backstop_data/*
!backstop_data/bitmaps_reference
!backstop_data/casper_scripts
*.iml
*.idea
cache.json
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
"program": "${workspaceRoot}/scripts/build.js",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "launch",
"name": "Test",
"program": "${workspaceRoot}/scripts/test.js",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "attach",
Expand Down
48 changes: 48 additions & 0 deletions backstop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"id": "octagon",
"viewports": [
{
"label": "tablet",
"width": 1024,
"height": 768
}
],
"onBeforeScript": "chromy/onBefore.js",
"onReadyScript": "chromy/onReady.js",
"scenarios": [
{
"label": "Octagon",
"cookiePath": "backstop_data/engine_scripts/cookies.json",
"url": "http://localhost:3333",
"referenceUrl": "",
"readyEvent": "",
"readySelector": "",
"delay": 2000,
"hideSelectors": [
".hide-in-test"
],
"removeSelectors": [],
"hoverSelector": "",
"clickSelector": "",
"postInteractionWait": "",
"selectors": [
"[data-reactroot]:not(.hasSidebar-0-2)"
],
"selectorExpansion": true,
"misMatchThreshold" : 0.1,
"requireSameDimensions": true
}
],
"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": ["browser"],
"engine": "chrome",
"engineFlags": [],
"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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions backstop_data/casper_scripts/onBefore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = function (casper, scenario, vp) {
// This script runs before your app loads. Edit here to log-in, load cookies or set other states required for your test.
console.log('onBefore.js has run for ' + vp.name + '.')
}

// // EXAMPLE: LOGIN BEFORE RUNNING TESTS
// module.exports = function(casper, scenario, vp) {
// casper.thenOpen(scenario.url, function(){
// if (this.exists('form#user-login-form')) {
// this.fill('form#loginForm',{
// 'username': 'test',
// 'password': 'changeme'
// }, true);
// }
// });
// };
6 changes: 6 additions & 0 deletions backstop_data/casper_scripts/onReady.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function (casper, scenario, vp) {
casper.evaluate(function () {
// Your web-app is now loaded. Edit here to simulate user interacions or other state changes.
})
console.log('onReady.js has run for: ', vp.name)
}
25 changes: 25 additions & 0 deletions backstop_data/engine_scripts/casper/clickAndHoverHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var WAIT_TIMEOUT = 5000;

module.exports = function(casper, scenario) {
var waitFor = require('./waitForHelperHelper')(casper, WAIT_TIMEOUT);
var hoverSelector = scenario.hoverSelector,
clickSelector = scenario.clickSelector,
postInteractionWait = scenario.postInteractionWait;

if (hoverSelector) {
waitFor(hoverSelector);
casper.then(function () {
casper.mouse.move(hoverSelector);
});
}

if (clickSelector) {
waitFor(clickSelector);
casper.then(function () {
casper.click(clickSelector);
});
}

// TODO: if postInteractionWait === integer then do ==> wait(postInteractionWait) || elsevvv
waitFor(postInteractionWait);
};
15 changes: 15 additions & 0 deletions backstop_data/engine_scripts/casper/loadCookies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var fs = require('fs');

module.exports = function (casper, scenario) {
var cookies = [];
var cookiePath = scenario.cookiePath;

// READ COOKIES FROM FILE IF EXISTS
if (fs.exists(cookiePath)) {
cookies = JSON.parse(fs.read(cookiePath));
}

casper.page.cookies = cookies;
console.log('Cookie state restored with cookies:', JSON.stringify(cookies, null, 2));
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36');
};
4 changes: 4 additions & 0 deletions backstop_data/engine_scripts/casper/onBefore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = function (casper, scenario, vp) {
require('./loadCookies')(casper, scenario);
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36');
};
5 changes: 5 additions & 0 deletions backstop_data/engine_scripts/casper/onReady.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function(casper, scenario, vp) {
console.log('SCENARIO> ' + scenario.label);
require('./clickAndHoverHelper')(casper, scenario);
// add more helpers here...
};
18 changes: 18 additions & 0 deletions backstop_data/engine_scripts/casper/waitForHelperHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var TIMEOUT_DEFAULT = 2000;

module.exports = function (casper, timeout) {
var TIMEOUT = timeout || TIMEOUT_DEFAULT;

return function waitFor (selector) {
if (selector) {
casper.waitForSelector(
selector,
function () {},
function () {
console.error('NOT FOUND > ' + selector);
},
TIMEOUT
);
}
};
};
24 changes: 24 additions & 0 deletions backstop_data/engine_scripts/chromy/clickAndHoverHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = function (chromy, scenario) {
var hoverSelector = scenario.hoverSelector;
var clickSelector = scenario.clickSelector;
var postInteractionWait = scenario.postInteractionWait; // selector [str] | ms [int]

if (hoverSelector) {
chromy
.wait(hoverSelector)
.rect(hoverSelector)
.result(function (rect) {
chromy.mouseMoved(rect.left, rect.top);
});
}

if (clickSelector) {
chromy
.wait(clickSelector)
.click(clickSelector);
}

if (postInteractionWait) {
chromy.wait(postInteractionWait);
}
};
22 changes: 22 additions & 0 deletions backstop_data/engine_scripts/chromy/loadCookies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var fs = require('fs');

module.exports = function (chromy, scenario) {
var cookies = [];
var cookiePath = scenario.cookiePath;

// READ COOKIES FROM FILE IF EXISTS
if (fs.existsSync(cookiePath)) {
cookies = JSON.parse(fs.readFileSync(cookiePath));
}

// MUNGE COOKIE DOMAIN FOR CHROMY USAGE
cookies = cookies.map(cookie => {
cookie.url = 'https://' + cookie.domain;
delete cookie.domain;
return cookie;
});

// SET COOKIES VIA CHROMY
chromy.setCookie(cookies);
console.log('Cookie state restored with:', JSON.stringify(cookies, null, 2));
};
6 changes: 6 additions & 0 deletions backstop_data/engine_scripts/chromy/onBefore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function (chromy, scenario, vp) {
require('./loadCookies')(chromy, scenario);

// IGNORE ANY CERT WARNINGS
chromy.ignoreCertificateErrors();
};
5 changes: 5 additions & 0 deletions backstop_data/engine_scripts/chromy/onReady.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function (chromy, scenario, vp) {
console.log('SCENARIO > ' + scenario.label);
require('./clickAndHoverHelper')(chromy, scenario);
// add more ready handlers here...
};
14 changes: 14 additions & 0 deletions backstop_data/engine_scripts/cookies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"domain": ".www.yourdomain.com",
"path": "/",
"name": "yourCookieName",
"value": "yourCookieValue",
"expirationDate": 1798790400,
"hostOnly": false,
"httpOnly": false,
"secure": false,
"session": false,
"sameSite": "no_restriction"
}
]
4 changes: 4 additions & 0 deletions backstop_data/engine_scripts/onBefore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = function (engine, scenario, vp) {
// This script runs before your app loads. Edit here to log-in, load cookies or set other states required for your test.
console.log('onBefore.js has run for ' + vp.label + '.');
};
6 changes: 6 additions & 0 deletions backstop_data/engine_scripts/onReady.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function (engine, scenario, vp) {
engine.evaluate(function () {
// Your web-app is now loaded. Edit here to simulate user interacions or other state changes in the browser window context.
});
console.log('onReady.js has run for: ', vp.label);
};
49 changes: 28 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
],
"devDependencies": {
"@semantic-release/condition-codeship": "^1.1.0",
"@semantic-release/release-notes-generator": "^2.0.0",
"@semantic-release/release-notes-generator": "^3.0.1",
"babel-cli": "^6.18.0",
"babel-core": "^6.18.2",
"babel-eslint": "^7.1.1",
"babel-jest": "^19.0.0",
"babel-loader": "^6.2.7",
"babel-eslint": "^7.2.3",
"babel-jest": "^21.0.0",
"babel-loader": "^7.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-transform-es3-member-expression-literals": "^6.8.0",
Expand All @@ -23,39 +23,45 @@
"babel-preset-stage-1": "^6.16.0",
"babel-register": "^6.18.0",
"babel-standalone": "^6.18.2",
"backstopjs": "^3.0.24",
"bluebird": "^3.5.0",
"coveralls": "^2.11.15",
"cross-spawn-promise": "^0.10.1",
"execa": "^0.8.0",
"faker": "^4.1.0",
"file-loader": "^0.10.1",
"folder-hash": "^1.1.1",
"fs-extra": "^2.0.0",
"gh-pages": "^1.0.0",
"glob": "^7.1.1",
"gulp": "^3.9.1",
"html-loader": "^0.4.4",
"html-loader": "^0.5.1",
"httpster": "^1.0.3",
"husky": "^0.14.3",
"javascript-natural-sort": "^0.7.1",
"jest": "^19.0.2",
"npm-run-all": "^4.0.2",
"jest": "^21.0.1",
"npm-run-all": "^4.1.1",
"nsp": "^2.6.2",
"perish": "^1.0.1",
"pify": "^2.3.0",
"postcss-cli": "^3.0.0-beta",
"postcss-cssnext": "^2.8.0",
"postcss-import": "^9.1.0",
"postcss-loader": "^1.1.0",
"postcss-neat": "^2.5.2",
"pify": "^3.0.0",
"postcss-cli": "^4.1.0",
"postcss-cssnext": "^3.0.2",
"postcss-import": "^10.0.0",
"postcss-loader": "^2.0.6",
"postcss-neat": "^2.5.3",
"react-remarkable": "^1.1.1",
"react-styleguidist": "^5.2.1",
"react-test-renderer": "^15.5.4",
"ripcord": "^3.1.0",
"rucksack-css": "^0.9.1",
"rucksack-css": "^1.0.2",
"semantic-release": "^6.3.2",
"semantic-release-cli": "^3.0.2",
"semantic-ui": "^2.2.6",
"standard": "^9.0.0",
"style-loader": "^0.13.2",
"standard": "^10.0.3",
"style-loader": "^0.18.2",
"toiletdb": "^1.4.0",
"url": "^0.11.0",
"webpack": "^1.13.1"
"webpack": "^3.5.6"
},
"dependencies": {
"d3": "^4.7.1",
Expand All @@ -69,9 +75,10 @@
},
"scripts": {
"build": "node scripts/build",
"secure": "nsp check",
"lint": "standard",
"test": "echo 'TBD'",
"test": "node scripts/test",
"test:report": "backstop openReport",
"secure": "nsp check",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"styleguide": "styleguidist server",
"styleguide:build": "styleguidist build",
Expand All @@ -81,12 +88,12 @@
"check-vulnerablities": "nsp check"
},
"standard": {
"parser": "babel-eslint",
"ignore": [
"lib",
"semantic",
"styleguide"
],
"parser": "babel-eslint"
]
},
"jest": {
"collectCoverage": true,
Expand Down
5 changes: 2 additions & 3 deletions scripts/postcss.config.js → postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module.exports = {
plugins: [
require('postcss-import'),
require('postcss-cssnext'), // permit future css rules
require('postcss-neat'), // @TODO investigate purging? may be unused
require('rucksack-css'), // css function superset (e.g. less like syntax)
require('autoprefixer')({ browsers: ['last 2 version'] })
require('postcss-cssnext'), // permit future css rules
require('postcss-neat') // @TODO investigate purging? may be unused
]
}
6 changes: 2 additions & 4 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ require('perish')
const builder = require('./builder')
const task = process.argv[2]

;(() => {
if (task) return builder[task]()
builder.build()
})()
if (task) builder[task]()
else builder.build()
Loading

0 comments on commit ca5dfd8

Please sign in to comment.