Skip to content

Commit

Permalink
Merge pull request magento#108 from magento-pangolin/MC-4456
Browse files Browse the repository at this point in the history
MC-4456
  • Loading branch information
tomreece authored Apr 26, 2019
2 parents c5171d6 + a14aec5 commit 7a38191
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
<see selector="{{StorefrontMessagesSection.success}}" userInput="You added {{productName}} to your shopping cart." stepKey="seeAddToCartSuccessMessage"/>
</actionGroup>

<actionGroup name="AddProductWithQtyToCartFromStorefrontProductPage" extends="addToCartFromStorefrontProductPage">
<arguments>
<argument name="productName" type="string"/>
<argument name="productQty" type="string"/>
</arguments>
<fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="{{productQty}}" stepKey="fillProductQuantity" before="addToCart"/>
</actionGroup>

<!--Verify text length validation hint with multiple inputs-->
<actionGroup name="testDynamicValidationHint">
<arguments>
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@
<var key="sku" entityType="product" entityKey="sku" />
<requiredEntity type="product_option">ProductOptionValueDropdown</requiredEntity>
</entity>
<entity name="productWithDropdownAndFieldOptions" type="product">
<var key="sku" entityType="product" entityKey="sku" />
<requiredEntity type="product_option">ProductOptionValueDropdown</requiredEntity>
<requiredEntity type="product_option">ProductOptionField</requiredEntity>
</entity>
<entity name="ProductWithTextFieldAndAreaOptions" type="product">
<var key="sku" entityType="product" entityKey="sku" />
<requiredEntity type="product_option">ProductOptionField</requiredEntity>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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="AssertShoppingCartIsEmptyActionGroup">
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/>
<waitForPageLoad stepKey="waitForCheckoutPageLoad"/>
<see userInput="You have no items in your shopping cart." stepKey="seeNoItemsInShoppingCart"/>
</actionGroup>
</actionGroups>
17 changes: 17 additions & 0 deletions app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,21 @@
<data key="subtotal">1,320.00</data>
<data key="currency">$</data>
</entity>
<entity name="quoteQty2Price123" type="Quote">
<data key="price">123.00</data>
<data key="qty">2</data>
<data key="shipping">10.00</data>
<data key="subtotal">246.00</data>
<data key="total">256.00</data>
<data key="currency">$</data>
</entity>
<entity name="quoteQty2Subtotal266" type="Quote">
<data key="qty">2</data>
<data key="customOptionsPrice">20</data>
<data key="price">143</data>
<data key="subtotal">266.00</data>
<data key="shipping">10.00</data>
<data key="total">276.00</data>
<data key="currency">$</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
<?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="ShoppingCartAndMiniShoppingCartPerCustomerTest">
<annotations>
<features value="Checkout"/>
<stories value="Shopping Cart and Mini Shopping Cart per Customer"/>
<title value="Shopping cart and mini shopping cart per customer test"/>
<description value="Shopping cart and mini shopping cart per customer with enabled cached"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-14730"/>
<group value="checkout"/>
</annotations>
<before>
<!-- Flush cache -->
<magentoCLI command="cache:flush" stepKey="clearCache"/>

<!-- Create two customers -->
<createData entity="Simple_US_Customer" stepKey="createFirstCustomer"/>
<createData entity="Simple_US_CA_Customer" stepKey="createSecondCustomer"/>

<!-- Create products -->
<createData entity="_defaultCategory" stepKey="createCategory"/>

<!-- Create simple product -->
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>

<!-- Create simple product with custom options -->
<createData entity="_defaultProduct" stepKey="createSimpleProductWithCustomOptions">
<requiredEntity createDataKey="createCategory"/>
</createData>
<updateData createDataKey="createSimpleProductWithCustomOptions" entity="productWithDropdownAndFieldOptions" stepKey="updateProductWithCustomOption"/>
</before>
<after>
<!-- Delete products -->
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
<deleteData createDataKey="createSimpleProductWithCustomOptions" stepKey="deleteSimpleProductWithCustomOptions"/>

<!-- Delete category -->
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>

<!-- Delete customers -->
<deleteData createDataKey="createFirstCustomer" stepKey="deleteFirstCustomer"/>
<deleteData createDataKey="createSecondCustomer" stepKey="deleteSecondCustomer"/>
</after>

<!-- Login as first customer -->
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccountAsFirstCustomer">
<argument name="Customer" value="$$createFirstCustomer$$"/>
</actionGroup>

<!-- Assert cart is empty -->
<actionGroup ref="AssertShoppingCartIsEmptyActionGroup" stepKey="seeEmptyShoppingCartForFirstCustomer"/>

<!-- Go to first product page -->
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.custom_attributes[url_key]$$)}}" stepKey="goToFirstProductPage"/>
<waitForPageLoad stepKey="waitForFirstProductPageLoad"/>

<!-- Add the product to the shopping cart -->
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addFirstProductToCart">
<argument name="productName" value="$$createSimpleProduct.name$$"/>
</actionGroup>

<!-- Go to the second product page -->
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProductWithCustomOptions.custom_attributes[url_key]$$)}}" stepKey="goToSecondProductPage"/>
<waitForPageLoad stepKey="waitForSecondProductPageLoad"/>

<!-- Fill the custom options values -->
<actionGroup ref="StorefrontSelectOptionDropDownActionGroup" stepKey="selectFirstOption">
<argument name="optionTitle" value="ProductOptionValueDropdown"/>
<argument name="option" value="ProductOptionValueWithSkuDropdown1.title"/>
</actionGroup>
<fillField selector="{{StorefrontProductInfoMainSection.productOptionFieldInput(ProductOptionField.title)}}" userInput="OptionField" stepKey="fillProductOptionInputField"/>

<!-- Add the product to the shopping cart -->
<actionGroup ref="StorefrontAddToCartCustomOptionsProductPageActionGroup" stepKey="addSecondProductToCart">
<argument name="productName" value="$$createSimpleProductWithCustomOptions.name$$"/>
</actionGroup>

<!-- Logout first customer -->
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="firstCustomerLogout"/>

<!-- Login as second customer -->
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccountAsSecondCustomer">
<argument name="Customer" value="$$createSecondCustomer$$"/>
</actionGroup>

<!-- Assert cart is empty -->
<actionGroup ref="AssertShoppingCartIsEmptyActionGroup" stepKey="seeEmptyShoppingCartForSecondCustomer"/>

<!-- Go to first product page -->
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.custom_attributes[url_key]$$)}}" stepKey="goToProductPage"/>
<waitForPageLoad stepKey="waitForProductPage"/>

<!-- Add the product to the shopping cart -->
<actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPage" stepKey="addProductToCart">
<argument name="productName" value="$$createSimpleProduct.name$$"/>
<argument name="productQty" value="{{quoteQty2Price123.qty}}"/>
</actionGroup>

<!-- Logout second customer -->
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="secondCustomerLogout"/>

<!-- Login as first customer -->
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsFirstCustomer">
<argument name="Customer" value="$$createFirstCustomer$$"/>
</actionGroup>

<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/>
<waitForPageLoad stepKey="waitForCheckoutPageLoad"/>

<!-- Assert first products present in shopping cart -->
<actionGroup ref="StorefrontCheckCartSimpleProductActionGroup" stepKey="checkFirstProductInCart">
<argument name="product" value="$$createSimpleProduct$$"/>
<argument name="productQuantity" value="ApiSimpleSingleQty.quantity"/>
</actionGroup>

<!-- Assert second products present in shopping cart -->
<seeElement selector="{{CheckoutCartProductSection.ProductLinkByName($$createSimpleProductWithCustomOptions.name$$)}}" stepKey="assertProductName"/>
<see selector="{{CheckoutCartProductSection.ProductPriceByName($$createSimpleProductWithCustomOptions.name$$)}}" userInput="{{quoteQty2Subtotal266.currency}}{{quoteQty2Subtotal266.price}}" stepKey="assertProductPrice"/>
<see selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute($$createSimpleProductWithCustomOptions.name$$, ProductOptionField.title)}}" userInput="OptionField" stepKey="seeFieldOption"/>
<see selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute($$createSimpleProductWithCustomOptions.name$$, ProductOptionValueDropdown.title)}}" userInput="{{ProductOptionValueWithSkuDropdown1.title}}" stepKey="seeDropDownOption"/>

<!-- Assert subtotal and grand total -->
<see selector="{{StorefrontProductPageSection.subTotal}}" userInput="{{quoteQty2Subtotal266.currency}}{{quoteQty2Subtotal266.subtotal}}" stepKey="seeFirstCustomerSubTotal"/>
<see selector="{{StorefrontProductPageSection.orderTotal}}" userInput="{{quoteQty2Subtotal266.currency}}{{quoteQty2Subtotal266.total}}" stepKey="seeFirstCustomerOrderTotal"/>

<!-- Assert products in mini cart for first customer -->
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToStoreFrontHomePage"/>
<waitForPageLoad stepKey="waitForHomePageLoad"/>
<actionGroup ref="assertOneProductNameInMiniCart" stepKey="assertFirstProductInMiniCart">
<argument name="productName" value="$$createSimpleProduct.name$$"/>
</actionGroup>
<actionGroup ref="assertOneProductNameInMiniCart" stepKey="assertSecondProductInMiniCart">
<argument name="productName" value="$$createSimpleProductWithCustomOptions.name$$"/>
</actionGroup>
<actionGroup ref="AssertMiniShoppingCartSubTotalActionGroup" stepKey="assertMiniCartSubTotal">
<argument name="dataQuote" value="quoteQty2Subtotal266"/>
</actionGroup>

<!-- Logout first customer -->
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutFirstCustomer"/>

<!-- Login as second customer -->
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsSecondCustomer">
<argument name="Customer" value="$$createSecondCustomer$$"/>
</actionGroup>

<!-- Assert first products present in shopping cart -->
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/>
<waitForPageLoad stepKey="waitForShoppingCartPageLoad"/>
<actionGroup ref="StorefrontCheckCartSimpleProductActionGroup" stepKey="checkProductInCart">
<argument name="product" value="$$createSimpleProduct$$"/>
<argument name="productQuantity" value="quoteQty2Price123.qty"/>
</actionGroup>

<!-- Assert subtotal and grand total -->
<see selector="{{StorefrontProductPageSection.subTotal}}" userInput="{{quoteQty2Price123.currency}}{{quoteQty2Price123.subtotal}}" stepKey="seeSecondCustomerSubTotal"/>
<see selector="{{StorefrontProductPageSection.orderTotal}}" userInput="{{quoteQty2Price123.currency}}{{quoteQty2Price123.total}}" stepKey="seeSecondCustomerOrderTotal"/>

<!-- Assert product in mini cart -->
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToHomePage"/>
<waitForPageLoad stepKey="waitForHomePageToLoad"/>
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/>
<waitForPageLoad stepKey="waitForPageToLoad"/>
<actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertProductInMiniCart">
<argument name="productName" value="$$createSimpleProduct.name$$"/>
<argument name="productPrice" value="$$createSimpleProduct.price$$"/>
<argument name="cartSubtotal" value="{{quoteQty2Price123.currency}}{{quoteQty2Price123.subtotal}}"/>
<argument name="qty" value="{{quoteQty2Price123.qty}}"/>
</actionGroup>

<!-- Logout second customer -->
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutSecondCustomer"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
<testCase name="Magento\Checkout\Test\TestCase\ShoppingCartPerCustomerTest" summary="Shopping Cart and Mini Shopping Cart per Customer with enabled cached" ticketId="MAGETWO-37214">
<variation name="ShoppingCartPerCustomerTestVariation1" summary="Shopping Cart and Mini Shopping Cart per Customer with enabled cached" ticketId="MAGETWO-37214">
<data name="tag" xsi:type="string">mftf_migrated:yes</data>
<data name="productsData/0" xsi:type="string">catalogProductSimple::default</data>
<data name="productsData/1" xsi:type="string">catalogProductSimple::with_two_custom_option</data>
<data name="customerDataset" xsi:type="string">johndoe_unique_firstname</data>
Expand Down

0 comments on commit 7a38191

Please sign in to comment.