Skip to content

Commit

Permalink
Fix press action shortcuts (closes DevExpress#1499) (DevExpress#1500)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderMoskovkin authored and AndreyBelym committed May 25, 2017
1 parent e961454 commit 03eee60
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/client/automation/playback/press/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ function moveTextAreaCursor (element, startPos, endPos, hasInverseSelection, new
}

function setElementValue (element, value, position) {
if (value.charAt(0) === '-' && value.charAt(1) === '.')
value = value.substring(1);

if (value.charAt(value.length - 1) === '.')
value = value.substring(0, value.length - 1);
if (domUtils.isInputElement(element) && element.type === 'number') {
if (value.charAt(0) === '-' && value.charAt(1) === '.')
value = value.substring(1);

if (value.charAt(value.length - 1) === '.')
value = value.substring(0, value.length - 1);
}

element.value = value;

Expand Down
20 changes: 16 additions & 4 deletions test/client/fixtures/automation/press-shortcuts-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var hammerhead = window.getTestCafeModule('hammerhead');
var browserUtils = hammerhead.utils.browser;

var testCafeCore = window.getTestCafeModule('testCafeCore');
var textSelection = testCafeCore.get('./utils/text-selection');
var domUtils = testCafeCore.get('./utils/dom');
var parseKeySequence = testCafeCore.get('./utils/parse-key-sequence');
var testCafeCore = window.getTestCafeModule('testCafeCore');
var textSelection = testCafeCore.get('./utils/text-selection');
var domUtils = testCafeCore.get('./utils/dom');
var parseKeySequence = testCafeCore.get('./utils/parse-key-sequence');

var testCafeAutomation = window.getTestCafeModule('testCafeAutomation');
var PressAutomation = testCafeAutomation.Press;
Expand Down Expand Up @@ -1003,4 +1003,16 @@ $(document).ready(function () {
start();
});
});

asyncTest("gh-1499 - Shortcuts work wrong if input's value ends with '.' or starts with '-.'", function () {
var input = createTextInput('a-.text.');

input.focus();
nativeSelect(input, 0, 0);

runPressAutomation('delete', function () {
checkShortcut(input, '-.text.', 0, 0);
start();
});
});
});

0 comments on commit 03eee60

Please sign in to comment.