diff --git a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleWithFromDateActionGroup.xml b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleWithFromDateActionGroup.xml new file mode 100644 index 0000000000000..d96f604b2cfee --- /dev/null +++ b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleWithFromDateActionGroup.xml @@ -0,0 +1,33 @@ + + + + + + + Goes to the Admin Cart Price Rule grid page. Adds the provided Rule (with from date). Validates that the Success Message is present and correct. + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Ui/Test/Mftf/Test/AdminGridFilterDeleteAndVerifyErrorMessageTest.xml b/app/code/Magento/Ui/Test/Mftf/Test/AdminGridFilterDeleteAndVerifyErrorMessageTest.xml index 3c93ed38b4eed..ed34ea4017db5 100644 --- a/app/code/Magento/Ui/Test/Mftf/Test/AdminGridFilterDeleteAndVerifyErrorMessageTest.xml +++ b/app/code/Magento/Ui/Test/Mftf/Test/AdminGridFilterDeleteAndVerifyErrorMessageTest.xml @@ -11,10 +11,10 @@ - <description value="Test log in to uI and Delete Grid Filter Test"/> + <description value="Test log in to UI and Delete Grid Filter Test"/> <testCaseId value="MC-14272"/> <severity value="CRITICAL"/> - <group value="uI"/> + <group value="ui"/> <group value="mtf_migrated"/> </annotations> diff --git a/app/code/Magento/Ui/Test/Mftf/Test/AdminLocalizedDateElementTest.xml b/app/code/Magento/Ui/Test/Mftf/Test/AdminLocalizedDateElementTest.xml new file mode 100644 index 0000000000000..e1484ea83a3d4 --- /dev/null +++ b/app/code/Magento/Ui/Test/Mftf/Test/AdminLocalizedDateElementTest.xml @@ -0,0 +1,89 @@ +<?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="AdminLocalizedDateElementTest"> + <annotations> + <stories value="Date element is localized"/> + <title value="Admin user should be able to create active admin user"/> + <description value="Admin date element should be localized."/> + <testCaseId value="MC-29484"/> + <severity value="CRITICAL"/> + <group value="ui"/> + </annotations> + <before> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + + <actionGroup ref="AdminCreateUserWithRoleAndIsActiveActionGroup" stepKey="createAdminUser"> + <argument name="role" value="genericAdminRole"/> + <argument name="user" value="dutchActiveAdmin"/> + </actionGroup> + + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutMasterAdmin"/> + </before> + <after> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAdmin"/> + + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminDeleteUserActionGroup" stepKey="deleteUser"> + <argument name="user" value="dutchActiveAdmin"/> + </actionGroup> + + <actionGroup ref="AdminDeleteCartPriceRuleActionGroup" stepKey="deleteCartPriceRule"> + <argument name="ruleName" value="TestSalesRule"/> + </actionGroup> + + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutMasterAdmin"/> + </after> + + <!-- Step 0. Generate dates, this cannot be done in before section. --> + + <generateDate date="now" format="m/j/Y" timezone="America/Los_Angeles" stepKey="today"/> + <generateDate date="now" format="d-m-Y" timezone="America/Los_Angeles" stepKey="todayNL"/> + <generateDate date="+1 days" format="m/j/Y" timezone="America/Los_Angeles" stepKey="tomorrow"/> + <generateDate date="+1 days" format="d-m-Y" timezone="America/Los_Angeles" stepKey="tomorrowNL"/> + + <!-- Step 1. Log in as main admin --> + + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + + <!-- Step 2. Create cart price rule in en_US admin locale. --> + + <actionGroup ref="AdminCreateCartPriceRuleWithFromDateActionGroup" stepKey="createCartPriceRule"> + <argument name="ruleName" value="TestSalesRule"/> + <argument name="fromDate" value="$today"/> + </actionGroup> + + <!-- Step 3. Log in as Dutch admin. --> + + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutMasterAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsDutchAdmin"> + <argument name="username" value="{{dutchActiveAdmin.username}}"/> + <argument name="password" value="{{dutchActiveAdmin.password}}"/> + </actionGroup> + + <!-- Step 4. Check the cart price rule from date, set it to tomorrow and check again. --> + + <amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/> + <waitForPageLoad stepKey="waitForPriceList"/> + <click selector="{{AdminCartPriceRulesSection.rowContainingText(TestSalesRule.name)}}" stepKey="openCartPriceRule"/> + <waitForPageLoad stepKey="waitForPriceRuleLoad"/> + + <seeInField selector="{{AdminCartPriceRulesFormSection.fromDate}}" userInput="$todayNL" stepKey="checkFromDateBeforeSave"/> + <click selector="{{AdminCartPriceRulesFormSection.saveAndContinue}}" stepKey="clickSaveButton"/> + + <waitForPageLoad stepKey="waitForPriceRuleSave"/> + <seeInField selector="{{AdminCartPriceRulesFormSection.fromDate}}" userInput="$todayNL" stepKey="checkFromDateAfterSave"/> + <fillField selector="{{AdminCartPriceRulesFormSection.fromDate}}" userInput="$tomorrowNL" stepKey="fillStartDate"/> + <click selector="{{AdminCartPriceRulesFormSection.saveAndContinue}}" stepKey="clickSaveButtonAfterChangingFromDate"/> + + <waitForPageLoad stepKey="waitForPriceRuleChangeSave"/> + <seeInField selector="{{AdminCartPriceRulesFormSection.fromDate}}" userInput="$tomorrowNL" stepKey="checkFromDateAfterChangeSaved"/> + </test> +</tests> diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/date.js b/app/code/Magento/Ui/view/base/web/js/form/element/date.js index a5447b290fc5d..6887afbf9c2a8 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/date.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/date.js @@ -31,6 +31,10 @@ define([ * Used only in date picker mode * (this.options.showsTime == false). * + * Locale examples: + * - (en_US): YYYY-MM-DD + * - (nl_NL): YYYY-MM-DD + * * @type {String} */ inputDateFormat: 'y-MM-dd', @@ -42,6 +46,10 @@ define([ * Used only in date picker mode * (this.options.showsTime == false). * + * Locale examples: + * - (en_US): MM/DD/YYYY + * - (nl_NL): DD-MM-YYYY + * * @type {String} */ outputDateFormat: 'MM/dd/y', @@ -117,22 +125,27 @@ define([ /** * Prepares and sets date/time value that will be displayed * in the input field. - * - * @param {String} value */ - onValueChange: function (value) { - var shiftedValue; + setInitialValue: function () { + const value = this.getInitialValue(); + let shiftedValue; if (value) { if (this.options.showsTime && !this.options.timeOnly) { shiftedValue = moment.tz(value, 'UTC').tz(this.storeTimeZone); } else { - shiftedValue = moment(value, this.outputDateFormat, true); + if (this.parentScope.startsWith('filters.')) { + /* + * Date element in filter will get date value in outputDateFormat, + * because the server does not convert it from client format to + * server format when saving UI bookmark data. + */ + shiftedValue = moment(value, this.outputDateFormat, true); + } else { + shiftedValue = moment(value, this.inputDateFormat, true); + } } - if (!shiftedValue.isValid()) { - shiftedValue = moment(value, this.inputDateFormat); - } shiftedValue = shiftedValue.format(this.pickerDateTimeFormat); } else { shiftedValue = ''; @@ -141,6 +154,8 @@ define([ if (shiftedValue !== this.shiftedValue()) { this.shiftedValue(shiftedValue); } + + return this._super(); }, /** diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleActionGroup.xml index dd4f181204040..1757dc0d9c541 100644 --- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleActionGroup.xml +++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleActionGroup.xml @@ -26,6 +26,7 @@ <fillField selector="{{AdminCreateUserSection.passwordTextField}}" userInput="{{user.password}}" stepKey="enterPassword"/> <fillField selector="{{AdminCreateUserSection.pwConfirmationTextField}}" userInput="{{user.password}}" stepKey="confirmPassword"/> <fillField selector="{{AdminCreateUserSection.currentPasswordField}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="enterCurrentPassword"/> + <selectOption selector="{{AdminCreateUserSection.interfaceLocale}}" userInput="{{user.interface_local}}" stepKey="selectInterfaceLocale"/> <scrollToTopOfPage stepKey="scrollToTopOfPage"/> <click stepKey="clickUserRole" selector="{{AdminCreateUserSection.userRoleTab}}"/> <click stepKey="chooseRole" selector="{{AdminStoreSection.createdRoleInUserPage(role.name)}}"/> diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserActionGroup.xml index 82a3a37cdd724..6979f8e749d15 100644 --- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserActionGroup.xml +++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserActionGroup.xml @@ -21,7 +21,7 @@ <click stepKey="openTheUser" selector="{{AdminDeleteUserSection.role(user.username)}}"/> <fillField stepKey="TypeCurrentPassword" selector="{{AdminDeleteUserSection.password}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> <scrollToTopOfPage stepKey="scrollToTop"/> - <click stepKey="clickToDeleteRole" selector="{{AdminDeleteUserSection.delete}}"/> + <click stepKey="clickToDeleteUser" selector="{{AdminDeleteUserSection.delete}}"/> <waitForElementVisible stepKey="wait" selector="{{AdminDeleteRoleSection.confirm}}" time="30"/> <click stepKey="clickToConfirm" selector="{{AdminDeleteUserSection.confirm}}"/> <waitForPageLoad stepKey="waitForPageLoad"/> diff --git a/app/code/Magento/User/Test/Mftf/Data/UserData.xml b/app/code/Magento/User/Test/Mftf/Data/UserData.xml index cf15c77810791..ab4ee398fab19 100644 --- a/app/code/Magento/User/Test/Mftf/Data/UserData.xml +++ b/app/code/Magento/User/Test/Mftf/Data/UserData.xml @@ -123,6 +123,12 @@ <data key="name" unique="suffix">admin</data> <data key="is_active">0</data> </entity> + <entity name="dutchActiveAdmin" type="user" extends="NewAdminUser"> + <data key="name" unique="suffix">admin</data> + <data key="is_active">1</data> + <data key="interface_local">nl_NL</data> + <data key="interface_local_label">Nederlands (Nederland)</data> + </entity> <entity name="adminUserCorrectPassword" type="user"> <data key="username">admin_user_with_correct_password</data> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCreateUserSection.xml b/app/code/Magento/User/Test/Mftf/Section/AdminCreateUserSection.xml similarity index 91% rename from app/code/Magento/Customer/Test/Mftf/Section/AdminCreateUserSection.xml rename to app/code/Magento/User/Test/Mftf/Section/AdminCreateUserSection.xml index 9548fb3175496..ad89f0f477ef1 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCreateUserSection.xml +++ b/app/code/Magento/User/Test/Mftf/Section/AdminCreateUserSection.xml @@ -18,6 +18,7 @@ <element name="emailTextField" type="input" selector="#user_email"/> <element name="passwordTextField" type="input" selector="#user_password"/> <element name="pwConfirmationTextField" type="input" selector="#user_confirmation"/> + <element name="interfaceLocale" type="select" selector="#page_tabs_main_section_content select[name='interface_locale']"/> <element name="currentPasswordField" type="input" selector="#user_current_password"/> <element name="createdRoleInUserPage" type="text" selector="//tr//td[contains(text(), '{{arg}}')]" parameterized="true"/> <element name="userRoleTab" type="button" selector="#page_tabs_roles_section"/>