Skip to content

Commit fe1a803

Browse files
ENGCOM-7036: 27027 added date format adjustment for 'validate-dob' rule #27149
- Merge Pull Request #27149 from sergiy-v/magento2:27027-dob-validation-adjustments - Merged commits: 1. 8f81132
2 parents 5a9fcab + 8f81132 commit fe1a803

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminCustomerDateOfBirthValidationMessageActionGroup">
12+
<annotations>
13+
<description>Fills 'Date of Birth' input with provided 'dob' value, clicks 'save' button, checks
14+
there is no provided validation error message for the 'Date of Birth' input on the page.</description>
15+
</annotations>
16+
<arguments>
17+
<argument name="message" type="string" defaultValue="The Date of Birth should not be greater than today."/>
18+
<argument name="dob" type="string" defaultValue="15/01/1970"/>
19+
</arguments>
20+
21+
<fillField userInput="{{dob}}" selector="{{AdminCustomerAccountInformationSection.dateOfBirth}}" stepKey="fillDateOfBirth"/>
22+
<click selector="{{AdminCustomerMainActionsSection.saveButton}}" stepKey="saveCustomer"/>
23+
<dontSee selector="{{AdminCustomerAccountInformationSection.dateOfBirthValidationErrorField}}" userInput="{{message}}" stepKey="seeTheErrorMessageIsDisplayed"/>
24+
</actionGroup>
25+
</actionGroups>

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountInformationSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@
3636
<element name="disabledGroup" type="text" selector="//div[@class='admin__action-group-wrap admin__action-multiselect-wrap action-select-wrap _disabled']"/>
3737
<element name="customerAttribute" type="input" selector="//input[contains(@name,'{{attributeCode}}')]" parameterized="true"/>
3838
<element name="attributeImage" type="block" selector="//div[contains(concat(' ',normalize-space(@class),' '),' file-uploader-preview ')]//img"/>
39+
<element name="dateOfBirthValidationErrorField" type="text" selector="input[name='customer[dob]'] ~ label.admin__field-error"/>
3940
</section>
4041
</sections>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminCheckDateOfBirthValidationForFranceDateFormatTest">
11+
<annotations>
12+
<features value="Customer"/>
13+
<stories value="Checks 'Date of Birth' field validation for the France date format value"/>
14+
<title value="Checks 'Date of Birth' field validation for the France date format value"/>
15+
<group value="customer"/>
16+
<group value="ui"/>
17+
</annotations>
18+
<before>
19+
<magentoCLI command="setup:static-content:deploy fr_FR" stepKey="deployStaticContentWithFrenchLocale"/>
20+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
21+
<actionGroup ref="SetAdminAccountActionGroup" stepKey="setAdminInterfaceLocaleToFrance">
22+
<argument name="InterfaceLocaleByValue" value="fr_FR"/>
23+
</actionGroup>
24+
</before>
25+
26+
<after>
27+
<actionGroup ref="SetAdminAccountActionGroup" stepKey="setAdminInterfaceLocaleToDefaultValue">
28+
<argument name="InterfaceLocaleByValue" value="en_US"/>
29+
</actionGroup>
30+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
31+
</after>
32+
33+
<actionGroup ref="AdminNavigateNewCustomerActionGroup" stepKey="navigateToNewCustomerPage"/>
34+
<actionGroup ref="AssertAdminCustomerDateOfBirthValidationMessageActionGroup" stepKey="assertDateOfBirthValidationMessage"/>
35+
</test>
36+
</tests>

app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,12 +1069,12 @@ define([
10691069
$.mage.__('This link is not allowed.')
10701070
],
10711071
'validate-dob': [
1072-
function (value) {
1072+
function (value, param, params) {
10731073
if (value === '') {
10741074
return true;
10751075
}
10761076

1077-
return moment(value).isBefore(moment());
1077+
return moment.utc(value, params.dateFormat).isSameOrBefore(moment.utc());
10781078
},
10791079
$.mage.__('The Date of Birth should not be greater than today.')
10801080
]

0 commit comments

Comments
 (0)