Skip to content

Commit

Permalink
Update Safari versions for client tests (#6806)
Browse files Browse the repository at this point in the history
* Update safari

* turn off one more drag test
  • Loading branch information
miherlosev authored Feb 4, 2022
1 parent 28ecb0b commit e43cdd7
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 110 deletions.
10 changes: 5 additions & 5 deletions gulp/constants/client-test-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ const CLIENT_TESTS_DESKTOP_BROWSERS = [
version: '11.0',
},
{
platform: 'macOS 10.13',
platform: 'macOS 12',
browserName: 'safari',
version: '11.1',
version: '15',
},
{
platform: 'OS X 10.11',
platform: 'macOS 12',
browserName: 'chrome',
},
{
platform: 'OS X 10.11',
platform: 'macOS 12',
browserName: 'firefox',
},
];
Expand All @@ -73,7 +73,7 @@ const CLIENT_TESTS_MOBILE_BROWSERS = [
// NOTE: https://github.com/DevExpress/testcafe/issues/471
// problem with extra scroll reproduced only on saucelabs
// virtual machines with ios device emulators
version: '10.3',
version: '14.5',
deviceName: 'iPhone 7 Plus Simulator',
},
];
Expand Down
6 changes: 4 additions & 2 deletions test/client/fixtures/automation/automations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const MouseOptions = testCafeAutomation.MouseOptions;
const parseKeySequence = testCafeCore.parseKeySequence;
const getOffsetOptions = testCafeAutomation.getOffsetOptions;

const isMobileSafari = browserUtils.isSafari && featureDetection.isTouchDevice;
const nextTestDelay = browserUtils.isIE ? 30 : 200;

$(document).ready(function () {
//consts
Expand Down Expand Up @@ -163,9 +165,9 @@ $(document).ready(function () {
};

const startNext = function (ms) {
if (browserUtils.isIE) {
if (browserUtils.isIE || isMobileSafari) {
removeTestElements();
window.setTimeout(start, ms || 30);
window.setTimeout(start, ms || nextTestDelay);
}
else
start();
Expand Down
95 changes: 53 additions & 42 deletions test/client/fixtures/automation/click-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const ClickOptions = testCafeAutomation.ClickOptions;

testCafeCore.preventRealEvents();

const isSafariGreaterThan15 = browserUtils.isSafari && parseFloat(browserUtils.fullVersion) >= '15.0';
const isMobileSafari = browserUtils.isSafari && featureDetection.isTouchDevice;
const nextTestDelay = browserUtils.isIE ? 30 : 200;
const TEST_RESULT_TIMEOUT = featureDetection.isTouchDevice ? 2500 : 500;

$(document).ready(function () {
let $el = null;

Expand Down Expand Up @@ -67,9 +72,9 @@ $(document).ready(function () {
};

const startNext = function () {
if (browserUtils.isIE) {
if (browserUtils.isIE || isMobileSafari) {
removeTestElements();
window.setTimeout(start, 30);
window.setTimeout(start, nextTestDelay);
}
else
start();
Expand Down Expand Up @@ -365,7 +370,7 @@ $(document).ready(function () {
equal(styleUtils.getScrollTop(document), windowY, 'scroll position should not change');
startNext();
});
});
}, TEST_RESULT_TIMEOUT);
});

asyncTest('scroll to already visible but obscured element', function () {
Expand Down Expand Up @@ -412,7 +417,7 @@ $(document).ready(function () {
ok(clicked, 'click was raised');
startNext();
});
}, 0);
}, TEST_RESULT_TIMEOUT);
});

asyncTest('click on element in scrolled container', function () {
Expand Down Expand Up @@ -656,7 +661,8 @@ $(document).ready(function () {
.then(function () {
const expectedPoint = { x: el.offsetLeft + 20, y: el.offsetTop + 20 };

deepEqual(eventPoint, expectedPoint, 'event point is correct');
equal(JSON.stringify(eventPoint), JSON.stringify(expectedPoint));

startNext();
});
});
Expand Down Expand Up @@ -689,7 +695,8 @@ $(document).ready(function () {
y: el.offsetTop + el.offsetHeight - 20,
};

deepEqual(eventPoint, expectedPoint, 'event point is correct');
equal(JSON.stringify(eventPoint), JSON.stringify(expectedPoint));

startNext();
});
});
Expand Down Expand Up @@ -938,53 +945,57 @@ $(document).ready(function () {
});
});

asyncTest('T224332 - TestCafe problem with click on links in popup menu (click on link with span inside without offset)', function () {
const $box = $('<div></div>').css('width', '128px').appendTo($('body'));
const $link = $('<a href="javascript:void(0);"></a>').appendTo($box);

$('<span>why do I have to break</span>').appendTo($link);

let clicked = false;
// NOTE: We turn off some tests due to an issue in Safari 15.
// Need to check these tests on the next Safari versions (15.3 and later).
if (!isSafariGreaterThan15) {
asyncTest('T224332 - TestCafe problem with click on links in popup menu (click on link with span inside without offset)', function () {
const $box = $('<div></div>').css('width', '128px').appendTo($('body'));
const $link = $('<a href="javascript:void(0);"></a>').appendTo($box);

$('input').remove();
$box.addClass(TEST_ELEMENT_CLASS);
$('<span>why do I have to break</span>').appendTo($link);

$link.click(function () {
clicked = true;
});
let clicked = false;

const click = new ClickAutomation($link[0], new ClickOptions());
$('input').remove();
$box.addClass(TEST_ELEMENT_CLASS);

click
.run()
.then(function () {
ok(clicked, 'check mouseup was called');
startNext();
$link.click(function () {
clicked = true;
});
});

asyncTest('T224332 - TestCafe problem with click on links in popup menu (click on span inside the link without offset)', function () {
const $box = $('<div></div>').css('width', '128px').appendTo($('body'));
const $link = $('<a href="javascript:void(0);"></a>').appendTo($box);
const $span = $('<span>why do I have to break</span>').appendTo($link);
const click = new ClickAutomation($link[0], new ClickOptions());

let clicked = false;
click
.run()
.then(function () {
ok(clicked, 'check mouseup was called');
startNext();
});
});

$box.addClass(TEST_ELEMENT_CLASS);
asyncTest('T224332 - TestCafe problem with click on links in popup menu (click on span inside the link without offset)', function () {
const $box = $('<div></div>').css('width', '128px').appendTo($('body'));
const $link = $('<a href="javascript:void(0);"></a>').appendTo($box);
const $span = $('<span>why do I have to break</span>').appendTo($link);

$link.click(function () {
clicked = true;
});
let clicked = false;

const click = new ClickAutomation($span[0], new ClickOptions());
$box.addClass(TEST_ELEMENT_CLASS);

click
.run()
.then(function () {
ok(clicked, 'check mouseup was called');
startNext();
$link.click(function () {
clicked = true;
});
});

const click = new ClickAutomation($span[0], new ClickOptions());

click
.run()
.then(function () {
ok(clicked, 'check mouseup was called');
startNext();
});
});
}

asyncTest('T191183 - pointer event properties are fixed', function () {
let mousedownRaised = false;
Expand Down Expand Up @@ -1123,7 +1134,7 @@ $(document).ready(function () {
notOk($img.data('clicked'), 'img element was not clicked');
startNext();
});
}, 1500);
}, TEST_RESULT_TIMEOUT);
});

module('touch devices test');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const hammerhead = window.getTestCafeModule('hammerhead');
const browserUtils = hammerhead.utils.browser;
const hammerhead = window.getTestCafeModule('hammerhead');
const browserUtils = hammerhead.utils.browser;
const featureDetection = hammerhead.utils.featureDetection;

const testCafeAutomation = window.getTestCafeModule('testCafeAutomation');
const ClickAutomation = testCafeAutomation.Click;
Expand All @@ -16,6 +17,8 @@ const domUtils = testCafeCore.domUtils;
const textSelection = testCafeCore.textSelection;
const parseKeySequence = testCafeCore.parseKeySequence;

const isMobileSafari = browserUtils.isSafari && featureDetection.isTouchDevice;
const nextTestDelay = isMobileSafari ? 200 : 30;

testCafeCore.preventRealEvents();

Expand All @@ -37,7 +40,7 @@ $(document).ready(function () {
let seventhElementInnerHTML = null;

const startNext = function () {
window.setTimeout(start, 30);
window.setTimeout(start, nextTestDelay);
};

const firstNotWhiteSpaceSymbolIndex = function (value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const hammerhead = window.getTestCafeModule('hammerhead');
const browserUtils = hammerhead.utils.browser;
const hammerhead = window.getTestCafeModule('hammerhead');
const browserUtils = hammerhead.utils.browser;
const featureDetection = hammerhead.utils.featureDetection;

const testCafeCore = window.getTestCafeModule('testCafeCore');
const textSelection = testCafeCore.textSelection;
Expand All @@ -16,6 +17,8 @@ const TypeOptions = testCafeAutomation.TypeOptions;

testCafeCore.preventRealEvents();

const isMobileSafari = browserUtils.isSafari && featureDetection.isTouchDevice;
const nextTestDelay = browserUtils.isIE ? 30 : 200;

$(document).ready(function () {
//consts
Expand All @@ -34,9 +37,9 @@ $(document).ready(function () {
$('body').css('height', 1500);

const startNext = function () {
if (browserUtils.isIE) {
if (browserUtils.isIE || isMobileSafari) {
removeTestElements();
window.setTimeout(start, 30);
window.setTimeout(start, nextTestDelay);
}
else
start();
Expand Down
Loading

0 comments on commit e43cdd7

Please sign in to comment.