forked from DevExpress/testcafe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Functional harness implemented (DevExpress#52)
- Loading branch information
Georgiy Abbasov
committed
Dec 25, 2015
1 parent
6345875
commit e29bc79
Showing
12 changed files
with
440 additions
and
0 deletions.
There are no files selected for viewing
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
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
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,21 @@ | ||
{ | ||
"rules": { | ||
"max-nested-callbacks": [2, 5] | ||
}, | ||
"env": { | ||
"browser": true, | ||
"jquery": true, | ||
"mocha": true | ||
}, | ||
"globals": { | ||
/* testcafe api */ | ||
"act": true, | ||
"inIFrame": true, | ||
"ok": true, | ||
"notOk": true, | ||
"eq": true, | ||
"notEq": true, | ||
/* functional harness */ | ||
"runTests": true | ||
} | ||
} |
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,43 @@ | ||
var os = require('os'); | ||
|
||
var isTravisEnvironment = !!process.env.TRAVIS; | ||
var hostname = isTravisEnvironment ? os.hostname() : '127.0.0.1'; | ||
|
||
module.exports = { | ||
isTravisTask: isTravisEnvironment, | ||
sauceLabs: { | ||
username: process.env.SAUCE_USERNAME, | ||
accessKey: process.env.SAUCE_ACCESS_KEY, | ||
build: process.env.TRAVIS_JOB_ID || '', | ||
tags: [process.env.TRAVIS_BRANCH || 'master'], | ||
name: 'testcafe functional tests' | ||
}, | ||
browsers: [ | ||
{ | ||
platform: 'Windows 10', | ||
browserName: 'internet explorer', | ||
version: '11.0', | ||
alias: 'ie' | ||
}, | ||
{ | ||
platform: 'Windows 10', | ||
browserName: 'firefox', | ||
alias: 'ff' | ||
}, | ||
{ | ||
platform: 'Windows 10', | ||
browserName: 'chrome', | ||
alias: 'chrome' | ||
} | ||
], | ||
testCafe: { | ||
hostname: hostname, | ||
port1: 2000, | ||
port2: 2001 | ||
}, | ||
site: { | ||
viewsPath: './test/functional/fixtures/', | ||
port1: 3000, | ||
port2: 3001 | ||
} | ||
}; |
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,27 @@ | ||
var expect = require('chai').expect; | ||
|
||
describe('api click test', function () { | ||
it('Should fail when the first argument is invisible', function () { | ||
return runTests('click.test.js', 'Should fail when the first argument is invisible', { shouldFail: true }) | ||
.catch(function (err) { | ||
var expectedError = [ | ||
'Error at step "1.Click on invisible element":', | ||
'', | ||
'act.click($input);', | ||
'', | ||
'A target element \<input id="input"\> of the click action is not visible.', | ||
'If this element should appear when you are hovering over another', | ||
'element, make sure that you properly recorded the hover action.' | ||
].join(' '); | ||
|
||
expect(err).eql(expectedError); | ||
}); | ||
}); | ||
|
||
it('Pointer events test (T191183) [ONLY:ie]', function () { | ||
return runTests('click.test.js', 'Pointer events test (T191183) [ONLY:ie]') | ||
.then(function (err) { | ||
expect(err).eql(''); | ||
}); | ||
}); | ||
}); |
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,50 @@ | ||
'@fixture click'; | ||
'@page ./runner/api/click/index.html'; | ||
|
||
|
||
var userAgent = window.navigator.userAgent.toLowerCase(); | ||
var isMSEdge = !!/edge\//.test(userAgent); | ||
|
||
var isIE11 = !!(navigator.appCodeName === 'Mozilla' && | ||
/trident\/7.0/.test(userAgent)); | ||
|
||
|
||
'@test'['Pointer events test (T191183) [ONLY:ie]'] = { | ||
'1.Bind pointer event handlers and call click': function () { | ||
var input = $('#input')[0]; | ||
var shared = this; | ||
|
||
shared.events = []; | ||
|
||
function pointerHandler (e) { | ||
shared.events.push(e.type.toLowerCase().replace('ms', '')); | ||
|
||
eq(e.pointerType, isIE11 || isMSEdge ? 'mouse' : 4); | ||
eq(e.button, 0); | ||
eq(e.buttons, 1); | ||
} | ||
|
||
if (isMSEdge) { | ||
input.onpointerdown = pointerHandler; | ||
input.onpointerup = pointerHandler; | ||
} | ||
else { | ||
input.onmspointerdown = pointerHandler; | ||
input.onmspointerup = pointerHandler; | ||
} | ||
|
||
act.click(input); | ||
}, | ||
|
||
'2.Check that handlers were called': function () { | ||
eq(this.events, ['pointerdown', 'pointerup']); | ||
} | ||
}; | ||
|
||
'@test'['Should fail when the first argument is invisible'] = { | ||
'1.Click on invisible element': function () { | ||
var $input = $('#input').css('visibility', 'hidden'); | ||
|
||
act.click($input); | ||
} | ||
}; |
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,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Click</title> | ||
</head> | ||
<body style="height: 1500px;"> | ||
<input type="button" id="input" style="position: absolute; margin-left: 100px; margin-top: 100px;"/> | ||
</body> | ||
</html> |
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,3 @@ | ||
{ | ||
"baseUrl": "http://localhost:3000" | ||
} |
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,56 @@ | ||
function isBrowserRelevant (test, browserAlias) { | ||
var matchesOnly = test.match(/\[ONLY\:([,\s\w]*)\]/); | ||
var matchesSkip = test.match(/\[SKIP\:([,\s\w]*)\]/); | ||
|
||
var only = true; | ||
var skip = false; | ||
|
||
if (matchesOnly !== null) | ||
only = matchesOnly[1].indexOf(browserAlias) > -1; | ||
|
||
if (matchesSkip !== null) | ||
skip = matchesSkip[1].indexOf(browserAlias) > -1; | ||
|
||
return only && !skip; | ||
} | ||
|
||
function filterErrors (errors, userAgents) { | ||
return errors.filter(function (error) { | ||
return userAgents.indexOf(error.split('\n')[0]) > -1; | ||
}); | ||
} | ||
|
||
function getTestError (testReport, browsersInfo) { | ||
var testError = ''; | ||
|
||
var actualUserAgents = browsersInfo | ||
.filter(function (browserInfo) { | ||
return isBrowserRelevant(testReport.name, browserInfo.settings.alias); | ||
}) | ||
.map(function (browserInfo) { | ||
return browserInfo.connection.userAgent; | ||
}); | ||
|
||
var actualBrowsersCount = actualUserAgents.length; | ||
var actualErrors = filterErrors(testReport.errs, actualUserAgents); | ||
var actualErrorsCount = actualErrors.length; | ||
|
||
if (actualErrorsCount) { | ||
//NOTE: if the test failed in different browsers with the same error we join it to one error | ||
if (actualErrorsCount !== actualBrowsersCount) | ||
testError = actualErrors.join('\n'); | ||
else { | ||
testError = actualErrors[0] | ||
.split('\n') | ||
.slice(1) | ||
.map(function (str) { | ||
return str.trim(); | ||
}) | ||
.join(' '); | ||
} | ||
} | ||
|
||
return testError; | ||
} | ||
|
||
module.exports = getTestError; |
Oops, something went wrong.