This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build): add missing test scripts
- Loading branch information
Showing
12 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
backstop_data/engine_scripts/casper/clickAndHoverHelper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
18
backstop_data/engine_scripts/casper/waitForHelperHelper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
backstop_data/engine_scripts/chromy/clickAndHoverHelper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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... | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + '.'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |