Skip to content

Commit

Permalink
fix: added pressure for click in NA (#7876)
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.
-->
[closes #7867]

## Purpose
Fix issue `Some clicks don't work in native automation mode`

## Approach
1. Find out the reason why click doesn't work correctly in NA
2. Add a test
3. Fix issue

## References
#7867

## Pre-Merge TODO
- [X] Write tests for your proposed changes
- [x] Make sure that existing tests do not fail
  • Loading branch information
Aleksey28 authored Jul 13, 2023
1 parent faed539 commit fd0def3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/native-automation/client/event-descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const messageSandbox = eventSandbox.message;

const MOUSE_EVENT_OPTIONS = {
clickCount: 1,
force: 0.5,
};

const CALCULATE_TOP_LEFT_POINT_REQUEST_CMD = 'native-automation|calculate-top-left-point|request';
Expand Down
6 changes: 6 additions & 0 deletions test/functional/fixtures/api/es-next/click/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@

status.textContent = 'Clicked!';
});

document.querySelector('#statusBtn').addEventListener('pointerdown', function (e) {
window.pointerdownPressure = e.pressure;
});

window.pointerdownPressure = 0;
</script>
<!--Click shifted element-->
<div id="shifted-element" style="background: green; width: 100px; height: 100px; transform: translateX(-60px);"></div>
Expand Down
7 changes: 6 additions & 1 deletion test/functional/fixtures/api/es-next/click/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const expect = require('chai').expect;
const { onlyInNativeAutomation } = require('../../../../utils/skip-in');
const expect = require('chai').expect;

//GH-1674
const TEST_DURATION_BOUND = 10000;
Expand Down Expand Up @@ -234,4 +235,8 @@ describe('[API] t.click()', function () {
});
});
});

onlyInNativeAutomation('Should set pressure in Native Automation', () => {
return runTests('./testcafe-fixtures/click-test.js', 'Check click pressure', { only: 'chrome' });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,9 @@ test('Click on an element with overlapped center', async t => {
test('Click overlapped element', async t => {
await t.click('.child1');
}).page('http://localhost:3000/fixtures/api/es-next/click/pages/overlapped.html');

test('Check click pressure', async t => {
await t.click('#statusBtn');

expect(await t.eval(() => window.pointerdownPressure)).gt(0);
});

0 comments on commit fd0def3

Please sign in to comment.