From 430918d82d1cf511c9807467d2f1721c51063e40 Mon Sep 17 00:00:00 2001 From: Adil Rakhaliyev <67043367+Bayheck@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:40:06 +0500 Subject: [PATCH] Click on multiline elements (#8183) ## Purpose Testcafe did not click properly on multiline elements. ## Approach In testcafe-hammerhead replaced getBoundingClientRect with getClientRects. Fix Edge workflow tests https://github.com/DevExpress/testcafe/pull/8189 ## References https://github.com/DevExpress/testcafe/issues/8179 https://github.com/DevExpress/testcafe/issues/8148 Hammerhead PR: https://github.com/DevExpress/testcafe-hammerhead/pull/3004 ## Pre-Merge TODO - [x] Write tests for your proposed changes - [ ] Make sure that existing tests do not fail --------- Co-authored-by: Bayheck --- package-lock.json | 14 +++++++------- package.json | 2 +- .../browser-provider/job-reporting/test.js | 3 ++- .../fixtures/regression/gh-2011/test.js | 10 ++++++---- .../fixtures/regression/gh-2568/test.js | 2 +- .../regression/gh-8179/pages/index.html | 18 ++++++++++++++++++ .../regression/gh-8179/pages/success.html | 10 ++++++++++ .../fixtures/regression/gh-8179/test.js | 5 +++++ .../gh-8179/testcafe-fixtures/index.js | 10 ++++++++++ 9 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 test/functional/fixtures/regression/gh-8179/pages/index.html create mode 100644 test/functional/fixtures/regression/gh-8179/pages/success.html create mode 100644 test/functional/fixtures/regression/gh-8179/test.js create mode 100644 test/functional/fixtures/regression/gh-8179/testcafe-fixtures/index.js diff --git a/package-lock.json b/package-lock.json index ceab009846b..e4619956fe7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -90,7 +90,7 @@ "source-map-support": "^0.5.16", "strip-bom": "^2.0.0", "testcafe-browser-tools": "2.0.26", - "testcafe-hammerhead": "31.7.1", + "testcafe-hammerhead": "31.7.2", "testcafe-legacy-api": "5.1.8", "testcafe-reporter-json": "^2.1.0", "testcafe-reporter-list": "^2.2.0", @@ -15707,9 +15707,9 @@ } }, "node_modules/testcafe-hammerhead": { - "version": "31.7.1", - "resolved": "https://registry.npmjs.org/testcafe-hammerhead/-/testcafe-hammerhead-31.7.1.tgz", - "integrity": "sha512-H162ruxCc0wIAkoVky7aQyEntiA6Np8OcWzOx0/2cSPY6BARFdFNd3spu2TB2j3qcpFIZ233IpEx+2sY+VFbjg==", + "version": "31.7.2", + "resolved": "https://registry.npmjs.org/testcafe-hammerhead/-/testcafe-hammerhead-31.7.2.tgz", + "integrity": "sha512-wjZ3Y4fXnew6WaoMhD7jTe/zrzSYJMLZulX+/pXS6xed9meUx7zzCSc5epPJEW8Xy3Zo09n7w+m7+2SDej0/Iw==", "dependencies": { "@adobe/css-tools": "^4.3.0-rc.1", "@electron/asar": "^3.2.3", @@ -29057,9 +29057,9 @@ } }, "testcafe-hammerhead": { - "version": "31.7.1", - "resolved": "https://registry.npmjs.org/testcafe-hammerhead/-/testcafe-hammerhead-31.7.1.tgz", - "integrity": "sha512-H162ruxCc0wIAkoVky7aQyEntiA6Np8OcWzOx0/2cSPY6BARFdFNd3spu2TB2j3qcpFIZ233IpEx+2sY+VFbjg==", + "version": "31.7.2", + "resolved": "https://registry.npmjs.org/testcafe-hammerhead/-/testcafe-hammerhead-31.7.2.tgz", + "integrity": "sha512-wjZ3Y4fXnew6WaoMhD7jTe/zrzSYJMLZulX+/pXS6xed9meUx7zzCSc5epPJEW8Xy3Zo09n7w+m7+2SDej0/Iw==", "requires": { "@adobe/css-tools": "^4.3.0-rc.1", "@electron/asar": "^3.2.3", diff --git a/package.json b/package.json index eb0c543e848..8d983508b73 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "source-map-support": "^0.5.16", "strip-bom": "^2.0.0", "testcafe-browser-tools": "2.0.26", - "testcafe-hammerhead": "31.7.1", + "testcafe-hammerhead": "31.7.2", "testcafe-legacy-api": "5.1.8", "testcafe-reporter-json": "^2.1.0", "testcafe-reporter-list": "^2.2.0", diff --git a/test/functional/fixtures/browser-provider/job-reporting/test.js b/test/functional/fixtures/browser-provider/job-reporting/test.js index 15352337ec6..3f50b01313a 100644 --- a/test/functional/fixtures/browser-provider/job-reporting/test.js +++ b/test/functional/fixtures/browser-provider/job-reporting/test.js @@ -13,6 +13,7 @@ if (config.useLocalBrowsers) { const BROWSER_OPENING_DELAY = 4000; let mockProvider = null; + const needSkip = config.hasBrowser('edge'); const mockProviderPlugin = Object.assign({}, chromeBrowserProvider, { state: {}, @@ -110,7 +111,7 @@ if (config.useLocalBrowsers) { }); }); - it('Should report job error to the providers', () => { + (needSkip ? it.skip : it)('Should report job error to the providers', () => { return run(['chrome --failed-1', 'chrome --id-2'], './testcafe-fixtures/long-test.js') .then(() => { throw new Error('Promise rejection expected'); diff --git a/test/functional/fixtures/regression/gh-2011/test.js b/test/functional/fixtures/regression/gh-2011/test.js index a73a9cae0e8..46c043414f4 100644 --- a/test/functional/fixtures/regression/gh-2011/test.js +++ b/test/functional/fixtures/regression/gh-2011/test.js @@ -1,11 +1,13 @@ const path = require('path'); const createTestCafe = require('../../../../../lib'); +const config = require('../../../config'); const { createReporter } = require('../../../utils/reporter'); const { expect } = require('chai'); -let testCafe = null; -let runner = null; -let errors = null; +let testCafe = null; +let runner = null; +let errors = null; +const needSkip = config.hasBrowser('edge'); const reporter = createReporter({ reportTestDone (_, testRunInfo) { @@ -35,7 +37,7 @@ const run = (pathToTest, concurrency) => { }); }; -describe('[Regression](GH-2011)', function () { +(needSkip ? describe.skip : describe)('[Regression](GH-2011)', function () { it('Should execute all fixture\'s test with disableConcurrency in one browser', function () { return run('./testcafe-fixtures/concurrency-mode-with-disable-concurrency-fixture-test.js', 3) diff --git a/test/functional/fixtures/regression/gh-2568/test.js b/test/functional/fixtures/regression/gh-2568/test.js index 7841f2195f8..2a204339b9c 100644 --- a/test/functional/fixtures/regression/gh-2568/test.js +++ b/test/functional/fixtures/regression/gh-2568/test.js @@ -1,7 +1,7 @@ const expect = require('chai').expect; function removeWhitespaces (str) { - return str.replace(/\s+|\n/g, ' ').trim(); + return str?.replace(/\s+|\n/g, ' ').trim() ?? ''; } function assertSelectorCallstack (actual, expected) { diff --git a/test/functional/fixtures/regression/gh-8179/pages/index.html b/test/functional/fixtures/regression/gh-8179/pages/index.html new file mode 100644 index 00000000000..8cfd96aad1d --- /dev/null +++ b/test/functional/fixtures/regression/gh-8179/pages/index.html @@ -0,0 +1,18 @@ + + + + + gh-8179 + + + +
+ This here link will take you to the + success page. +
+ + diff --git a/test/functional/fixtures/regression/gh-8179/pages/success.html b/test/functional/fixtures/regression/gh-8179/pages/success.html new file mode 100644 index 00000000000..417a8198a8b --- /dev/null +++ b/test/functional/fixtures/regression/gh-8179/pages/success.html @@ -0,0 +1,10 @@ + + + + + Title + + +

success

+ + diff --git a/test/functional/fixtures/regression/gh-8179/test.js b/test/functional/fixtures/regression/gh-8179/test.js new file mode 100644 index 00000000000..192a0cc79c8 --- /dev/null +++ b/test/functional/fixtures/regression/gh-8179/test.js @@ -0,0 +1,5 @@ +describe('[Regression](GH-8179)', function () { + it('Should click on a two-word link split over two lines', function () { + return runTests('testcafe-fixtures/index.js'); + }); +}); diff --git a/test/functional/fixtures/regression/gh-8179/testcafe-fixtures/index.js b/test/functional/fixtures/regression/gh-8179/testcafe-fixtures/index.js new file mode 100644 index 00000000000..25f0c603d30 --- /dev/null +++ b/test/functional/fixtures/regression/gh-8179/testcafe-fixtures/index.js @@ -0,0 +1,10 @@ +import { Selector } from 'testcafe'; + +fixture`GH-8179 - Should click on a two-word link split over two lines` + .page`http://localhost:3000/fixtures/regression/gh-8179/pages/index.html`; + +test('Click on a split link', async t => { + await t + .click('.main a') + .expect(Selector('h1').innerText).eql('success'); +});