Skip to content

Commit 39e4bcb

Browse files
committed
Merge branch 'MC-35968' into 2.4-develop-com-pr14
2 parents cab49b4 + 566cb4e commit 39e4bcb

File tree

44 files changed

+1274
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1274
-25
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenSalesCheckoutConfigPageActionGroup">
11+
<annotations>
12+
<description>Goes to the Store Configuration > Sales > Checkout configuration page in admin.</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="tabGroupAnchor" type="string" defaultValue=""/>
16+
</arguments>
17+
<amOnPage url="{{AdminCheckoutConfigPage.url(tabGroupAnchor)}}" stepKey="openCheckoutConfigPage"/>
18+
<waitForPageLoad stepKey="waitForCheckoutConfigPageLoad"/>
19+
</actionGroup>
20+
</actionGroups>
21+
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="AdminSelectClearShoppingCartConfigurationActionGroup">
12+
<annotations>
13+
<description>Enable/Disable clear shopping cart store configuration using UI.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="value" type="string" defaultValue="{{EnableClearShoppingCart.textValue}}"/>
17+
</arguments>
18+
<waitForElementVisible selector="{{AdminCheckoutConfigSection.clearShoppingCartEnabledInherit}}" stepKey="waitForClearShoppingCartEnabledInherit" />
19+
<uncheckOption selector="{{AdminCheckoutConfigSection.clearShoppingCartEnabledInherit}}" stepKey="uncheckUseSystem" />
20+
<waitForElementVisible selector="{{AdminCheckoutConfigSection.clearShoppingCartEnabled}}" stepKey="waitForClearShoppingCartEnabled" />
21+
<selectOption selector="{{AdminCheckoutConfigSection.clearShoppingCartEnabled}}" userInput="{{value}}" stepKey="fillClearShoppingCartEnabled" />
22+
</actionGroup>
23+
</actionGroups>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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="StorefrontClearShoppingCartActionGroup">
12+
<annotations>
13+
<description>Clicks the Clear Shopping Cart button on the storefront on the shopping cart page and verifies shopping cart gets emptied.</description>
14+
</annotations>
15+
16+
<waitForElementVisible selector="{{CheckoutCartProductSection.emptyCartButton}}" stepKey="waitForEmptyCartButton"/>
17+
<click selector="{{CheckoutCartProductSection.emptyCartButton}}" stepKey="clickEmptyCartButton"/>
18+
<waitForElementVisible selector="{{CheckoutCartProductSection.modalMessage}}" stepKey="waitForModalMessage"/>
19+
<waitForText selector="{{CheckoutCartProductSection.modalMessage}}" userInput="Are you sure you want to remove all items from your shopping cart?" stepKey="waitForTextModalMessage"/>
20+
<waitForElementVisible selector="{{CheckoutCartProductSection.modalConfirmButton}}" stepKey="waitForModalConfirmButton"/>
21+
<click selector="{{CheckoutCartProductSection.modalConfirmButton}}" stepKey="clickModalConfirmButton"/>
22+
<waitForPageLoad stepKey="waitForPageLoad"/>
23+
<seeCurrentUrlEquals url="{{_ENV.MAGENTO_BASE_URL}}checkout/cart" stepKey="seeCurrentUrlEqualsCartPage"/>
24+
<waitForText selector="{{CheckoutCartMessageSection.emptyCartMessage}}" userInput="You have no items in your shopping cart." stepKey="waitForEmptyCartMessage"/>
25+
26+
</actionGroup>
27+
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/Data/ConfigData.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,17 @@
100100
<data key="label">Display number of items in cart</data>
101101
<data key="value">0</data>
102102
</entity>
103+
104+
<entity name="EnableClearShoppingCart">
105+
<data key="path">checkout/cart/enable_clear_shopping_cart</data>
106+
<data key="label">Display clear shopping cart button on the cart page</data>
107+
<data key="value">1</data>
108+
<data key="textValue">Yes</data>
109+
</entity>
110+
<entity name="DisableClearShoppingCart">
111+
<data key="path">checkout/cart/enable_clear_shopping_cart</data>
112+
<data key="label">Do not display clear shopping cart button on the cart page</data>
113+
<data key="value">0</data>
114+
<data key="textValue">No</data>
115+
</entity>
103116
</entities>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
9+
<page name="AdminCheckoutConfigPage" url="admin/system_config/edit/section/checkout/{{tabLink}}" area="admin" parameterized="true" module="Magento_Checkout">
10+
<section name="AdminCheckoutConfigSection"/>
11+
</page>
12+
</pages>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
9+
<section name="AdminCheckoutConfigSection">
10+
<element name="clearShoppingCartEnabled" type="select" selector="#checkout_cart_enable_clear_shopping_cart" timeout="30"/>
11+
<element name="clearShoppingCartEnabledInherit" type="select" selector="#checkout_cart_enable_clear_shopping_cart_inherit" timeout="30"/>
12+
</section>
13+
</sections>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
<element name="checkoutCartProductPrice" type="text" selector="//td[@class='col price']//span[@class='price']"/>
4949
<element name="checkoutCartSubtotal" type="text" selector="//td[@class='col subtotal']//span[@class='price']"/>
5050
<element name="emptyCart" selector=".cart-empty" type="text"/>
51+
<element name="emptyCartButton" type="button" selector="#empty_cart_button" timeout="30"/>
52+
<element name="modalMessage" type="text" selector=".modal-popup.confirm._show .modal-content" timeout="30"/>
53+
<element name="modalConfirmButton" type="button" selector=".modal-popup.confirm._show .action-accept" timeout="30"/>
5154
<!-- Required attention section -->
5255
<element name="removeProductBySku" type="button" selector="//div[contains(., '{{sku}}')]/ancestor::tbody//button" parameterized="true" timeout="30"/>
5356
<element name="failedItemBySku" type="block" selector="//div[contains(.,'{{sku}}')]/ancestor::tbody" parameterized="true" timeout="30"/>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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="ClearShoppingCartEnableDisableConfigurationTest">
11+
<annotations>
12+
<features value="Checkout"/>
13+
<stories value="Shopping Cart"/>
14+
<title value="Enable and Disable Clear Shopping Cart Configuration"/>
15+
<description value="Verify that disabling the clear shopping cart store configuration will remove the clear shopping cart configuration button from the storefront's shopping cart page. Verify that enabling the configuration will add the button to the page and that the button functions as expected"/>
16+
<group value="shoppingCart"/>
17+
<severity value="MAJOR"/>
18+
</annotations>
19+
<before>
20+
<!-- Create simple products and category -->
21+
<createData entity="_defaultCategory" stepKey="createCategory"/>
22+
<createData entity="SimpleProduct" stepKey="createProduct1">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
<createData entity="SimpleProduct" stepKey="createProduct2">
26+
<requiredEntity createDataKey="createCategory"/>
27+
</createData>
28+
29+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
30+
</before>
31+
<after>
32+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
33+
<deleteData createDataKey="createProduct1" stepKey="deleteProduct1"/>
34+
<deleteData createDataKey="createProduct2" stepKey="deleteProduct2"/>
35+
36+
<!-- Disable clear shopping cart -->
37+
<magentoCLI command="config:set {{DisableClearShoppingCart.path}} {{DisableClearShoppingCart.value}}" stepKey="disableClearShoppingCart"/>
38+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
39+
</after>
40+
41+
<!-- Navigate to sales checkout cart configuration -->
42+
<actionGroup ref="AdminOpenSalesCheckoutConfigPageActionGroup" stepKey="openSalesCheckoutCartConfig1">
43+
<argument name="tabGroupAnchor" value="#checkout_cart-link"/>
44+
</actionGroup>
45+
46+
<!-- Enable clear shopping cart button -->
47+
<actionGroup ref="AdminSelectClearShoppingCartConfigurationActionGroup" stepKey="enableClearShoppingCartButton"/>
48+
<actionGroup ref="SaveStoreConfigurationActionGroup" stepKey="saveStoreConfiguration1"/>
49+
50+
<!-- Open product 1 and add to cart -->
51+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProduct1Page1">
52+
<argument name="product" value="$$createProduct1$$"/>
53+
</actionGroup>
54+
<actionGroup ref="StorefrontAddToTheCartActionGroup" stepKey="product1AddToCart"/>
55+
56+
<!-- Open product 2 and add to cart -->
57+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProduct2Page">
58+
<argument name="product" value="$$createProduct2$$"/>
59+
</actionGroup>
60+
<actionGroup ref="StorefrontAddToTheCartActionGroup" stepKey="product2AddToCart"/>
61+
62+
<!-- Go to shopping cart page -->
63+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage1"/>
64+
65+
<!-- Clear shopping cart -->
66+
<actionGroup ref="StorefrontClearShoppingCartActionGroup" stepKey="clearShoppingCart"/>
67+
<actionGroup ref="AssertMiniCartEmptyActionGroup" stepKey="assertMiniCartEmpty"/>
68+
69+
<!-- Return to Admin to disable clear shopping cart -->
70+
<actionGroup ref="AdminOpenSalesCheckoutConfigPageActionGroup" stepKey="openSalesCheckoutCartConfig2"/>
71+
<actionGroup ref="AdminSelectClearShoppingCartConfigurationActionGroup" stepKey="disableClearShoppingCartButton">
72+
<argument name="value" value="{{DisableClearShoppingCart.textValue}}"/>
73+
</actionGroup>
74+
<actionGroup ref="SaveStoreConfigurationActionGroup" stepKey="saveStoreConfiguration2"/>
75+
76+
<!-- Open product 1 page and add to cart -->
77+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProduct1Page2">
78+
<argument name="product" value="$$createProduct1$$"/>
79+
</actionGroup>
80+
<actionGroup ref="StorefrontAddToTheCartActionGroup" stepKey="product1AddToCart2"/>
81+
82+
<!-- Go to shopping cart and assert clear shopping cart button is not rendered in UI -->
83+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage2"/>
84+
<dontSeeElementInDOM selector="{{CheckoutCartProductSection.emptyCartButton}}" stepKey="dontSeeElementEmptyCartButton"/>
85+
</test>
86+
</tests>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Checkout\ViewModel;
8+
9+
use Magento\Framework\App\Config\ScopeConfigInterface;
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
use Magento\Framework\View\Element\Context;
12+
use Magento\Store\Model\ScopeInterface;
13+
14+
/**
15+
* Cart form view model.
16+
*/
17+
class Cart implements ArgumentInterface
18+
{
19+
/**
20+
* Config settings path to enable clear shopping cart button
21+
*/
22+
private const XPATH_CONFIG_ENABLE_CLEAR_SHOPPING_CART = 'checkout/cart/enable_clear_shopping_cart';
23+
24+
/**
25+
* @var ScopeConfigInterface
26+
*/
27+
private $_scopeConfig;
28+
29+
/**
30+
* Constructor
31+
*
32+
* @param Context $context
33+
*/
34+
public function __construct(
35+
Context $context
36+
) {
37+
$this->_scopeConfig = $context->getScopeConfig();
38+
}
39+
40+
/**
41+
* Check if clear shopping cart button is enabled
42+
*
43+
* @return bool
44+
*/
45+
public function isClearShoppingCartEnabled()
46+
{
47+
return (bool)$this->_scopeConfig->getValue(
48+
self::XPATH_CONFIG_ENABLE_CLEAR_SHOPPING_CART,
49+
ScopeInterface::SCOPE_WEBSITE
50+
);
51+
}
52+
}

app/code/Magento/Checkout/etc/adminhtml/system.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
<label>Show Cross-sell Items in the Shopping Cart</label>
4949
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
5050
</field>
51+
<field id="enable_clear_shopping_cart" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" canRestore="1">
52+
<label>Enable Clear Shopping Cart</label>
53+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
54+
</field>
5155
</group>
5256
<group id="cart_link" translate="label" sortOrder="3" showInDefault="1" showInWebsite="1">
5357
<label>My Cart Link</label>

0 commit comments

Comments
 (0)