Skip to content

Commit a647220

Browse files
ENGCOM-9322: Replace repetitive actions with Action Groups in AdminAddInStockProductToTheCartTest #34298
- Merge Pull Request #34298 from kate-kyzyma/magento2:Refactoring-AdminAddInStockProductToTheCartTest - Merged commits: 1. 90e3b3a 2. 8710edf 3. a3479ea 4. a1290c6 5. f548447
2 parents a6f7022 + f548447 commit a647220

File tree

1 file changed

+64
-28
lines changed

1 file changed

+64
-28
lines changed

app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml

Lines changed: 64 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,50 +39,86 @@
3939
<argument name="product" value="SimpleProduct"/>
4040
</actionGroup>
4141
<!-- Update product Advanced Inventory setting -->
42-
<click stepKey="openSelectedProduct" selector="{{AdminProductGridSection.productRowBySku($$createSimpleProduct.sku$$)}}"/>
43-
<waitForPageLoad stepKey="waitForProductToLoad"/>
42+
<actionGroup ref="AdminProductGridSectionClickFirstRowActionGroup" stepKey="openSelectedProduct"/>
43+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForProductToLoad"/>
4444
<actionGroup ref="AdminClickOnAdvancedInventoryLinkActionGroup" stepKey="clickOnAdvancedInventoryLink"/>
45-
<uncheckOption selector="{{AdminProductFormAdvancedInventorySection.useConfigSettings}}" stepKey="uncheckConfigSetting"/>
46-
<selectOption selector="{{AdminProductFormAdvancedInventorySection.manageStock}}" userInput="Yes" stepKey="clickOnManageStock"/>
47-
<fillField selector="{{AdminProductFormAdvancedInventorySection.advancedInventoryQty}}" userInput="5" stepKey="fillProductQty"/>
48-
<uncheckOption selector="{{AdminProductFormAdvancedInventorySection.miniQtyConfigSetting}}" stepKey="uncheckMiniQtyCheckBox"/>
49-
<fillField selector="{{AdminProductFormAdvancedInventorySection.miniQtyAllowedInCart}}" userInput="1" stepKey="fillMiniAllowedQty"/>
50-
<uncheckOption selector="{{AdminProductFormAdvancedInventorySection.maxiQtyConfigSetting}}" stepKey="uncheckMaxQtyCheckBox"/>
51-
<fillField selector="{{AdminProductFormAdvancedInventorySection.maxiQtyAllowedInCart}}" userInput="10000" stepKey="fillMaxAllowedQty"/>
52-
<selectOption selector="{{AdminProductFormAdvancedInventorySection.qtyUsesDecimals}}" userInput="Yes" stepKey="selectQuatityUsesDecimal"/>
53-
<uncheckOption selector="{{AdminProductFormAdvancedInventorySection.notifyBelowQtyConfigSetting}}" stepKey="uncheckNotifyBelowQtyheckBox"/>
54-
<fillField selector="{{AdminProductFormAdvancedInventorySection.notifyBelowQty}}" userInput="1" stepKey="fillNotifyBelowQty"/>
45+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="uncheckConfigSetting"/>
46+
<actionGroup ref="AdminSetManageStockConfigActionGroup" stepKey="clickOnManageStock">
47+
<argument name="value" value="Yes"/>
48+
</actionGroup>
49+
<actionGroup ref="AdminFillAdvancedInventoryQtyActionGroup" stepKey="fillProductQty">
50+
<argument name="qty" value="5"/>
51+
</actionGroup>
52+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="uncheckMiniQtyCheckBox"/>
53+
<actionGroup ref="AdminSetMinAllowedQtyForProductActionGroup" stepKey="fillMiniAllowedQty">
54+
<argument name="qty" value="1"/>
55+
</actionGroup>
56+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="uncheckMaxQtyCheckBox"/>
57+
<actionGroup ref="AdminSetMaxAllowedQtyForProductActionGroup" stepKey="fillMaxAllowedQty">
58+
<argument name="qty" value="1000"/>
59+
</actionGroup>
60+
<actionGroup ref="AdminSetQtyUsesDecimalsConfigActionGroup" stepKey="selectQuatityUsesDecimal">
61+
<argument name="value" value="Yes"/>
62+
</actionGroup>
63+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="uncheckNotifyBelowQtyheckBox"/>
64+
<actionGroup ref="AdminSetNotifyBelowQtyValueActionGroup" stepKey="fillNotifyBelowQty">
65+
<argument name="qty" value="1"/>
66+
</actionGroup>
5567
<actionGroup ref="AdminSetStockStatusConfigActionGroup" stepKey="selectOutOfStock">
5668
<argument name="stockStatus" value="In Stock"/>
5769
</actionGroup>
5870
<actionGroup ref="AdminSubmitAdvancedInventoryFormActionGroup" stepKey="clickOnDoneButton"/>
5971
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="clickOnSaveButton"/>
60-
<see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the product." stepKey="messageYouSavedTheProductIsShown"/>
72+
<actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="messageYouSavedTheProductIsShown">
73+
<argument name="message" value="You saved the product."/>
74+
</actionGroup>
6175
<comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/>
6276
<comment userInput="Adding the comment to replace CliCacheFlushActionGroup action group ('cache:flush' command) for preserving Backward Compatibility" stepKey="flushCache"/>
6377
<!--Verify product is visible in category front page -->
64-
<amOnPage url="$$createCategory.custom_attributes[url_key]$$.html" stepKey="openCategoryStoreFrontPage"/>
65-
<waitForPageLoad stepKey="waitForCategoryPageToLoad"/>
66-
<seeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleSubCategory.name)}}" stepKey="seeCategoryInFrontPage"/>
78+
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="openCategoryStoreFrontPage">
79+
<argument name="category" value="$createCategory$"/>
80+
</actionGroup>
81+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCategoryPageToLoad"/>
82+
<actionGroup ref="StorefrontAssertCategoryNameIsShownInMenuActionGroup" stepKey="seeCategoryInFrontPage">
83+
<argument name="categoryName" value="{{SimpleSubCategory.name}}"/>
84+
</actionGroup>
6785
<click selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleSubCategory.name)}}" stepKey="clickOnCategory"/>
68-
<see selector="{{StorefrontCategoryMainSection.productName}}" userInput="{{SimpleProduct.name}}" stepKey="seeProductNameInCategoryPage"/>
86+
<actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="seeProductNameInCategoryPage">
87+
<argument name="productName" value="{{SimpleProduct.name}}"/>
88+
</actionGroup>
6989
<!--Verify Product In Store Front-->
70-
<amOnPage url="$$createSimpleProduct.custom_attributes[url_key]$$.html" stepKey="goToStorefrontPage"/>
71-
<waitForPageLoad stepKey="waitForProductFrontPageToLoad"/>
72-
<see selector="{{StorefrontProductInfoMainSection.productName}}" userInput="{{SimpleProduct.name}}" stepKey="seeProductNameInStoreFront"/>
73-
<see selector="{{StorefrontProductInfoMainSection.productPrice}}" userInput="{{SimpleProduct.price}}" stepKey="seeProductPriceInStoreFront"/>
90+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="goToStorefrontPage">
91+
<argument name="product" value="$createSimpleProduct$"/>
92+
</actionGroup>
93+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForProductFrontPageToLoad"/>
94+
<actionGroup ref="StorefrontAssertProductNameOnProductPageActionGroup" stepKey="seeProductNameInStoreFront">
95+
<argument name="productName" value="{{SimpleProduct.name}}"/>
96+
</actionGroup>
97+
<actionGroup ref="StorefrontAssertProductPriceOnProductPageActionGroup" stepKey="seeProductPriceInStoreFront">
98+
<argument name="productPrice" value="{{SimpleProduct.price}}"/>
99+
</actionGroup>
74100
<actionGroup ref="StorefrontAssertProductSkuOnProductPageActionGroup" stepKey="seeProductSkuInStoreFront">
75101
<argument name="productSku" value="{{SimpleProduct.sku}}"/>
76102
</actionGroup>
77-
<see selector="{{StorefrontProductInfoMainSection.productStockStatus}}" userInput="In Stock" stepKey="seeProductStatusInStoreFront"/>
103+
<actionGroup ref="StorefrontCheckProductStockStatus" stepKey="seeProductStatusInStoreFront">
104+
<argument name="productUrlKey" value="$$createSimpleProduct.custom_attributes[url_key]$$"/>
105+
<argument name="productName" value="$createSimpleProduct.name$"/>
106+
</actionGroup>
78107
<!--Add Product to the cart-->
79-
<fillField selector="{{StorefrontProductPageSection.qtyInput}}" userInput="1" stepKey="fillProductQuantity"/>
80-
<actionGroup ref="StorefrontClickAddToCartOnProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage"/>
81-
<seeElement selector="{{StorefrontProductPageSection.successMsg}}" stepKey="seeSuccessSaveMessage"/>
108+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductQuantity"/>
109+
<actionGroup ref="StorefrontAddProductToCartWithQtyActionGroup" stepKey="addToCartFromStorefrontProductPage">
110+
<argument name="productQty" value="1"/>
111+
</actionGroup>
112+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeSuccessSaveMessage"/>
82113
<seeElement selector="{{StorefrontMinicartSection.quantity(1)}}" stepKey="seeAddedProductQuantityInCart"/>
83114
<actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/>
84-
<see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{SimpleProduct.name}}" stepKey="seeProductNameInMiniCart"/>
85-
<see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{SimpleProduct.price}}" stepKey="seeProductPriceInMiniCart"/>
86-
<seeElement selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="seeCheckOutButtonInMiniCart"/>
115+
<actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="seeProductNameInMiniCart">
116+
<argument name="productName" value="{{SimpleProduct.name}}"/>
117+
<argument name="productPrice" value="{{SimpleProduct.price}}"/>
118+
<argument name="cartSubtotal" value="{{SimpleProduct.price}}" />
119+
<argument name="qty" value="1"/>
120+
</actionGroup>
121+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeProductPriceInMiniCart"/>
122+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeCheckOutButtonInMiniCart"/>
87123
</test>
88124
</tests>

0 commit comments

Comments
 (0)