Skip to content

Commit

Permalink
refactor: removed IE leftovers fromtest\functional\fixtures\api\es-ne…
Browse files Browse the repository at this point in the history
…xt (#7967)

<!--
Thank you for your contribution.

Before making a PR, please read our contributing guidelines at

https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution

We recommend creating a *draft* PR, so that you can mark it as 'ready
for review' when you are done.
-->

## Purpose
_Describe the problem you want to address or the feature you want to
implement._

## Approach
_Describe how your changes address the issue or implement the desired
functionality in as much detail as possible._

## References
_Provide a link to the existing issue(s), if any._

## Pre-Merge TODO
- [ ] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail
  • Loading branch information
Aleksey28 authored Aug 30, 2023
1 parent d1c9bce commit 66dabe4
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { checkUserAgent } = require('../../../../assertion-helper');

describe('[API] ClientFunction', function () {
it('Should be correctly dispatched to test run', function () {
const browsers = 'chrome,firefox,ie';
const browsers = 'chrome,firefox';

return runTests('./testcafe-fixtures/client-fn-test.js', 'Dispatch', { shouldFail: true, only: browsers })
.catch(function (errs) {
Expand Down
18 changes: 9 additions & 9 deletions test/functional/fixtures/api/es-next/dispatch-event/test.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
describe('[API] t.dispatchEvent()', function () {
it('mouse', function () {
return runTests('testcafe-fixtures/index.js', 'mouse', { skip: ['ie', 'iphone'] });
return runTests('testcafe-fixtures/index.js', 'mouse', { skip: ['iphone'] });
});

it('keyboard', function () {
return runTests('testcafe-fixtures/index.js', 'keyboard', { skip: ['ie', 'iphone'] });
return runTests('testcafe-fixtures/index.js', 'keyboard', { skip: ['iphone'] });
});

it('input', function () {
return runTests('testcafe-fixtures/index.js', 'input', { skip: ['ie', 'safari'] });
return runTests('testcafe-fixtures/index.js', 'input', { skip: ['safari'] });
});

it('focus', function () {
return runTests('testcafe-fixtures/index.js', 'focus', { skip: 'ie' });
return runTests('testcafe-fixtures/index.js', 'focus');
});

it('pointer', function () {
return runTests('testcafe-fixtures/index.js', 'pointer', { skip: ['ie', 'iphone', 'ipad', 'safari'] });
return runTests('testcafe-fixtures/index.js', 'pointer', { skip: ['iphone', 'ipad', 'safari'] });
});

it('defaults', function () {
return runTests('testcafe-fixtures/index.js', 'defaults', { skip: ['ie', 'iphone'] });
return runTests('testcafe-fixtures/index.js', 'defaults', { skip: ['iphone'] });
});

it('predefined ctor', function () {
return runTests('testcafe-fixtures/index.js', 'predefined ctor', { skip: 'ie' });
return runTests('testcafe-fixtures/index.js', 'predefined ctor');
});

it('custom event', function () {
return runTests('testcafe-fixtures/index.js', 'custom event', { skip: 'ie' });
return runTests('testcafe-fixtures/index.js', 'custom event');
});

it('simple drag', function () {
return runTests('testcafe-fixtures/index.js', 'simple drag', { skip: 'ie' });
return runTests('testcafe-fixtures/index.js', 'simple drag');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/functional/fixtures/api/es-next/eval/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { checkUserAgent } = require('../../../../assertion-helper');

describe('[API] t.eval', function () {
it('Should execute an anonymous client function', function () {
const browsers = 'chrome,firefox,ie';
const browsers = 'chrome,firefox';

return runTests('./testcafe-fixtures/eval-test.js', 'Get UA', { shouldFail: true, only: browsers })
.catch(function (errs) {
Expand Down
2 changes: 1 addition & 1 deletion test/functional/fixtures/api/es-next/hooks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('[API] test.before/test.after hooks', () => {

describe('[API] t.ctx', () => {
it('Should pass context object to tests and hooks', () => {
return runTests('./testcafe-fixtures/run-all.js', 't.ctx', { shouldFail: true, only: 'chrome,ie,firefox' })
return runTests('./testcafe-fixtures/run-all.js', 't.ctx', { shouldFail: true, only: 'chrome,firefox' })
.catch(errs => {
const testedBrowsers = config.currentEnvironment.browsers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,7 @@ <h2>Same-domain iframes</h2>
<iframe id="iframe" src="iframe.html" width="500px" height="300px"></iframe>
<iframe id="invisible-iframe" style="visibility: hidden;"></iframe>
<iframe name="long" id="slowly-loading-iframe" src="iframe.html?delay=1000" height="300px"></iframe>

<script>
document.addEventListener('DOMContentLoaded', function () {
// NOTE: if we add a slowly loading iframe via markup, IE9 sometimes raises the DOMContentLoaded
// event after this iframe is completely loaded (in other browsers, this event never waits for
// an iframe to load). To avoid this collision, we create the iframe on the DOMContentLoaded event.
// It helps us get rid of an unstable functional test in IE9.
const tooSlowlyLoadingIframe = document.createElement('iframe');

tooSlowlyLoadingIframe.id = 'too-slowly-loading-iframe';
tooSlowlyLoadingIframe.src = "iframe.html?delay=10000";
tooSlowlyLoadingIframe.style.width = "500px";
tooSlowlyLoadingIframe.style.height = "300px";

document.body.insertBefore(tooSlowlyLoadingIframe, document.getElementById('slowly-loading-iframe'));
});
</script>
<iframe id="too-slowly-loading-iframe" src="iframe.html?delay=10000"></iframe>

<script>
document.getElementById('btn').addEventListener('click', function () {
Expand Down
6 changes: 3 additions & 3 deletions test/functional/fixtures/api/es-next/iframe-switching/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ describe('[API] t.switchToIframe(), t.switchToMainWindow()', function () {
it('Should switch context between a shadow iframe and the main window', function () {
return runTests('./testcafe-fixtures/iframe-switching-test.js', 'Click on an element in a shadow iframe and return to the main window', {
...DEFAULT_RUN_OPTIONS,
skip: ['ie', 'edge'],
skip: ['edge'],
});
});

it('Should switch context between a nested shadow iframe and the main window', function () {
return runTests('./testcafe-fixtures/iframe-switching-test.js', 'Click on element in a nested shadow iframe', {
...DEFAULT_RUN_OPTIONS,
skip: ['ie', 'edge'],
skip: ['edge'],
});
});

Expand Down Expand Up @@ -72,7 +72,7 @@ describe('[API] t.switchToIframe(), t.switchToMainWindow()', function () {
});

it('Should work in an iframe with the srcdoc attribute', function () {
return runTests('./testcafe-fixtures/iframe-switching-test.js', 'Click in an iframe with the srcdoc attribute', { skip: 'ie', ...DEFAULT_RUN_OPTIONS });
return runTests('./testcafe-fixtures/iframe-switching-test.js', 'Click in an iframe with the srcdoc attribute', { ...DEFAULT_RUN_OPTIONS });
});

it('Correct execution order of "message" events in cross-domain iframe', function () {
Expand Down
4 changes: 2 additions & 2 deletions test/functional/fixtures/api/es-next/roles/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const isRemoteTask = config.currentEnvironmentName === config.testingEnvironment
(isRemoteTask ? describe.skip : describe)('[API] t.useRole()', function () {
// TODO: stabilize the test in Firefox
(config.hasBrowser('firefox') ? it.skip : it)('Should initialize and switch roles', function () {
return runTests('./testcafe-fixtures/use-role-test.js', null, { only: 'chrome,ie,firefox' });
return runTests('./testcafe-fixtures/use-role-test.js', null, { only: 'chrome,firefox' });
});

it('Should switch to Role.anonymous()', function () {
Expand Down Expand Up @@ -55,7 +55,7 @@ const isRemoteTask = config.currentEnvironmentName === config.testingEnvironment
it('Should fail all tests that use role with the initializer error', function () {
return runTests('./testcafe-fixtures/init-error-test.js', null, {
shouldFail: true,
only: 'chrome,ie,firefox',
only: 'chrome,firefox',
})
.catch(function (errs) {
const testedBrowsers = config.currentEnvironment.browsers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,34 +99,22 @@ test('End element selector returns text node', async t => {
await t.selectEditableContent('#p1', getNode);
});

const isIEFunction = ClientFunction(() => {
const userAgent = window.navigator.userAgent;
const appName = window.navigator.appName;
const isIE11Re = new RegExp('Trident/.*rv:([0-9]{1,}[.0-9]{0,})');
const isMSEdge = /Edge/.test(navigator.userAgent);

return appName === 'Microsoft Internet Explorer' ||
appName === 'Netscape' && isIE11Re.exec(userAgent) !== null ||
isMSEdge;
});

test('simple inverse selection in contenteditable', async t => {
await t.selectText(Selector('#div'), 28, 2);

const checkEditableContentInverseSelection = ClientFunction(() => {
const selection = window.getSelection();
const div = document.getElementById('div');
const isIE = isIEFunction();
const startNode = isIE ? div.childNodes[0] : div.childNodes[3].childNodes[0];
const startOffset = isIE ? 2 : 3;
const endNode = isIE ? div.childNodes[3].childNodes[0] : div.childNodes[0];
const endOffset = isIE ? 3 : 2;
const startNode = div.childNodes[3].childNodes[0];
const startOffset = 3;
const endNode = div.childNodes[0];
const endOffset = 2;

return selection.anchorNode === startNode &&
selection.anchorOffset === startOffset &&
selection.focusNode === endNode &&
selection.focusOffset === endOffset;
}, { dependencies: { isIEFunction: isIEFunction } });
});

await t.expect(checkEditableContentInverseSelection()).ok();
});
Expand All @@ -137,17 +125,16 @@ test('difficult inverse selection in contenteditable', async t => {
const checkEditableContentInverseSelection = ClientFunction(() => {
const selection = window.getSelection();
const div = document.getElementById('bigDiv');
const isIE = isIEFunction();
const startNode = isIE ? div.childNodes[0] : div.childNodes[10];
const startOffset = isIE ? 4 : 1;
const endNode = isIE ? div.childNodes[10] : div.childNodes[0];
const endOffset = isIE ? 1 : 4;
const startNode = div.childNodes[10];
const startOffset = 1;
const endNode = div.childNodes[0];
const endOffset = 4;

return selection.anchorNode === startNode &&
selection.anchorOffset === startOffset &&
selection.focusNode === endNode &&
selection.focusOffset === endOffset;
}, { dependencies: { isIEFunction: isIEFunction } });
});

await t.expect(checkEditableContentInverseSelection()).ok();
});
10 changes: 5 additions & 5 deletions test/functional/fixtures/api/es-next/selector/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ describe('[API] Selector', function () {
});

it('Selector "shadowRoot" method - children are found', function () {
return runTests('./testcafe-fixtures/selector-test.js', 'Selector "shadowRoot" method - children are found', Object.assign({ skip: ['ie', 'edge'] }, DEFAULT_RUN_OPTIONS));
return runTests('./testcafe-fixtures/selector-test.js', 'Selector "shadowRoot" method - children are found', Object.assign({ skip: ['edge'] }, DEFAULT_RUN_OPTIONS));
});

it('Selector "shadowRoot" method - shadow root not found', function () {
return runTests('./testcafe-fixtures/selector-test.js', 'Selector "shadowRoot" method - shadow root not found', Object.assign({ shouldFail: true, skip: ['ie', 'edge'] }, DEFAULT_RUN_OPTIONS))
return runTests('./testcafe-fixtures/selector-test.js', 'Selector "shadowRoot" method - shadow root not found', Object.assign({ shouldFail: true, skip: ['edge'] }, DEFAULT_RUN_OPTIONS))
.catch(function (errs) {
expect(errs[0]).contains('The specified selector does not match any element in the DOM tree.');
expect(errs[0]).contains('| Selector(\'p\')');
Expand All @@ -136,14 +136,14 @@ describe('[API] Selector', function () {
});

it('Selector "shadowRoot" method - content property', function () {
return runTests('./testcafe-fixtures/selector-test.js', 'Selector "shadowRoot" method - content property', Object.assign({ skip: ['ie', 'edge'] }, DEFAULT_RUN_OPTIONS));
return runTests('./testcafe-fixtures/selector-test.js', 'Selector "shadowRoot" method - content property', Object.assign({ skip: ['edge'] }, DEFAULT_RUN_OPTIONS));
});

it('Cannot use "shadowRoot" as a target', function () {
return runTests('./testcafe-fixtures/selector-test.js', 'Cannot use "shadowRoot" as a target', Object.assign({ shouldFail: true, skip: ['ie', 'edge'] }, DEFAULT_RUN_OPTIONS))
return runTests('./testcafe-fixtures/selector-test.js', 'Cannot use "shadowRoot" as a target', Object.assign({ shouldFail: true, skip: ['edge'] }, DEFAULT_RUN_OPTIONS))
.catch(function (errs) {
expect(errs[0]).contains('The specified selector is expected to match a DOM element, but it matches a document fragment node.');
expect(errs[0]).contains('> 1121 | await t.click(shadowRoot);');
expect(/> \d* |\s{4}await t.click(shadowRoot);/.test(errs[0])).to.be.ok;
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ fixture `Selector`

const getElementById = Selector(id => document.getElementById(id));

const isIEFunction = ClientFunction(() => {
const userAgent = window.navigator.userAgent;
const appName = window.navigator.appName;
const isIE11Re = new RegExp('Trident/.*rv:([0-9]{1,}[.0-9]{0,})');

return appName === 'Microsoft Internet Explorer' ||
appName === 'Netscape' && isIE11Re.exec(userAgent) !== null;
});

test('HTMLElement snapshot basic properties', async t => {
const el = await getElementById('htmlElement');

Expand Down Expand Up @@ -167,15 +158,11 @@ test('Input-specific element snapshot properties', async t => {
});

test('`innerText` element snapshot property', async t => {
const isIE = await isIEFunction();
let innerText = await getElementById('htmlElementWithInnerText').innerText;

innerText = innerText.trim().replace(/\r\n/, '\n');

// NOTE: we have to use regexp because the innerText field
// returns a little bit different values in IE9 and other browsers
const expectedTextRe = isIE ? /^Hey\nyo test {2}42 test {2}'hey hey'; \.someClass \{ \}/ :
/^Hey\nyo test {1,2}test/;
const expectedTextRe = /^Hey\nyo test {1,2}test/;

await t.expect(expectedTextRe.test(innerText.trim())).ok();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,9 @@ test
const expectedWidth = width - scrollbarSize;
const expectedHeight = height - scrollbarSize;

// NOTE: IE clips screenshots not accurately
const accuracy = parseUserAgent(ua).name === 'Internet Explorer' ? 1 : 0;

await t.expect(scrollbarSize).gt(0);
await t.expect(Math.abs(png.width - expectedWidth)).lte(accuracy);
await t.expect(Math.abs(png.height - expectedHeight)).lte(accuracy);
await t.expect(png.width).eql(expectedWidth);
await t.expect(png.height).eql(expectedHeight);
});

test('Should add default extension', async t => {
Expand Down

0 comments on commit 66dabe4

Please sign in to comment.