|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!-- |
| 3 | + /** |
| 4 | + * Copyright 2025 Adobe |
| 5 | + * All Rights Reserved. |
| 6 | + */ |
| 7 | +--> |
| 8 | +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 9 | + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> |
| 10 | + <test name="StorefrontCartSidebarSynchronizationWithCustomerDataLifetimeTest"> |
| 11 | + <annotations> |
| 12 | + <features value="Checkout"/> |
| 13 | + <stories value="Cart Sidebar Synchronization"/> |
| 14 | + <title value="Cart sidebar synchronization with Customer Data Lifetime and product changes"/> |
| 15 | + <description value="Verify cart sidebar shows cached values until Customer Data Lifetime expires or cart is updated, with multi-tab admin product changes"/> |
| 16 | + <severity value="MAJOR"/> |
| 17 | + <testCaseId value="AC-4753"/> |
| 18 | + <group value="checkout"/> |
| 19 | + </annotations> |
| 20 | + <before> |
| 21 | + <!-- Create Simple product with price $10 --> |
| 22 | + <createData entity="SimpleProduct2" stepKey="createSimpleProduct"> |
| 23 | + <field key="name">Apple</field> |
| 24 | + <field key="price">10</field> |
| 25 | + </createData> |
| 26 | + <!-- Create customer account --> |
| 27 | + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> |
| 28 | + <!-- Admin login --> |
| 29 | + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> |
| 30 | + <!-- Set Customer Data Lifetime to 2 minutes --> |
| 31 | + <actionGroup ref="SetCustomerDataLifetimeActionGroup" stepKey="setCustomerDataLifetimeToTwoMinutes"> |
| 32 | + <argument name="minutes" value="2"/> |
| 33 | + </actionGroup> |
| 34 | + </before> |
| 35 | + <after> |
| 36 | + <!-- Reset Customer Data Lifetime to default --> |
| 37 | + <actionGroup ref="SetCustomerDataLifetimeActionGroup" stepKey="resetCustomerDataLifetime"/> |
| 38 | + <!-- Logout customer --> |
| 39 | + <actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/> |
| 40 | + <!-- Delete test data --> |
| 41 | + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> |
| 42 | + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> |
| 43 | + <!-- Admin logout --> |
| 44 | + <actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/> |
| 45 | + </after> |
| 46 | + <!-- Step 1: Open browser tab A - Login to storefront, open simple product page and add to cart --> |
| 47 | + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontTabA"> |
| 48 | + <argument name="Customer" value="$createCustomer$"/> |
| 49 | + </actionGroup> |
| 50 | + <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openSimpleProductPage"> |
| 51 | + <argument name="product" value="$createSimpleProduct$"/> |
| 52 | + </actionGroup> |
| 53 | + <actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addSimpleProductToCart"> |
| 54 | + <argument name="productName" value="$createSimpleProduct.name$"/> |
| 55 | + </actionGroup> |
| 56 | + <!-- Step 2: Reload product page several times to validate caching --> |
| 57 | + <actionGroup ref="ReloadPageActionGroup" stepKey="reloadProductPageFirst"/> |
| 58 | + <waitForPageLoad stepKey="waitForFirstReload"/> |
| 59 | + <actionGroup ref="ReloadPageActionGroup" stepKey="reloadProductPageSecond"/> |
| 60 | + <waitForPageLoad stepKey="waitForSecondReload"/> |
| 61 | + <actionGroup ref="ReloadPageActionGroup" stepKey="reloadProductPageThird"/> |
| 62 | + <waitForPageLoad stepKey="waitForThirdReload"/> |
| 63 | + <!-- Step 3: Open Cart Sidebar (minicart) and verify initial values --> |
| 64 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openCartSidebarInitial"/> |
| 65 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName($createSimpleProduct.name$)}}" stepKey="waitForAppleProductInMiniCart"/> |
| 66 | + <waitForText userInput="$10.00" selector="{{StorefrontMinicartSection.productPriceByName($createSimpleProduct.name$)}}" stepKey="verifyInitialProductPrice"/> |
| 67 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="closeCartSidebarInitial"/> |
| 68 | + <!-- Step 4: Open additional browser tab B - Admin product changes --> |
| 69 | + <openNewTab stepKey="openAdminTabB"/> |
| 70 | + <!-- Navigate to admin product edit page --> |
| 71 | + <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openAppleProductForFirstEdit"> |
| 72 | + <argument name="productId" value="$createSimpleProduct.id$"/> |
| 73 | + </actionGroup> |
| 74 | + <!-- Change product name to Apple-X and price to $20 --> |
| 75 | + <fillField userInput="Apple-X" selector="{{AdminProductFormSection.productName}}" stepKey="changeProductNameToAppleX"/> |
| 76 | + <fillField userInput="20" selector="{{AdminProductFormSection.productPrice}}" stepKey="changeProductPriceTo20"/> |
| 77 | + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductWithFirstChanges"/> |
| 78 | + <!-- Step 5: Return to browser tab A - Storefront --> |
| 79 | + <switchToPreviousTab stepKey="switchBackToStorefrontTabA"/> |
| 80 | + <!-- Reload product page and open Cart Sidebar --> |
| 81 | + <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openSimpleProductPageAfterFirstAdminChange"> |
| 82 | + <argument name="product" value="$createSimpleProduct$"/> |
| 83 | + </actionGroup> |
| 84 | + <actionGroup ref="ReloadPageActionGroup" stepKey="reloadProductPageAfterFirstAdminChange"/> |
| 85 | + <waitForPageLoad stepKey="waitForReloadAfterFirstChange"/> |
| 86 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openCartSidebarAfterFirstChange"/> |
| 87 | + <!-- Verify Cart Sidebar still shows OLD values (cached) --> |
| 88 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName('Apple')}}" stepKey="verifyProductNameStillApple"/> |
| 89 | + <waitForText userInput="$10.00" selector="{{StorefrontMinicartSection.productPriceByName('Apple')}}" stepKey="verifyProductPriceStill10"/> |
| 90 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="closeCartSidebarAfterFirstChange"/> |
| 91 | + <!-- Step 6: Open Shopping Cart and update quantity to 3 --> |
| 92 | + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage"/> |
| 93 | + <waitForElementVisible selector="{{CheckoutCartProductSection.ProductQuantityByName('Apple-X')}}" stepKey="waitForQuantityField"/> |
| 94 | + <clearField selector="{{CheckoutCartProductSection.ProductQuantityByName('Apple-X')}}" stepKey="clearQuantityField"/> |
| 95 | + <fillField userInput="3" selector="{{CheckoutCartProductSection.ProductQuantityByName('Apple-X')}}" stepKey="updateQuantityToThree"/> |
| 96 | + <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="clickUpdateShoppingCart"/> |
| 97 | + <waitForPageLoad stepKey="waitForCartUpdate"/> |
| 98 | + <!-- Step 7: Open Cart Sidebar and verify it shows UPDATED values --> |
| 99 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openCartSidebarAfterQuantityUpdate"/> |
| 100 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName('Apple-X')}}" stepKey="verifyProductNameUpdatedToAppleX"/> |
| 101 | + <waitForText userInput="$20.00" selector="{{StorefrontMinicartSection.productPriceByName('Apple-X')}}" stepKey="verifyProductPriceUpdatedTo20"/> |
| 102 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="closeCartSidebarAfterQuantityUpdate"/> |
| 103 | + <!-- Step 8: Reload page several times to validate caching again --> |
| 104 | + <actionGroup ref="ReloadPageActionGroup" stepKey="reloadCartPageFirst"/> |
| 105 | + <waitForPageLoad stepKey="waitForFirstCartReload"/> |
| 106 | + <actionGroup ref="ReloadPageActionGroup" stepKey="reloadCartPageSecond"/> |
| 107 | + <waitForPageLoad stepKey="waitForSecondCartReload"/> |
| 108 | + <!-- Step 9: Open browser tab B - Second admin product change --> |
| 109 | + <openNewTab stepKey="openAdminTabBSecond"/> |
| 110 | + <!-- Navigate to admin product edit page again --> |
| 111 | + <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openAppleProductForSecondEdit"> |
| 112 | + <argument name="productId" value="$createSimpleProduct.id$"/> |
| 113 | + </actionGroup> |
| 114 | + <!-- Change product name to Apple-X-Y and price to $30 --> |
| 115 | + <fillField userInput="Apple-X-Y" selector="{{AdminProductFormSection.productName}}" stepKey="changeProductNameToAppleXY"/> |
| 116 | + <fillField userInput="30" selector="{{AdminProductFormSection.productPrice}}" stepKey="changeProductPriceTo30"/> |
| 117 | + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductWithSecondChanges"/> |
| 118 | + <!-- Step 10: Return to browser tab A - Storefront --> |
| 119 | + <switchToPreviousTab stepKey="switchBackToStorefrontTabASecond"/> |
| 120 | + <!-- Reload product page and open Cart Sidebar --> |
| 121 | + <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openSimpleProductPageAfterSecondAdminChange"> |
| 122 | + <argument name="product" value="$createSimpleProduct$"/> |
| 123 | + </actionGroup> |
| 124 | + <actionGroup ref="ReloadPageActionGroup" stepKey="reloadProductPageAfterSecondAdminChange"/> |
| 125 | + <waitForPageLoad stepKey="waitForReloadAfterSecondChange"/> |
| 126 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openCartSidebarAfterSecondChange"/> |
| 127 | + <!-- Verify Cart Sidebar still shows PREVIOUS values (Apple-X, $20) - cached --> |
| 128 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName('Apple-X')}}" stepKey="verifyProductNameStillAppleX"/> |
| 129 | + <waitForText userInput="$20.00" selector="{{StorefrontMinicartSection.productPriceByName('Apple-X')}}" stepKey="verifyProductPriceStill20"/> |
| 130 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="closeCartSidebarAfterSecondChange"/> |
| 131 | + <!-- Step 11: Wait 2 minutes for Customer Data Lifetime --> |
| 132 | + <wait time="120" stepKey="waitTwoMinutesForDataLifetimeExpiration"/> |
| 133 | + <!-- Step 12: Reload page and verify Cart Sidebar shows UPDATED values --> |
| 134 | + <actionGroup ref="ReloadPageActionGroup" stepKey="reloadPageAfterDataLifetimeExpiration"/> |
| 135 | + <waitForPageLoad stepKey="waitForReloadAfterExpiration"/> |
| 136 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openCartSidebarAfterExpiration"/> |
| 137 | + <!-- Verify Cart Sidebar now shows LATEST values (Apple-X-Y, $30) --> |
| 138 | + <waitForElementVisible selector="{{StorefrontMinicartSection.productLinkByName('Apple-X-Y')}}" stepKey="verifyProductNameUpdatedToAppleXY"/> |
| 139 | + <waitForText userInput="$30.00" selector="{{StorefrontMinicartSection.productPriceByName('Apple-X-Y')}}" stepKey="verifyProductPriceUpdatedTo30"/> |
| 140 | + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="closeCartSidebarFinal"/> |
| 141 | + </test> |
| 142 | +</tests> |
0 commit comments