From 5838c555ef4ff07f9d0d811c959fe240cee18c5e Mon Sep 17 00:00:00 2001 From: Maria Kovdrysh Date: Wed, 24 Apr 2019 15:36:37 -0500 Subject: [PATCH] MC-4456: Convert ShoppingCartPerCustomerTest to MFTF --- .../StorefrontProductPageActionGroup.xml | 8 + .../Catalog/Test/Mftf/Data/ProductData.xml | 5 + .../AssertShoppingCartIsEmptyActionGroup.xml | 15 ++ .../Checkout/Test/Mftf/Data/QuoteData.xml | 17 ++ ...CartAndMiniShoppingCartPerCustomerTest.xml | 185 ++++++++++++++++++ .../TestCase/ShoppingCartPerCustomerTest.xml | 1 + 6 files changed, 231 insertions(+) create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertShoppingCartIsEmptyActionGroup.xml create mode 100644 app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontProductPageActionGroup.xml index 82042975d5fb8..8e0ef3ccbcf28 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontProductPageActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontProductPageActionGroup.xml @@ -19,6 +19,14 @@ + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml index fcfca073cb484..b875249a95ba5 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml @@ -472,6 +472,11 @@ ProductOptionValueDropdown + + + ProductOptionValueDropdown + ProductOptionField + ProductOptionField diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertShoppingCartIsEmptyActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertShoppingCartIsEmptyActionGroup.xml new file mode 100644 index 0000000000000..d71832c63cb18 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertShoppingCartIsEmptyActionGroup.xml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml b/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml index e7a5992ad8943..7c4f814e2b977 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml @@ -37,4 +37,21 @@ 1,320.00 $ + + 123.00 + 2 + 10.00 + 246.00 + 256.00 + $ + + + 2 + 20 + 143 + 266.00 + 10.00 + 276.00 + $ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml new file mode 100644 index 0000000000000..84cdb8abd9344 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml @@ -0,0 +1,185 @@ + + + + + + + + + + <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> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPerCustomerTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPerCustomerTest.xml index abdcfc2de335e..cd6a9559e31df 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPerCustomerTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPerCustomerTest.xml @@ -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>