Skip to content

Commit

Permalink
Click on multiline elements (#8183)
Browse files Browse the repository at this point in the history
<!--
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
Testcafe did not click properly on multiline elements.

## Approach
In testcafe-hammerhead replaced getBoundingClientRect with
getClientRects.

Fix Edge workflow tests
#8189

## References
#8179
#8148

Hammerhead PR:
DevExpress/testcafe-hammerhead#3004


## Pre-Merge TODO
- [x] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail

---------

Co-authored-by: Bayheck <adil.rakhaliyev@devexpress.com>
  • Loading branch information
Bayheck and Bayheck committed Jun 3, 2024
1 parent 1b17abd commit 430918d
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 14 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down Expand Up @@ -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');
Expand Down
10 changes: 6 additions & 4 deletions test/functional/fixtures/regression/gh-2011/test.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/fixtures/regression/gh-2568/test.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions test/functional/fixtures/regression/gh-8179/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>gh-8179</title>
<style>
.main {
width: 300px;
}
</style>
</head>
<body>
<div class="main">
This here link will take you to the
<a href="success.html">success page</a>.
</div>
</body>
</html>
10 changes: 10 additions & 0 deletions test/functional/fixtures/regression/gh-8179/pages/success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Title</title>
</head>
<body>
<h1>success</h1>
</body>
</html>
5 changes: 5 additions & 0 deletions test/functional/fixtures/regression/gh-8179/test.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
Original file line number Diff line number Diff line change
@@ -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');
});

0 comments on commit 430918d

Please sign in to comment.