|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!-- |
| 3 | +/** |
| 4 | + * Copyright 2025 Adobe |
| 5 | + * All Rights Reserved. |
| 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="StorefrontCartSynchronizationWithMultipleProductChangesTest"> |
| 12 | + <annotations> |
| 13 | + <features value="Checkout"/> |
| 14 | + <stories value="Shopping Cart Synchronization"/> |
| 15 | + <title value="Cart updates with multiple product changes and admin cart management"/> |
| 16 | + <description value="Customer Checkout With multiple products where admin changes product price, stock status, and manages customer cart with Customer Data Lifetime configuration"/> |
| 17 | + <severity value="MAJOR"/> |
| 18 | + <testCaseId value="AC-4303"/> |
| 19 | + <group value="checkout"/> |
| 20 | + </annotations> |
| 21 | + <before> |
| 22 | + <!-- Preconditions 1,2,3: Create 3 Simple products with different prices --> |
| 23 | + <createData entity="SimpleProduct2" stepKey="createSimple1Product"> |
| 24 | + <field key="price">10</field> |
| 25 | + </createData> |
| 26 | + <createData entity="SimpleProduct2" stepKey="createSimple2Product"> |
| 27 | + <field key="price">20</field> |
| 28 | + </createData> |
| 29 | + <createData entity="SimpleProduct2" stepKey="createSimple3Product"> |
| 30 | + <field key="price">30</field> |
| 31 | + </createData> |
| 32 | + <!-- Preconditions 4: Create customer [email protected] --> |
| 33 | + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> |
| 34 | + <!-- Admin login --> |
| 35 | + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> |
| 36 | + </before> |
| 37 | + <after> |
| 38 | + <!-- Reset Customer Data Lifetime to default --> |
| 39 | + <actionGroup ref="SetCustomerDataLifetimeActionGroup" stepKey="resetCustomerDataLifetime"/> |
| 40 | + <!-- Logout customer from storefront --> |
| 41 | + <actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/> |
| 42 | + <!-- Delete test data --> |
| 43 | + <deleteData createDataKey="createSimple1Product" stepKey="deleteSimple1Product"/> |
| 44 | + <deleteData createDataKey="createSimple2Product" stepKey="deleteSimple2Product"/> |
| 45 | + <deleteData createDataKey="createSimple3Product" stepKey="deleteSimple3Product"/> |
| 46 | + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> |
| 47 | + <!-- Admin logout --> |
| 48 | + <actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/> |
| 49 | + </after> |
| 50 | + <!--Flush cache and Reindex--> |
| 51 | + <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> |
| 52 | + <argument name="indices" value=""/> |
| 53 | + </actionGroup> |
| 54 | + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> |
| 55 | + <argument name="tags" value=""/> |
| 56 | + </actionGroup> |
| 57 | + |
| 58 | + <!-- Step 1: Go to Storefront as logged in Customer from preconditions --> |
| 59 | + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefront"> |
| 60 | + <argument name="Customer" value="$createCustomer$"/> |
| 61 | + </actionGroup> |
| 62 | + <!-- Step 2: Add to Shopping Cart next products --> |
| 63 | + <!-- Simple1, qty = 1 --> |
| 64 | + <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="goToSimple1ProductPage"> |
| 65 | + <argument name="product" value="$createSimple1Product$"/> |
| 66 | + </actionGroup> |
| 67 | + <actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addSimple1ToCart"> |
| 68 | + <argument name="productName" value="$createSimple1Product.name$"/> |
| 69 | + </actionGroup> |
| 70 | + <!-- Simple2, qty = 2 --> |
| 71 | + <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="goToSimple2ProductPage"> |
| 72 | + <argument name="product" value="$createSimple2Product$"/> |
| 73 | + </actionGroup> |
| 74 | + <actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPageActionGroup" stepKey="addSimple2ToCart"> |
| 75 | + <argument name="productName" value="$createSimple2Product.name$"/> |
| 76 | + <argument name="productQty" value="2"/> |
| 77 | + </actionGroup> |
| 78 | + <!-- Simple3, qty = 3 --> |
| 79 | + <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="goToSimple3ProductPage"> |
| 80 | + <argument name="product" value="$createSimple3Product$"/> |
| 81 | + </actionGroup> |
| 82 | + <actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPageActionGroup" stepKey="addSimple3ToCart"> |
| 83 | + <argument name="productName" value="$createSimple3Product.name$"/> |
| 84 | + <argument name="productQty" value="3"/> |
| 85 | + </actionGroup> |
| 86 | + <!-- Expected Result: Mini-Cart red icon with number = 6 is shown (1+2+3) --> |
| 87 | + <waitForText userInput="6" selector="{{StorefrontMinicartSection.productCount}}" time="30" stepKey="assertProductCount"/> |
| 88 | + <!-- Verify Mini-Cart has all added products with correct prices --> |
| 89 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCartToVerify"/> |
| 90 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName($createSimple1Product.name$)}}" stepKey="seeSimple1InMiniCart"/> |
| 91 | + <waitForText userInput="$10.00" selector="{{StorefrontMinicartSection.productPriceByName($createSimple1Product.name$)}}" stepKey="seeSimple1InitialPrice"/> |
| 92 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName($createSimple2Product.name$)}}" stepKey="seeSimple2InMiniCart"/> |
| 93 | + <waitForText userInput="$20.00" selector="{{StorefrontMinicartSection.productPriceByName($createSimple2Product.name$)}}" stepKey="seeSimple2InitialPrice"/> |
| 94 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName($createSimple3Product.name$)}}" stepKey="seeSimple3InMiniCart"/> |
| 95 | + <waitForText userInput="$30.00" selector="{{StorefrontMinicartSection.productPriceByName($createSimple3Product.name$)}}" stepKey="seeSimple3InitialPrice"/> |
| 96 | + <!-- Cart Subtotal = 140 (10*1 + 20*2 + 30*3) --> |
| 97 | + <actionGroup ref="AssertStorefrontMiniCartSubtotalActionGroup" stepKey="verifyCartSubtotal"> |
| 98 | + <argument name="subtotal" value="$140.00"/> |
| 99 | + </actionGroup> |
| 100 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="closeMiniCart"/> |
| 101 | + <!-- Step 3: Go to Shopping Cart page --> |
| 102 | + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToShoppingCart"/> |
| 103 | + <!-- Expected Result: Shopping Cart page is opened with all 3 products, Subtotal = 140 --> |
| 104 | + <waitForElementVisible selector="{{CheckoutCartProductSection.ProductLinkByName($createSimple1Product.name$)}}" stepKey="seeSimple1InCart"/> |
| 105 | + <waitForElementVisible selector="{{CheckoutCartProductSection.ProductLinkByName($createSimple2Product.name$)}}" stepKey="seeSimple2InCart"/> |
| 106 | + <waitForElementVisible selector="{{CheckoutCartProductSection.ProductLinkByName($createSimple3Product.name$)}}" stepKey="seeSimple3InCart"/> |
| 107 | + <waitForText userInput="$140.00" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="verifyInitialCartSubtotal"/> |
| 108 | + <!-- Step 4,5: Open Simple1 product and change price to 15 and Save --> |
| 109 | + <openNewTab stepKey="openAdminTab"/> |
| 110 | + <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openSimple1ProductForEdit"> |
| 111 | + <argument name="productId" value="$createSimple1Product.id$"/> |
| 112 | + </actionGroup> |
| 113 | + <fillField userInput="15" selector="{{AdminProductFormSection.productPrice}}" stepKey="changeSimple1PriceToFifteen"/> |
| 114 | + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveSimple1ProductWithNewPrice"/> |
| 115 | + <!-- Step 6: Open Simple2 product and change Stock Status to Out of Stock and Save --> |
| 116 | + <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openSimple2ProductForEdit"> |
| 117 | + <argument name="productId" value="$createSimple2Product.id$"/> |
| 118 | + </actionGroup> |
| 119 | + <actionGroup ref="AdminSetStockStatusActionGroup" stepKey="setSimple2OutOfStock"> |
| 120 | + <argument name="stockStatus" value="Out of Stock"/> |
| 121 | + </actionGroup> |
| 122 | + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveSimple2ProductWithOutOfStock"/> |
| 123 | + <!-- Step 7: Go to Customers > All Customers and open Customer for edit --> |
| 124 | + <actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="openCustomerEditPage"> |
| 125 | + <argument name="customerId" value="$createCustomer.id$"/> |
| 126 | + </actionGroup> |
| 127 | + <!-- Step 8: Click Manage Shopping Cart --> |
| 128 | + <click selector="{{AdminCustomerMainActionsSection.manageShoppingCart}}" stepKey="clickManageShoppingCart"/> |
| 129 | + <waitForPageLoad stepKey="waitForManageCartPageLoad"/> |
| 130 | + <!-- Step 9: Change quantity for Simple3 product and Update Items and Quantities --> |
| 131 | + <!-- Set Simple3 qty = 2 and update cart --> |
| 132 | + <actionGroup ref="AdminUpdateProductQtyCustomerManageShoppingCartActionGroup" stepKey="updateSimple3QuantityAndUpdate"> |
| 133 | + <argument name="productQty" value="2"/> |
| 134 | + <argument name="productSku" value="$createSimple3Product.sku$"/> |
| 135 | + </actionGroup> |
| 136 | + <!-- Step 10: Go to Stores > Configuration > Customers > Customer Configuration Tab Online Customer Options and change Customer Data Lifetime to 1 --> |
| 137 | + <actionGroup ref="SetCustomerDataLifetimeActionGroup" stepKey="setCustomerDataLifetimeToOneMinute"> |
| 138 | + <argument name="minutes" value="1"/> |
| 139 | + </actionGroup> |
| 140 | + <!-- Step 11: Save and Flush cache if required --> |
| 141 | + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushConfigCache"> |
| 142 | + <argument name="tags" value="config"/> |
| 143 | + </actionGroup> |
| 144 | + <!-- Step 12: Go back to Storefront on Shopping Cart page --> |
| 145 | + <switchToPreviousTab stepKey="switchBackToStorefront"/> |
| 146 | + <!-- Step 13: Wait 1 min and refresh page --> |
| 147 | + <wait time="65" stepKey="waitOneMinuteForDataLifetimeExpiration"/> |
| 148 | + <actionGroup ref="ReloadPageActionGroup" stepKey="refreshCartPage"/> |
| 149 | + <waitForPageLoad stepKey="waitForCartPageReload"/> |
| 150 | + <!-- Expected Results Verification --> |
| 151 | + <!-- Mini-Cart has 5 items (1 + 1 + 3) - Simple2 qty should be 1 because it's out of stock --> |
| 152 | + <waitForText userInput="5" selector="{{StorefrontMinicartSection.productCount}}" time="30" stepKey="assertUpdatedMiniCartItemCount"/> |
| 153 | + <!-- Verify Mini-Cart product details --> |
| 154 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openUpdatedMiniCart"/> |
| 155 | + <!-- Simple1: qty = 1, price = 15 --> |
| 156 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName($createSimple1Product.name$)}}" stepKey="seeUpdatedSimple1InMiniCart"/> |
| 157 | + <seeInField userInput="1" selector="{{StorefrontMinicartSection.itemQuantity($createSimple1Product.name$)}}" stepKey="seeSimple1UpdatedQtyInMiniCart"/> |
| 158 | + <waitForText userInput="$15.00" selector="{{StorefrontMinicartSection.productPriceByName($createSimple1Product.name$)}}" stepKey="seeSimple1UpdatedPriceInMiniCart"/> |
| 159 | + <!-- Simple2: qty = 2, price = 20 (out of stock) --> |
| 160 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName($createSimple2Product.name$)}}" stepKey="seeUpdatedSimple2InMiniCart"/> |
| 161 | + <seeInField userInput="2" selector="{{StorefrontMinicartSection.itemQuantity($createSimple2Product.name$)}}" stepKey="seeSimple2UpdatedQtyInMiniCart"/> |
| 162 | + <waitForText userInput="$20.00" selector="{{StorefrontMinicartSection.productPriceByName($createSimple2Product.name$)}}" stepKey="seeSimple2PriceInMiniCart"/> |
| 163 | + <!-- Simple3: qty = 2, price = 30 --> |
| 164 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName($createSimple3Product.name$)}}" stepKey="seeUpdatedSimple3InMiniCart"/> |
| 165 | + <seeInField userInput="2" selector="{{StorefrontMinicartSection.itemQuantity($createSimple3Product.name$)}}" stepKey="seeSimple3UpdatedQtyInMiniCart"/> |
| 166 | + <waitForText userInput="$30.00" selector="{{StorefrontMinicartSection.productPriceByName($createSimple3Product.name$)}}" stepKey="seeSimple3PriceInMiniCart"/> |
| 167 | + <!-- Cart Subtotal = 115 (15*1 + 20*2 + 30*2) --> |
| 168 | + <waitForText userInput="$115.00" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="verifyUpdatedMiniCartSubtotal"/> |
| 169 | + <waitForElementNotVisible selector="{{StorefrontMinicartSection.proceedToCheckout}}" stepKey="verifyCheckoutButtonNotVisibleInMiniCart"/> |
| 170 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="closeUpdatedMiniCart"/> |
| 171 | + <!-- On Shopping Cart page: Verify "Some of the products are out of stock" message --> |
| 172 | + <waitForText userInput="Some of the products are out of stock." selector="{{CheckoutCartMessageSection.errorMessage}}" stepKey="verifyOutOfStockHeaderMessage"/> |
| 173 | + <!-- Verify Simple2 has specific out of stock message --> |
| 174 | + <waitForText userInput="Product $createSimple2Product.name$ is out of stock." selector="{{CheckoutCartProductSection.ProductErrorMessageByName($createSimple2Product.name$)}}" stepKey="verifySimple2OutOfStockMessage"/> |
| 175 | + <!-- Verify all product quantities and prices are updated as in MiniCart --> |
| 176 | + <!-- Simple1: qty = 1, price = 15 --> |
| 177 | + <seeInField userInput="1" selector="{{CheckoutCartProductSection.ProductQuantityByName($createSimple1Product.name$)}}" stepKey="verifySimple1UpdatedQuantity"/> |
| 178 | + <waitForText userInput="$15.00" selector="{{CheckoutCartProductSection.ProductPriceByName($$createSimple1Product.name$$)}}" stepKey="verifySimple1UpdatedPriceInCart"/> |
| 179 | + <!-- Simple2: qty = 2, price = 20 --> |
| 180 | + <seeInField userInput="2" selector="{{CheckoutCartProductSection.ProductQuantityByName($createSimple2Product.name$)}}" stepKey="verifySimple2UpdatedQuantity"/> |
| 181 | + <waitForText userInput="$20.00" selector="{{CheckoutCartProductSection.ProductPriceByName($createSimple2Product.name$)}}" stepKey="verifySimple2PriceInCart"/> |
| 182 | + <!-- Simple3: qty = 2, price = 30 --> |
| 183 | + <seeInField userInput="2" selector="{{CheckoutCartProductSection.ProductQuantityByName($createSimple3Product.name$)}}" stepKey="verifySimple3UpdatedQuantity"/> |
| 184 | + <waitForText userInput="$30.00" selector="{{CheckoutCartProductSection.ProductPriceByName($createSimple3Product.name$)}}" stepKey="verifySimple3PriceInCart"/> |
| 185 | + <!-- Subtotal = 115 --> |
| 186 | + <waitForText userInput="$115.00" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="verifyFinalCartSubtotal"/> |
| 187 | + </test> |
| 188 | +</tests> |
0 commit comments