Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKamaev committed Jun 25, 2018
1 parent be2206f commit f13436a
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
74 changes: 74 additions & 0 deletions test/functional/fixtures/regression/gh-2056/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>

#el1, #el2, #el3 {
position: absolute;
background-color: black;
display: inline-block;
height: 50px;
width: 50px;
top: 0;
left: 0;
}
#el2 {
top: 200px;
left: 200px;
}

#el3 {
top: 0;
left: 200px;
}
</style>
<script>
function log (text) {
document.getElementById('result').innerHTML += text;
}

function onMove (e) {
window.removeEventListener('mousemove', onMove);

log('onMove:' + e.button + e.buttons + e.which);
}

function onMoveWithLeftButtonPressed (e) {
window.removeEventListener('mousemove', onMoveWithLeftButtonPressed);

log('onMoveWithLeftButtonPressed:' + e.button + e.buttons + e.which);
}

function listenMouseMove(e) {
window.addEventListener('mousemove', onMove);
}

function listenMouseMoveWithLeftButtonPressed(e) {
window.addEventListener('mousemove', onMoveWithLeftButtonPressed);
}
</script>
</head>
<body>
<div id="el1"></div>
<div id="el2"></div>
<div id="el3"></div>
<br/>
<br/>
<br/>
<br/>
<br/>
<div id="result"></div>

<script type="text/javascript">
var el1 = document.getElementById('el1');
var el2 = document.getElementById('el2');
var el3 = document.getElementById('el3');
var el4 = document.getElementById('el4');

el1.addEventListener('click', listenMouseMove);
el2.addEventListener('click', listenMouseMoveWithLeftButtonPressed);
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions test/functional/fixtures/regression/gh-2056/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('[Regression](GH-2056)', function () {
it('Move actions should provide correct button, buttons, which properties', function () {
return runTests('testcafe-fixtures/index.js');
}, { skip: ['iphone', 'ipad', 'android'] });
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Selector, ClientFunction } from 'testcafe';
import userAgent from 'useragent';

fixture `GH-2056`
.page `http://localhost:3000/fixtures/regression/gh-2056/pages/index.html`;

const el1 = Selector('#el1');
const el2 = Selector('#el2');
const el3 = Selector('#el3');
const result = Selector('#result');

const getUserAgent = ClientFunction(() => navigator.userAgent.toString());

test('Move actions should provide correct button, buttons, which properties', async t => {
var userAgentStr = await getUserAgent();
var isChrome = userAgent.is(userAgentStr).chrome;
var expected = isChrome ? 'onMove:000onMoveWithLeftButtonPressed:011' : 'onMove:001onMoveWithLeftButtonPressed:011';

await t
.setTestSpeed(0.1)
.click(el1)
.hover(el3)
.click(el2)
.dragToElement(el2, el3)
.expect(result.innerText).eql(expected);
});

0 comments on commit f13436a

Please sign in to comment.