Skip to content

Commit e91cff3

Browse files
committed
Convert UpdateShoppingCartTest to MFTF
1 parent e457037 commit e91cff3

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,11 @@
386386
<var key="sku" entityType="product" entityKey="sku" />
387387
<requiredEntity type="product_option">ProductOptionDropDownWithLongValuesTitle</requiredEntity>
388388
</entity>
389+
<entity name="productWithOptions3" type="product">
390+
<var key="sku" entityType="product" entityKey="sku" />
391+
<requiredEntity type="product_option">ProductOptionField</requiredEntity>
392+
<requiredEntity type="product_option">ProductOptionArea</requiredEntity>
393+
</entity>
389394
<entity name="ApiVirtualProductWithDescription" type="product">
390395
<data key="sku" unique="suffix">api-virtual-product</data>
391396
<data key="type_id">virtual</data>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<element name="ProductPriceByName" type="text"
1616
selector="//main//table[@id='shopping-cart-table']//tbody//tr[..//strong[contains(@class, 'product-item-name')]//a/text()='{{var1}}'][1]//td[contains(@class, 'price')]//span[@class='price']"
1717
parameterized="true"/>
18+
<element name="ProductSubtotalByName" type="text"
19+
selector="//main//table[@id='shopping-cart-table']//tbody//tr[..//strong[contains(@class, 'product-item-name')]//a/text()='{{var1}}'][1]//td[contains(@class, 'subtotal')]//span[@class='price']"
20+
parameterized="true"/>
1821
<element name="ProductImageByName" type="text"
1922
selector="//main//table[@id='shopping-cart-table']//tbody//tr//img[contains(@class, 'product-image-photo') and @alt='{{var1}}']"
2023
parameterized="true"/>
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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="UpdateShoppingCartTestVariation1">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<title value="Check updating shopping cart while updating items qty"/>
15+
<description value="Check updating shopping cart while updating items qty"/>
16+
<group value="shoppingCart"/>
17+
<group value="mtf_migrated"/>
18+
</annotations>
19+
<before>
20+
<createData entity="_defaultCategory" stepKey="createCategory"/>
21+
<createData entity="SimpleProduct" stepKey="createProduct">
22+
<requiredEntity createDataKey="createCategory"/>
23+
<field key="price">100</field>
24+
</createData>
25+
26+
<!-- Add the newly created product to the shopping cart -->
27+
<amOnPage url="$$createProduct.custom_attributes[url_key]$$.html" stepKey="navigateToSimpleProductPage"/>
28+
<waitForPageLoad stepKey="waitForCatalogPageLoad1"/>
29+
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProductPage1">
30+
<argument name="productName" value="$$createProduct.name$$"/>
31+
</actionGroup>
32+
</before>
33+
<after>
34+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
35+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
36+
</after>
37+
38+
<!-- Go to the shopping cart -->
39+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/>
40+
<waitForPageLoad stepKey="waitForCheckoutPageLoad1"/>
41+
42+
<!-- Change the product QTY -->
43+
<fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="3" stepKey="changeCartQty"/>
44+
<click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="openShoppingCart"/>
45+
<waitForPageLoad stepKey="waitForCheckoutPageLoad2"/>
46+
47+
<!-- The price and QTY values should be updated for the product -->
48+
<grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/>
49+
<see userInput="$300" selector="{{CheckoutCartProductSection.ProductSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/>
50+
<assertEquals expected="3" actual="$grabProductQtyInCart" stepKey="assertProductQtyInCart"/>
51+
52+
<!-- Subtotal should be updated -->
53+
<see userInput="$300" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertCartSubtotal"/>
54+
55+
<!-- Minicart product price and subtotal should be updated -->
56+
<actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="openMinicart"/>
57+
<grabValueFrom selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" stepKey="grabProductQtyInMinicart"/>
58+
<assertEquals expected="3" actual="$grabProductQtyInMinicart" stepKey="assertProductQtyInMinicart"/>
59+
<see userInput="$300" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/>
60+
</test>
61+
<test name="UpdateShoppingCartTestVariation2">
62+
<annotations>
63+
<features value="Checkout"/>
64+
<title value="Check updating shopping cart while updating qty of items with custom options"/>
65+
<description value="Check updating shopping cart while updating qty of items with custom options"/>
66+
<group value="shoppingCart"/>
67+
<group value="mtf_migrated"/>
68+
</annotations>
69+
<before>
70+
<createData entity="_defaultCategory" stepKey="createCategory"/>
71+
<createData entity="SimpleProduct" stepKey="createProduct">
72+
<requiredEntity createDataKey="createCategory"/>
73+
<field key="price">100</field>
74+
</createData>
75+
76+
<!-- Add two custom options to the product: field and textarea -->
77+
<updateData createDataKey="createProduct" entity="productWithOptions3" stepKey="updateProductWithOption"/>
78+
79+
<!-- Go to the product page, fill the custom options values and add the product to the shopping cart -->
80+
<amOnPage url="{{StorefrontHomePage.url}}$createProduct.custom_attributes[url_key]$.html" stepKey="amOnProductPage"/>
81+
<waitForPageLoad stepKey="waitForCatalogPageLoad"/>
82+
<fillField userInput="OptionField" selector="{{StorefrontProductInfoMainSection.productOptionFieldInput(ProductOptionField.title)}}" stepKey="fillProductOptionInputField"/>
83+
<fillField userInput="OptionArea" selector="{{StorefrontProductInfoMainSection.productOptionAreaInput(ProductOptionArea.title)}}" stepKey="fillProductOptionInputArea"/>
84+
<actionGroup ref="StorefrontAddToCartCustomOptionsProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage">
85+
<argument name="productName" value="$createProduct.name$"/>
86+
</actionGroup>
87+
</before>
88+
<after>
89+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
90+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
91+
</after>
92+
93+
<!-- Go to the shopping cart -->
94+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/>
95+
<waitForPageLoad stepKey="waitForCheckoutPageLoad1"/>
96+
97+
<!-- Change the product QTY -->
98+
<fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="11" stepKey="changeCartQty"/>
99+
<click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="openShoppingCart"/>
100+
<waitForPageLoad stepKey="waitForCheckoutPageLoad2"/>
101+
102+
<!-- The price and QTY values should be updated for the product -->
103+
<grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/>
104+
<see userInput="$1,320.00" selector="{{CheckoutCartProductSection.ProductSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/>
105+
<assertEquals expected="11" actual="$grabProductQtyInCart" stepKey="assertProductQtyInCart"/>
106+
<see userInput="$1,320.00" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertSubtotal"/>
107+
108+
<!-- Minicart product price and subtotal should be updated -->
109+
<actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="openMinicart"/>
110+
<grabValueFrom selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" stepKey="grabProductQtyInMinicart"/>
111+
<assertEquals expected="11" actual="$grabProductQtyInMinicart" stepKey="assertProductQtyInMinicart"/>
112+
<see userInput="1,320.00" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/>
113+
</test>
114+
</tests>

0 commit comments

Comments
 (0)