Skip to content

Commit 27b9d8c

Browse files
author
OlgaVasyltsun
committed
MC-17259: Update blank gender it does not saved in direct edits from customer grid
1 parent 71f9784 commit 27b9d8c

10 files changed

+204
-1
lines changed

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCategoryHighlightedAndProductDisplayedTest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
<createData entity="SimpleProduct" stepKey="product4">
3838
<requiredEntity createDataKey="category2"/>
3939
</createData>
40+
41+
<!-- TODO: REMOVE AFTER FIX MC-21717 -->
42+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
43+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
4044
</before>
4145
<after>
4246
<deleteData createDataKey="product1" stepKey="deleteProduct1"/>
Lines changed: 25 additions & 0 deletions
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="AdminUpdateCustomerGenderInCustomersGridActionGroup">
12+
<annotations>
13+
<description>Update customer gender attribute value on customers grid page</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="customerEmail" defaultValue="{{Simple_US_Customer.email}}" type="string"/>
17+
<argument name="genderValue" defaultValue="{{Gender.empty}}" type="string"/>
18+
</arguments>
19+
20+
<click selector="{{AdminDataGridTableSection.rowTemplate(customerEmail)}}" stepKey="clickCustomersGridRow"/>
21+
<waitForElementVisible selector="{{AdminCustomerGridInlineEditorSection.customerGenderEditor}}" stepKey="waitForGenderElementAppeares"/>
22+
<selectOption userInput="{{genderValue}}" selector="{{AdminCustomerGridInlineEditorSection.customerGenderEditor}}" stepKey="selectGenderValue"/>
23+
<click selector="{{AdminCustomerGridInlineEditorSection.saveInGrid}}" stepKey="saveCustomer"/>
24+
</actionGroup>
25+
</actionGroups>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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="AssertAdminCustomerGenderInCustomersGridActionGroup">
12+
<annotations>
13+
<description>Assert customer genderAttribute value on customers grid page</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="customerEmail" defaultValue="{{Simple_US_Customer.email}}" type="string"/>
17+
<argument name="expectedGenderValue" defaultValue="{{Gender.empty}}" type="string"/>
18+
</arguments>
19+
20+
<see userInput="{{expectedGenderValue}}" selector="{{AdminCustomerGridSection.customerGenderByEmail(customerEmail)}}" stepKey="assertGenderValue"/>
21+
</actionGroup>
22+
</actionGroups>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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="AssertAdminCustomerGenderOnCustomerFormActionGroup">
12+
<annotations>
13+
<description>Validates that the provided Customer Gender is selected on the Admin Customer edit page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="customerGender" defaultValue="{{Gender.empty}}" type="string"/>
17+
</arguments>
18+
19+
<conditionalClick selector="{{AdminCustomerAccountInformationSection.accountInformationTab}}" dependentSelector="{{AdminCustomerAccountInformationSection.gender}}" visible="false" stepKey="clickOnAccountInfoTab"/>
20+
<waitForPageLoad stepKey="waitForPageLoad"/>
21+
<seeOptionIsSelected userInput="{{customerGender}}" selector="{{AdminCustomerAccountInformationSection.gender}}" stepKey="verifyNeededCustomerGenderSelected"/>
22+
</actionGroup>
23+
</actionGroups>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="Gender" type="gender">
12+
<data key="empty"/>
13+
<data key="male">Male</data>
14+
<data key="female">Female</data>
15+
<data key="not_specified">Not Specified</data>
16+
</entity>
17+
</entities>

app/code/Magento/Customer/Test/Mftf/Page/AdminCustomerPage.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
<section name="AdminCustomerMessagesSection"/>
1414
<section name="AdminCustomerGridSection"/>
1515
<section name="AdminCustomerFiltersSection"/>
16+
<section name="AdminCustomerGridInlineEditorSection"/>
1617
</page>
1718
</pages>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminCustomerGridInlineEditorSection">
12+
<element name="customerGenderEditor" type="select" selector="tr.data-grid-editable-row:not([style*='display: none']) [name='gender']"/>
13+
<element name="saveInGrid" type="button" selector="tr.data-grid-editable-row-actions button.action-primary" timeout="30"/>
14+
</section>
15+
</sections>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
<element name="customerCheckboxByEmail" type="checkbox" selector="//tr[@class='data-row' and //div[text()='{{customerEmail}}']]//input[@type='checkbox']" parameterized="true" timeout="30"/>
1717
<element name="customerEditLinkByEmail" type="text" selector="//tr[@class='data-row' and //div[text()='{{customerEmail}}']]//a[@class='action-menu-item']" parameterized="true" timeout="30"/>
1818
<element name="customerGroupByEmail" type="text" selector="//tr[@class='data-row' and //div[text()='{{customerEmail}}']]//div[text()='{{customerGroup}}']" parameterized="true"/>
19+
<element name="customerGenderByEmail" type="text" selector="//tr[@class='data-row']//div[text()='{{customerEmail}}']/ancestor::tr/td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Gender')]/preceding-sibling::th) +1]" parameterized="true"/>
1920
</section>
2021
</sections>
22+
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminChangeCustomerGenderInCustomersGridTest">
12+
<annotations>
13+
<features value="Customer"/>
14+
<stories value="Update Customer"/>
15+
<title value="Gender attribute blank value is saved in direct edits from customer grid"/>
16+
<description value="Check that gender attribute blank value can be saved on customers grid"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-22025"/>
19+
<useCaseId value="MC-17259"/>
20+
<group value="customer"/>
21+
</annotations>
22+
<before>
23+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
24+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
25+
</before>
26+
<after>
27+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
28+
<!-- Reset customer grid filter -->
29+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="goToCustomersGridPage"/>
30+
<waitForPageLoad stepKey="waitForCustomersGrid"/>
31+
<actionGroup ref="AdminResetFilterInCustomerGrid" stepKey="resetFilter"/>
32+
33+
<actionGroup ref="logout" stepKey="logout"/>
34+
</after>
35+
<!-- Open customers grid page, filter by created customer-->
36+
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterCustomerGridByEmail">
37+
<argument name="email" value="$createCustomer.email$"/>
38+
</actionGroup>
39+
<!-- Check customer is in grid-->
40+
<actionGroup ref="AdminAssertCustomerInCustomersGrid" stepKey="assertCustomerInCustomersGrid">
41+
<argument name="text" value="$createCustomer.email$"/>
42+
<argument name="row" value="1"/>
43+
</actionGroup>
44+
<!--Check customer Gender value in grid-->
45+
<actionGroup ref="AssertAdminCustomerGenderInCustomersGridActionGroup" stepKey="assertCustomerGenderInCustomersGrid">
46+
<argument name="customerEmail" value="$createCustomer.email$"/>
47+
</actionGroup>
48+
<!--Update customer Gender to Male-->
49+
<actionGroup ref="AdminUpdateCustomerGenderInCustomersGridActionGroup" stepKey="updateCustomerGenderWithMaleValueInCustomersGrid">
50+
<argument name="customerEmail" value="$createCustomer.email$"/>
51+
<argument name="genderValue" value="{{Gender.male}}"/>
52+
</actionGroup>
53+
<!--Check customer Gender value in grid-->
54+
<actionGroup ref="AssertAdminCustomerGenderInCustomersGridActionGroup" stepKey="assertCustomerGenderMaleInCustomersGrid">
55+
<argument name="customerEmail" value="$createCustomer.email$"/>
56+
<argument name="expectedGenderValue" value="{{Gender.male}}"/>
57+
</actionGroup>
58+
<!--Open customer edit page and check Gender value-->
59+
<actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="openCustomerEditPageWithMaleGender">
60+
<argument name="customerId" value="$createCustomer.id$"/>
61+
</actionGroup>
62+
<actionGroup ref="AssertAdminCustomerGenderOnCustomerFormActionGroup" stepKey="assertCustomerGenderValueIsMaleOnCustomerForm">
63+
<argument name="customerGender" value="{{Gender.male}}"/>
64+
</actionGroup>
65+
<!--Filter customers grid by email-->
66+
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterCustomerByEmailToUpdateWithEmptyGender">
67+
<argument name="email" value="$createCustomer.email$"/>
68+
</actionGroup>
69+
<!--Update customer Gender to empty value-->
70+
<actionGroup ref="AdminUpdateCustomerGenderInCustomersGridActionGroup" stepKey="updateCustomerGenderWithEmptyValueInCustomersGrid">
71+
<argument name="customerEmail" value="$createCustomer.email$"/>
72+
</actionGroup>
73+
<!--Check customer Gender value in grid-->
74+
<actionGroup ref="AssertAdminCustomerGenderInCustomersGridActionGroup" stepKey="assertCustomerGenderEmptyInCustomersGrid">
75+
<argument name="customerEmail" value="$createCustomer.email$"/>
76+
</actionGroup>
77+
<!--Open customer edit page and check Gender value-->
78+
<actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="openCustomerEditPageWithEmptyGender">
79+
<argument name="customerId" value="$createCustomer.id$"/>
80+
</actionGroup>
81+
<actionGroup ref="AssertAdminCustomerGenderOnCustomerFormActionGroup" stepKey="assertCustomerGenderValueIsEmptyOnCustomerForm"/>
82+
</test>
83+
</tests>

app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,18 @@ define([
337337
* @returns {Object} Collection of records data.
338338
*/
339339
getData: function () {
340-
var data = this.activeRecords.map('getData');
340+
var data = this.activeRecords.map(function (record) {
341+
var elemKey,
342+
recordData = record.getData();
343+
344+
for (elemKey in recordData) {
345+
if (_.isUndefined(recordData[elemKey])) {
346+
recordData[elemKey] = null;
347+
}
348+
}
349+
350+
return recordData;
351+
});
341352

342353
return _.indexBy(data, this.indexField);
343354
},

0 commit comments

Comments
 (0)