Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

27027 added date format adjustment for 'validate-dob' rule #27149

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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