Skip to content

Commit cbef977

Browse files
ENGCOM-6174: Resolve "Disable Automatic Group Change Based on VAT ID" in "New Customer" form at Backend is not respect Setting "Default Value for Disable Automatic Group Changes Based on VAT ID" #25257
2 parents 0d7df6c + 59f393c commit cbef977

7 files changed

+191
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
<!-- Check Default Value for Disable Automatic Group Changes Based on VAT ID in Customer Form -->
12+
<actionGroup name="AdminAssertDefaultValueDisableAutoGroupInCustomerFormActionGroup">
13+
<annotations>
14+
<description>Check Default Value for Disable Automatic Group Changes Based on VAT ID in Create Customer form.</description>
15+
</annotations>
16+
<arguments>
17+
<argument name="isChecked" type="string"/>
18+
</arguments>
19+
20+
<grabValueFrom selector="{{AdminCustomerAccountInformationSection.disableAutomaticGroupChange}}" stepKey="grabDisableAutomaticGroupChange"/>
21+
<assertEquals stepKey="assertDisableAutomaticGroupChangeNo" message="pass">
22+
<expectedResult type="string">{{isChecked}}</expectedResult>
23+
<actualResult type="variable">grabDisableAutomaticGroupChange</actualResult>
24+
</assertEquals>
25+
</actionGroup>
26+
</actionGroups>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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="AdminNavigateNewCustomerActionGroup">
12+
<annotations>
13+
<description>Goes to the New Customer page.</description>
14+
</annotations>
15+
16+
<amOnPage url="{{AdminNewCustomerPage.url}}" stepKey="navigateToCustomers"/>
17+
<waitForPageLoad stepKey="waitForLoad"/>
18+
</actionGroup>
19+
</actionGroups>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<element name="firstName" type="input" selector="input[name='customer[firstname]']"/>
1818
<element name="lastName" type="input" selector="input[name='customer[lastname]']"/>
1919
<element name="email" type="input" selector="input[name='customer[email]']"/>
20+
<element name="disableAutomaticGroupChange" type="input" selector="input[name='customer[disable_auto_group_change]']"/>
2021
<element name="group" type="select" selector="[name='customer[group_id]']"/>
2122
<element name="groupIdValue" type="text" selector="//*[@name='customer[group_id]']/option"/>
2223
<element name="groupValue" type="button" selector="//span[text()='{{groupValue}}']" parameterized="true"/>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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="AdminCheckDefaultValueDisableAutoGroupChangeIsNoTest">
12+
<annotations>
13+
<features value="Customer"/>
14+
<stories value="Default Value for Disable Automatic Group Changes Based on VAT ID"/>
15+
<title value="Check settings Default Value for Disable Automatic Group Changes Based on VAT ID is No"/>
16+
<description value="Check settings Default Value for Disable Automatic Group Changes Based on VAT ID is No"/>
17+
<severity value="MAJOR"/>
18+
<group value="customer"/>
19+
<group value="create"/>
20+
</annotations>
21+
<before>
22+
<magentoCLI command="config:set customer/create_account/viv_disable_auto_group_assign_default 0" stepKey="setConfigDefaultIsNo"/>
23+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
24+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
25+
</before>
26+
<after>
27+
<actionGroup ref="logout" stepKey="adminLogout"/>
28+
</after>
29+
30+
<actionGroup ref="AdminNavigateNewCustomerActionGroup" stepKey="navigateToNewCustomer"/>
31+
32+
<actionGroup ref="AdminAssertDefaultValueDisableAutoGroupInCustomerFormActionGroup" stepKey="seeDefaultValueInForm">
33+
<argument name="isChecked" value="0"/>
34+
</actionGroup>
35+
</test>
36+
</tests>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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="AdminCheckDefaultValueDisableAutoGroupChangeIsYesTest">
12+
<annotations>
13+
<features value="Customer"/>
14+
<stories value="Default Value for Disable Automatic Group Changes Based on VAT ID"/>
15+
<title value="Check settings Default Value for Disable Automatic Group Changes Based on VAT ID is Yes"/>
16+
<description value="Check settings Default Value for Disable Automatic Group Changes Based on VAT ID is Yes"/>
17+
<severity value="MAJOR"/>
18+
<group value="customer"/>
19+
<group value="create"/>
20+
</annotations>
21+
<before>
22+
<magentoCLI command="config:set customer/create_account/viv_disable_auto_group_assign_default 1" stepKey="setConfigDefaultIsYes"/>
23+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
24+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
25+
</before>
26+
<after>
27+
<magentoCLI command="config:set customer/create_account/viv_disable_auto_group_assign_default 0" stepKey="setConfigDefaultIsNo"/>
28+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
29+
<actionGroup ref="logout" stepKey="adminLogout"/>
30+
</after>
31+
32+
<actionGroup ref="AdminNavigateNewCustomerActionGroup" stepKey="navigateToNewCustomer"/>
33+
34+
<actionGroup ref="AdminAssertDefaultValueDisableAutoGroupInCustomerFormActionGroup" stepKey="seeDefaultValueInForm">
35+
<argument name="isChecked" value="1"/>
36+
</actionGroup>
37+
</test>
38+
</tests>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Customer\Ui\Component\Form\Field;
9+
10+
use Magento\Framework\View\Element\UiComponent\ContextInterface;
11+
use Magento\Framework\View\Element\UiComponentFactory;
12+
use Magento\Framework\View\Element\UiComponentInterface;
13+
use Magento\Customer\Helper\Address as AddressHelper;
14+
15+
/**
16+
* Process setting to set Default Value for Disable Automatic Group Changes Based on VAT ID
17+
*
18+
* Class \Magento\Customer\Ui\Component\Form\Field\DisableAutoGroupChange
19+
*/
20+
class DisableAutoGroupChange extends \Magento\Ui\Component\Form\Field
21+
{
22+
/**
23+
* Yes value for Default Value for Disable Automatic Group Changes Based on VAT ID
24+
*/
25+
const DISABLE_AUTO_GROUP_CHANGE_YES = '1';
26+
27+
/**
28+
* Address Helper
29+
*
30+
* @var AddressHelper
31+
*/
32+
private $addressHelper;
33+
34+
/**
35+
* Constructor
36+
*
37+
* @param ContextInterface $context
38+
* @param UiComponentFactory $uiComponentFactory
39+
* @param AddressHelper $addressHelper
40+
* @param UiComponentInterface[] $components
41+
* @param array $data
42+
*/
43+
public function __construct(
44+
ContextInterface $context,
45+
UiComponentFactory $uiComponentFactory,
46+
AddressHelper $addressHelper,
47+
array $components = [],
48+
array $data = []
49+
) {
50+
$this->addressHelper = $addressHelper;
51+
parent::__construct($context, $uiComponentFactory, $components, $data);
52+
}
53+
54+
/**
55+
* Prepare component configuration
56+
*
57+
* @return void
58+
* @throws \Magento\Framework\Exception\LocalizedException
59+
*/
60+
public function prepare()
61+
{
62+
parent::prepare();
63+
64+
if ($this->addressHelper->isDisableAutoGroupAssignDefaultValue()) {
65+
$currentConfig = $this->getData('config');
66+
$currentConfig['default'] = self::DISABLE_AUTO_GROUP_CHANGE_YES;
67+
$this->setData('config', $currentConfig);
68+
}
69+
}
70+
}

app/code/Magento/Customer/view/base/ui_component/customer_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
<dataType>number</dataType>
170170
</settings>
171171
</field>
172-
<field name="disable_auto_group_change" formElement="checkbox">
172+
<field name="disable_auto_group_change" formElement="checkbox" class="Magento\Customer\Ui\Component\Form\Field\DisableAutoGroupChange">
173173
<argument name="data" xsi:type="array">
174174
<item name="config" xsi:type="array">
175175
<item name="fieldGroup" xsi:type="string">group_id</item>

0 commit comments

Comments
 (0)