Skip to content

Commit

Permalink
ENGCOM-7036: 27027 added date format adjustment for 'validate-dob' rule
Browse files Browse the repository at this point in the history
  • Loading branch information
slavvka committed Mar 5, 2020
2 parents c188002 + fe1a803 commit 9cbb34a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertAdminCustomerDateOfBirthValidationMessageActionGroup">
<annotations>
<description>Fills 'Date of Birth' input with provided 'dob' value, clicks 'save' button, checks
there is no provided validation error message for the 'Date of Birth' input on the page.</description>
</annotations>
<arguments>
<argument name="message" type="string" defaultValue="The Date of Birth should not be greater than today."/>
<argument name="dob" type="string" defaultValue="15/01/1970"/>
</arguments>

<fillField userInput="{{dob}}" selector="{{AdminCustomerAccountInformationSection.dateOfBirth}}" stepKey="fillDateOfBirth"/>
<click selector="{{AdminCustomerMainActionsSection.saveButton}}" stepKey="saveCustomer"/>
<dontSee selector="{{AdminCustomerAccountInformationSection.dateOfBirthValidationErrorField}}" userInput="{{message}}" stepKey="seeTheErrorMessageIsDisplayed"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<element name="disabledGroup" type="text" selector="//div[@class='admin__action-group-wrap admin__action-multiselect-wrap action-select-wrap _disabled']"/>
<element name="customerAttribute" type="input" selector="//input[contains(@name,'{{attributeCode}}')]" parameterized="true"/>
<element name="attributeImage" type="block" selector="//div[contains(concat(' ',normalize-space(@class),' '),' file-uploader-preview ')]//img"/>
<element name="dateOfBirthValidationErrorField" type="text" selector="input[name='customer[dob]'] ~ label.admin__field-error"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminCheckDateOfBirthValidationForFranceDateFormatTest">
<annotations>
<features value="Customer"/>
<stories value="Checks 'Date of Birth' field validation for the France date format value"/>
<title value="Checks 'Date of Birth' field validation for the France date format value"/>
<group value="customer"/>
<group value="ui"/>
</annotations>
<before>
<magentoCLI command="setup:static-content:deploy fr_FR" stepKey="deployStaticContentWithFrenchLocale"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="SetAdminAccountActionGroup" stepKey="setAdminInterfaceLocaleToFrance">
<argument name="InterfaceLocaleByValue" value="fr_FR"/>
</actionGroup>
</before>

<after>
<actionGroup ref="SetAdminAccountActionGroup" stepKey="setAdminInterfaceLocaleToDefaultValue">
<argument name="InterfaceLocaleByValue" value="en_US"/>
</actionGroup>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<actionGroup ref="AdminNavigateNewCustomerActionGroup" stepKey="navigateToNewCustomerPage"/>
<actionGroup ref="AssertAdminCustomerDateOfBirthValidationMessageActionGroup" stepKey="assertDateOfBirthValidationMessage"/>
</test>
</tests>
4 changes: 2 additions & 2 deletions app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -1069,12 +1069,12 @@ define([
$.mage.__('This link is not allowed.')
],
'validate-dob': [
function (value) {
function (value, param, params) {
if (value === '') {
return true;
}

return moment(value).isBefore(moment());
return moment.utc(value, params.dateFormat).isSameOrBefore(moment.utc());
},
$.mage.__('The Date of Birth should not be greater than today.')
]
Expand Down

0 comments on commit 9cbb34a

Please sign in to comment.