diff --git a/composer.json b/composer.json index 8e2f8db800..204031b11e 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "require": { "php": ">=7.4 <8.4", "atk4/data": "dev-develop", - "nyholm/psr7": "^1.4", + "nyholm/psr7": "^1.6", "nyholm/psr7-server": "^1.0", "symfony/filesystem": "^4.4 || ^5.3 || ^6.0", "symfony/http-foundation": "^4.4 || ^5.3 || ^6.0" @@ -61,13 +61,13 @@ "require-release": { "php": ">=7.4 <8.4", "atk4/data": "~5.0.0", - "nyholm/psr7": "^1.4", + "nyholm/psr7": "^1.6", "nyholm/psr7-server": "^1.0", "symfony/filesystem": "^4.4 || ^5.3 || ^6.0", "symfony/http-foundation": "^4.4 || ^5.3 || ^6.0" }, "require-dev": { - "atk4/behat-mink-selenium2-driver": "^1.6.1", + "atk4/behat-mink-selenium2-driver": "^1.6.2", "behat/mink-extension": "^2.3.1", "ergebnis/composer-normalize": "^2.13", "friendsofphp/php-cs-fixer": "^3.0", diff --git a/src/Behat/Context.php b/src/Behat/Context.php index 1fd4349490..1b27c43e3b 100644 --- a/src/Behat/Context.php +++ b/src/Behat/Context.php @@ -663,7 +663,7 @@ public function compareInputValueToText(string $selector, string $text): void $inputValue = $this->findElement(null, $selector)->getValue(); if ($inputValue !== $text) { - throw new \Exception('Input value does not match: ' . $inputValue . ' expected: ' . $text); + throw new \Exception('Input value does not match: ' . $inputValue . ', expected: ' . $text); } } @@ -678,7 +678,7 @@ public function compareInputValueToElementText(string $inputName, string $select $expectedText = $this->findElement(null, $selector)->getText(); $input = $this->findElement(null, 'input[name="' . $inputName . '"]'); if ($expectedText !== $input->getValue()) { - throw new \Exception('Input value does not match: ' . $input->getValue() . ' expected: ' . $expectedText); + throw new \Exception('Input value does not match: ' . $input->getValue() . ', expected: ' . $expectedText); } } diff --git a/src/Behat/MinkSeleniumDriver.php b/src/Behat/MinkSeleniumDriver.php index 71dcca4849..42821ca0a0 100644 --- a/src/Behat/MinkSeleniumDriver.php +++ b/src/Behat/MinkSeleniumDriver.php @@ -55,6 +55,14 @@ protected function mouseOverElement(WebDriverElement $element): void $this->getWebDriverSession()->moveto(['element' => $element->getID()]); } + private function executeJsSelectText(WebDriverElement $element, int $start, int $stop = null): void + { + $this->executeScript( + 'arguments[0].setSelectionRange(Math.min(arguments[1], Number.MAX_SAFE_INTEGER), Math.min(arguments[2], Number.MAX_SAFE_INTEGER));', + [$element, $start, $stop ?? $start] + ); + } + /** * @param 'type' $action * @param string $options @@ -81,6 +89,11 @@ public function keyboardWrite(string $xpath, $text): void $focusedElement = $this->getWebDriverSession()->activeElement(); if ($element->getID() !== $focusedElement->getID()) { $this->clickOnElement($element); + $focusedElement = $this->getWebDriverSession()->activeElement(); + } + + if (in_array($focusedElement->name(), ['input', 'textarea'], true)) { + $this->executeJsSelectText($focusedElement, \PHP_INT_MAX); } $this->executeSynJsAndWait('type', $element, $text); diff --git a/tests-behat/vue.feature b/tests-behat/vue.feature index 5b4a1bbe87..78c4e43ca9 100644 --- a/tests-behat/vue.feature +++ b/tests-behat/vue.feature @@ -7,11 +7,22 @@ Feature: Vue Then Toast display should contain text "Update saved" Given I am on "javascript/vue-component.php" Then I check if input value for "(//input[@name='atk_fp_country__name'])[1]" match text "test autoSave" - When I fill field using "(//input[@name='atk_fp_country__name'])[1]" with "Germany" + When I fill field using "(//input[@name='atk_fp_country__name'])[1]" with "germany" Then Toast display should contain text "Country name must be unique." + Then I check if input value for "(//input[@name='atk_fp_country__name'])[1]" match text "germany" + When I write "[escape]" into selector "(//input[@name='atk_fp_country__name'])[1]" + Then I check if input value for "(//input[@name='atk_fp_country__name'])[1]" match text "test autoSave" - Scenario: testing InlineEdit - /w onChange callback + Scenario: testing InlineEdit - special keys typing using bitovi/syn + When I persist DB changes across requests + When I write "[ctrl]a[ctrl-up]test ean[left][backspace]" into selector "(//input[@name='atk_fp_country__name'])[1]" + Then No toast should be displayed + When I write "ter[enter]" into selector "(//input[@name='atk_fp_country__name'])[1]" + Then Toast display should contain text "Update saved" Given I am on "javascript/vue-component.php" + Then I check if input value for "(//input[@name='atk_fp_country__name'])[1]" match text "test enter" + + Scenario: testing InlineEdit - /w onChange callback When I fill field using "(//input[@name='atk_fp_country__name'])[2]" with "test callback" Then I should see "new value: test callback" Then I hide js modal