Skip to content

Commit bba8b73

Browse files
authored
ENGCOM-5545: "New Tax Rate" missing validation => data is automatically changed when saving issue 23967 #23968
2 parents 1e12fd2 + 90f2f6e commit bba8b73

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

app/code/Magento/Tax/Block/Adminhtml/Rate/Form.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*
1010
* @author Magento Core Team <core@magentocommerce.com>
1111
*/
12+
declare(strict_types=1);
13+
1214
namespace Magento\Tax\Block\Adminhtml\Rate;
1315

1416
use Magento\Framework\Exception\NoSuchEntityException;
@@ -228,7 +230,8 @@ protected function _prepareForm()
228230
'note' => __(
229231
"'*' - matches any; 'xyz*' - matches any that begins on 'xyz' and are not longer than %1.",
230232
$this->_taxData->getPostCodeSubStringLength()
231-
)
233+
),
234+
'class' => 'validate-length maximum-length-' . $this->_taxData->getPostCodeSubStringLength()
232235
]
233236
);
234237

app/code/Magento/Tax/Test/Mftf/Data/TaxRateData.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,14 @@
117117
<data key="zip_is_range">0</data>
118118
<data key="rate">10</data>
119119
</entity>
120+
<entity name="taxRateWithInvalidPostCodeLength" type="taxRate">
121+
<data key="code" unique="suffix">Tax Rate </data>
122+
<data key="tax_country_id">US</data>
123+
<data key="tax_country">United States</data>
124+
<data key="tax_region_id">12</data>
125+
<data key="tax_region">California</data>
126+
<data key="tax_postcode">12345678901</data>
127+
<data key="zip_is_range">0</data>
128+
<data key="rate">100.0000</data>
129+
</entity>
120130
</entities>

app/code/Magento/Tax/Test/Mftf/Section/AdminTaxRateFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
<element name="rangeFrom" type="text" selector="#zip_from"/>
2121
<element name="rangeTo" type="text" selector="#zip_to"/>
2222
<element name="zipCode" type="input" selector="#tax_postcode"/>
23+
<element name="fieldError" type="text" selector="//input[@name='{{fieldName}}']/following-sibling::label[@class='mage-error']" parameterized="true"/>
2324
</section>
2425
</sections>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminCreateTaxRateInvalidPostcodeTestLength">
12+
<annotations>
13+
<stories value="Create tax rate"/>
14+
<title value="Create tax rate, invalid post code length"/>
15+
<description value="Test log in to Create Tax Rate and Create Tax Rate with invalid post code length"/>
16+
<testCaseId value="MC-18817"/>
17+
<severity value="AVERAGE"/>
18+
<group value="tax"/>
19+
<group value="mtf_migrated"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
</before>
24+
25+
<amOnPage url="{{AdminTaxRateGridPage.url}}" stepKey="goToTaxRateIndex1"/>
26+
<waitForPageLoad stepKey="waitForTaxRateIndex1"/>
27+
<!-- Create a tax rate for large postcodes -->
28+
<click selector="{{AdminTaxRateGridSection.add}}" stepKey="clickAddNewTaxRateButton"/>
29+
<fillField selector="{{AdminTaxRateFormSection.taxIdentifier}}" userInput="{{taxRateWithInvalidPostCodeLength.code}}" stepKey="fillRuleName"/>
30+
<fillField selector="{{AdminTaxRateFormSection.zipCode}}" userInput="{{taxRateWithInvalidPostCodeLength.tax_postcode}}" stepKey="fillPostCode"/>
31+
<selectOption selector="{{AdminTaxRateFormSection.country}}" userInput="{{taxRateWithInvalidPostCodeLength.tax_country}}" stepKey="selectCountry1"/>
32+
<selectOption selector="{{AdminTaxRateFormSection.state}}" userInput="{{taxRateWithInvalidPostCodeLength.tax_region}}" stepKey="selectState" />
33+
<fillField selector="{{AdminTaxRateFormSection.rate}}" userInput="{{taxRateWithInvalidPostCodeLength.rate}}" stepKey="fillRate"/>
34+
<click selector="{{AdminTaxRateFormSection.save}}" stepKey="clickSave"/>
35+
<see selector="{{AdminTaxRateFormSection.fieldError('tax_postcode')}}" userInput="Please enter less or equal than 10 symbols." stepKey="seeErrorMessage"/>
36+
</test>
37+
</tests>

0 commit comments

Comments
 (0)