Skip to content

Commit 928ca8c

Browse files
committed
MC-17269: Date format grid is not based on the locale defined in the back-office
1 parent 227475f commit 928ca8c

File tree

3 files changed

+93
-1
lines changed

3 files changed

+93
-1
lines changed

app/code/Magento/Sales/Test/Mftf/Section/AdminOrderDetailsInformationSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
<element name="shippingAddress" type="text" selector=".order-shipping-address"/>
2121
<element name="itemsOrdered" type="text" selector=".edit-order-table"/>
2222
<element name="paymentInformation" type="text" selector="//div[@class='order-payment-method-title']"/>
23+
<element name="orderId" type="text" selector="|Order # (\d+)|"/>
2324
</section>
24-
</sections>
25+
</sections>

app/code/Magento/Ui/Component/Listing/Columns/Date.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ public function prepare()
109109
'months' => $months,
110110
'monthsShort' => $monthsShort,
111111
];
112+
if (!isset($config['dateFormat'])) {
113+
$config['dateFormat'] = $this->timezone->getDateTimeFormat(\IntlDateFormatter::MEDIUM);
114+
}
112115
$this->setData('config', $config);
113116

114117
parent::prepare();
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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="AdminCheckingDateAfterChangeInterfaceLocaleTest">
11+
<annotations>
12+
<features value="Ui"/>
13+
<stories value="Checking the value in a grid column"/>
14+
<title value="Checking date format in orders grid column after changing admin interface locale"/>
15+
<description value="Checking date format in orders grid column after changing admin interface locale"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-17761"/>
18+
<useCaseId value="MC-17269"/>
19+
<group value="ui"/>
20+
</annotations>
21+
<before>
22+
<!--Create entities-->
23+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
24+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
25+
<!--Login to Admin page-->
26+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
27+
</before>
28+
<after>
29+
<!--Delete entities-->
30+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
31+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
32+
<!--Set Admin "Interface Locale" to default value-->
33+
<actionGroup ref="SetAdminAccountActionGroup" stepKey="setAdminInterfaceLocaleToDefaultValue">
34+
<argument name="InterfaceLocaleByValue" value="en_US"/>
35+
</actionGroup>
36+
<!--Clear filters-->
37+
<actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/>
38+
<!--Logout from Admin page-->
39+
<actionGroup ref="logout" stepKey="logout"/>
40+
</after>
41+
42+
<!--Create order-->
43+
<actionGroup ref="CreateOrderActionGroup" stepKey="createOrder">
44+
<argument name="product" value="$$createProduct$$"/>
45+
<argument name="customer" value="$$createCustomer$$"/>
46+
</actionGroup>
47+
<grabTextFrom selector="{{AdminOrderDetailsInformationSection.orderId}}" stepKey="grabOrderId"/>
48+
49+
<!--Filter orders grid by ID on Admin page-->
50+
<actionGroup ref="filterOrderGridById" stepKey="filterOrderGridById">
51+
<argument name="orderId" value="{$grabOrderId}"/>
52+
</actionGroup>
53+
54+
<!--Get date from "Purchase Date" column-->
55+
<grabTextFrom selector="{{AdminOrdersGridSection.gridCell('1','Purchase Date')}}" stepKey="grabPurchaseDateInDefaultLocale"/>
56+
57+
<!--Get month name in default locale (US)-->
58+
<executeJS function="return (new Date('{$grabPurchaseDateInDefaultLocale}').toLocaleDateString('en-US', {month: 'short'}))" stepKey="getMonthNameInUS"/>
59+
60+
<!--Checking Date with default "Interface Locale"-->
61+
<assertContains stepKey="checkingDateWithDefaultInterfaceLocale">
62+
<expectedResult type="variable">getMonthNameInUS</expectedResult>
63+
<actualResult type="variable">grabPurchaseDateInDefaultLocale</actualResult>
64+
</assertContains>
65+
66+
<!--Set Admin "Interface Locale" to "Français (France) / français (France)"-->
67+
<actionGroup ref="SetAdminAccountActionGroup" stepKey="setAdminInterfaceLocaleToFrance">
68+
<argument name="InterfaceLocaleByValue" value="fr_FR"/>
69+
</actionGroup>
70+
71+
<!--Filter orders grid by ID on Admin page after changing "Interface Locale"-->
72+
<actionGroup ref="filterOrderGridById" stepKey="filterOrderGridByIdAfterSetFrenchLocale">
73+
<argument name="orderId" value="{$grabOrderId}"/>
74+
</actionGroup>
75+
76+
<!--Get date from "Purchase Date" column after changing "Interface Locale"-->
77+
<grabTextFrom selector="{{AdminOrdersGridSection.gridCell('1','Purchase Date')}}" stepKey="grabPurchaseDateInFrenchLocale"/>
78+
79+
<!--Get month name in French-->
80+
<executeJS function="return (new Date('{$grabPurchaseDateInDefaultLocale}').toLocaleDateString('fr-FR', {month: 'short'}))" stepKey="getMonthNameInFrench"/>
81+
82+
<!--Checking Date after changing "Interface Locale"-->
83+
<assertContains stepKey="checkingDateAfterChangeInterfaceLocale">
84+
<expectedResult type="variable">getMonthNameInFrench</expectedResult>
85+
<actualResult type="variable">grabPurchaseDateInFrenchLocale</actualResult>
86+
</assertContains>
87+
</test>
88+
</tests>

0 commit comments

Comments
 (0)