Skip to content

Commit

Permalink
magento#108: Clear Shopping Cart - Updated MFTF for code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
John Carlo Octabio committed Jul 20, 2020
1 parent d8eeb97 commit 35a469b
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 121 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminOpenSalesCheckoutConfigPageActionGroup">
<annotations>
<description>Goes to the Store Configuration > Sales > Checkout configuration page in admin.</description>
</annotations>
<arguments>
<argument name="tabGroupAnchor" type="string" defaultValue=""/>
</arguments>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminSelectClearShoppingCartConfigurationActionGroup">
<annotations>
<description>Enable/Disable clear shopping cart store configuration using UI.</description>
</annotations>
<arguments>
<argument name="value" type="string" defaultValue="{{EnableClearShoppingCart.textValue}}"/>
</arguments>
<waitForElementVisible selector="{{AdminCheckoutConfigSection.clearShoppingCartEnabledInherit}}" stepKey="waitForClearShoppingCartEnabledInherit" />
<uncheckOption selector="{{AdminCheckoutConfigSection.clearShoppingCartEnabledInherit}}" stepKey="uncheckUseSystem" />
<waitForElementVisible selector="{{AdminCheckoutConfigSection.clearShoppingCartEnabled}}" stepKey="waitForClearShoppingCartEnabled" />
<selectOption selector="{{AdminCheckoutConfigSection.clearShoppingCartEnabled}}" userInput="{{value}}" stepKey="fillClearShoppingCartEnabled" />
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="StorefrontClearShoppingCartActionGroup">
<annotations>
<description>Clicks the Clear Shopping Cart button on the storefront on the shopping cart page and verifies shopping cart gets emptied.</description>
</annotations>

<waitForElementVisible selector="{{CheckoutCartProductSection.emptyCartButton}}" stepKey="waitForEmptyCartButton"/>
<click selector="{{CheckoutCartProductSection.emptyCartButton}}" stepKey="clickEmptyCartButton"/>
<waitForElementVisible selector="{{CheckoutCartProductSection.modalMessage}}" stepKey="waitForModalMessage"/>
<waitForText selector="{{CheckoutCartProductSection.modalMessage}}" userInput="Are you sure you want to remove all items from your shopping cart?" stepKey="waitForTextModalMessage"/>
<waitForElementVisible selector="{{CheckoutCartProductSection.modalConfirmButton}}" stepKey="waitForModalConfirmButton"/>
<click selector="{{CheckoutCartProductSection.modalConfirmButton}}" stepKey="clickModalConfirmButton"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<seeCurrentUrlEquals url="{{_ENV.MAGENTO_BASE_URL}}checkout/cart" stepKey="seeCurrentUrlEqualsCartPage"/>
<waitForText selector="{{CheckoutCartMessageSection.emptyCartMessage}}" userInput="You have no items in your shopping cart." stepKey="waitForEmptyCartMessage"/>

</actionGroup>
</actionGroups>
2 changes: 2 additions & 0 deletions app/code/Magento/Checkout/Test/Mftf/Data/ConfigData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@
<data key="path">checkout/cart/enable_clear_shopping_cart</data>
<data key="label">Display clear shopping cart button on the cart page</data>
<data key="value">1</data>
<data key="textValue">Yes</data>
</entity>
<entity name="DisableClearShoppingCart">
<data key="path">checkout/cart/enable_clear_shopping_cart</data>
<data key="label">Do not display clear shopping cart button on the cart page</data>
<data key="value">0</data>
<data key="textValue">No</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminCheckoutConfigSection">
<element name="clearShoppingCartEnabled" type="select" selector="#checkout_cart_enable_clear_shopping_cart"/>
<element name="clearShoppingCartEnabledInherit" type="select" selector="#checkout_cart_enable_clear_shopping_cart_inherit"/>
<element name="clearShoppingCartEnabled" type="select" selector="#checkout_cart_enable_clear_shopping_cart" timeout="30"/>
<element name="clearShoppingCartEnabledInherit" type="select" selector="#checkout_cart_enable_clear_shopping_cart_inherit" timeout="30"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<element name="checkoutCartSubtotal" type="text" selector="//td[@class='col subtotal']//span[@class='price']"/>
<element name="emptyCart" selector=".cart-empty" type="text"/>
<element name="emptyCartButton" selector="#empty_cart_button" type="button"/>
<element name="modalMessage" type="text" selector=".modal-popup.confirm._show .modal-content" timeout="30"/>
<element name="modalConfirmButton" type="button" selector=".modal-popup.confirm._show .action-accept" timeout="30"/>
<!-- Required attention section -->
<element name="removeProductBySku" type="button" selector="//div[contains(., '{{sku}}')]/ancestor::tbody//button" parameterized="true" timeout="30"/>
<element name="failedItemBySku" type="block" selector="//div[contains(.,'{{sku}}')]/ancestor::tbody" parameterized="true" timeout="30"/>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?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="ClearShoppingCartEnableDisableConfigurationTest">
<annotations>
<features value="Checkout"/>
<stories value="Shopping Cart"/>
<title value="Enable and Disable Clear Shopping Cart Configuration"/>
<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"/>
<group value="shoppingCart"/>
</annotations>
<before>
<!-- Create simple products and category -->
<createData entity="_defaultCategory" stepKey="createCategory"/>
<createData entity="SimpleProduct" stepKey="createProduct1">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="SimpleProduct" stepKey="createProduct2">
<requiredEntity createDataKey="createCategory"/>
</createData>

<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<deleteData createDataKey="createProduct1" stepKey="deleteProduct1"/>
<deleteData createDataKey="createProduct2" stepKey="deleteProduct2"/>

<!-- Disable clear shopping cart -->
<magentoCLI command="config:set {{DisableClearShoppingCart.path}} {{DisableClearShoppingCart.value}}" stepKey="disableClearShoppingCart"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<!-- Navigate to sales checkout cart configuration -->
<actionGroup ref="AdminOpenSalesCheckoutConfigPageActionGroup" stepKey="openSalesCheckoutCartConfig1">
<argument name="tabGroupAnchor" value="#checkout_cart-link"/>
</actionGroup>

<!-- Enable clear shopping cart button -->
<actionGroup ref="AdminSelectClearShoppingCartConfigurationActionGroup" stepKey="enableClearShoppingCartButton"/>
<actionGroup ref="SaveStoreConfigurationActionGroup" stepKey="saveStoreConfiguration1"/>
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cliCacheClean1">
<argument name="tags" value=""/>
</actionGroup>

<!-- Open product 1 and add to cart -->
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProduct1Page1">
<argument name="product" value="$$createProduct1$$"/>
</actionGroup>
<actionGroup ref="StorefrontAddToTheCartActionGroup" stepKey="product1AddToCart"/>

<!-- Open product 2 and add to cart -->
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProduct2Page">
<argument name="product" value="$$createProduct2$$"/>
</actionGroup>
<actionGroup ref="StorefrontAddToTheCartActionGroup" stepKey="product2AddToCart"/>

<!-- Go to shopping cart page -->
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage1"/>

<!-- Clear shopping cart -->
<actionGroup ref="StorefrontClearShoppingCartActionGroup" stepKey="clearShoppingCart"/>
<actionGroup ref="AssertMiniCartEmptyActionGroup" stepKey="assertMiniCartEmpty"/>

<!-- Return to Admin to disable clear shopping cart -->
<actionGroup ref="AdminOpenSalesCheckoutConfigPageActionGroup" stepKey="openSalesCheckoutCartConfig2"/>
<actionGroup ref="AdminSelectClearShoppingCartConfigurationActionGroup" stepKey="disableClearShoppingCartButton">
<argument name="value" value="{{DisableClearShoppingCart.textValue}}"/>
</actionGroup>
<actionGroup ref="SaveStoreConfigurationActionGroup" stepKey="saveStoreConfiguration2"/>
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cliCacheClean2">
<argument name="tags" value=""/>
</actionGroup>

<!-- Open product 1 page and add to cart -->
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProduct1Page2">
<argument name="product" value="$$createProduct1$$"/>
</actionGroup>
<actionGroup ref="StorefrontAddToTheCartActionGroup" stepKey="product1AddToCart2"/>

<!-- Go to shopping cart and assert clear shopping cart button is not rendered in UI -->
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage2"/>
<dontSeeElementInDOM selector="{{CheckoutCartProductSection.emptyCartButton}}" stepKey="dontSeeElementEmptyCartButton"/>
</test>
</tests>

This file was deleted.

0 comments on commit 35a469b

Please sign in to comment.