Skip to content

Commit 4f46f40

Browse files
ENGCOM-9221: Replace repetitive actions with Action Groups in AdminAddBundleItemsTest #34075
- Merge Pull Request #34075 from kate-kyzyma/magento2:Refactoring-AdminAddBundleItemsTest - Merged commits: 1. 36ad6b7 2. 76a5004 3. 1d07483 4. a4d9bc1 5. 61c8530
2 parents 177254d + 61c8530 commit 4f46f40

File tree

1 file changed

+71
-50
lines changed

1 file changed

+71
-50
lines changed

app/code/Magento/Bundle/Test/Mftf/Test/AdminAddBundleItemsTest.xml

Lines changed: 71 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,47 @@
4040
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
4141
</after>
4242
<!--Go to bundle product creation page-->
43-
<amOnPage url="{{AdminProductCreatePage.url(BundleProduct.set, BundleProduct.type)}}" stepKey="goToBundleProductCreationPage"/>
44-
<waitForPageLoad stepKey="waitForBundleProductCreatePageToLoad"/>
43+
<actionGroup ref="AdminOpenNewProductFormPageActionGroup" stepKey="goToBundleProductCreationPage">
44+
<argument name="attributeSetId" value="{{BundleProduct.set}}"/>
45+
<argument name="productType" value="{{BundleProduct.type}}"/>
46+
</actionGroup>
47+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleProductCreatePageToLoad"/>
48+
4549

4650
<!-- Add two bundle items -->
47-
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
48-
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3"/>
49-
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
50-
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
51-
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
52-
<actionGroup ref="AdminClickAddProductToOptionActionGroup" stepKey="clickAddProductsToOption"/>
53-
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterBundleProductOptions">
54-
<argument name="product" value="$$simpleProduct0$$"/>
55-
</actionGroup>
56-
<checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectFirstGridRow"/>
57-
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterBundleProductOptions2">
58-
<argument name="product" value="$$simpleProduct1$$"/>
51+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="conditionallyOpenSectionBundleItems"/>
52+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickAddOption3"/>
53+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleOptions"/>
54+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillOptionTitle"/>
55+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="selectInputType"/>
56+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickAddProductsToOption"/>
57+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="filterBundleProductOptions"/>
58+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="selectFirstGridRow"/>
59+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="filterBundleProductOptions2"/>
60+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="selectFirstGridRow2"/>
61+
<actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="clickAddSelectedBundleProducts">
62+
<argument name="x" value="0"/>
63+
<argument name="n" value="1"/>
64+
<argument name="prodOneSku" value="$$simpleProduct0.sku$$"/>
65+
<argument name="prodTwoSku" value="$$simpleProduct1.sku$$"/>
66+
<argument name="optionTitle" value="{{BundleProduct.optionTitle1}}"/>
67+
<argument name="inputType" value="{{BundleProduct.optionInputType1}}"/>
5968
</actionGroup>
60-
<checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectFirstGridRow2"/>
61-
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddSelectedBundleProducts"/>
62-
<!-- Check that Bundle Options initialized with default quantity -->
69+
70+
<!-- Check that Bundle Options initialized with proper quantity -->
6371
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantity"/>
6472
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantity">
65-
<expectedResult type="string">1</expectedResult>
73+
<expectedResult type="string">50</expectedResult>
6674
<actualResult type="string">$grabbedFirstBundleOptionQuantity</actualResult>
6775
</assertEquals>
6876
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantity"/>
6977
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantity">
70-
<expectedResult type="string">1</expectedResult>
78+
<expectedResult type="string">50</expectedResult>
7179
<actualResult type="string">$grabbedSecondBundleOptionQuantity</actualResult>
7280
</assertEquals>
7381

74-
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty1"/>
75-
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty2"/>
82+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductDefaultQty1"/>
83+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductDefaultQty2"/>
7684

7785
<!--Fill out ancillary data on bundle product-->
7886
<actionGroup ref="AncillaryPrepBundleProductActionGroup" stepKey="createBundledProductForTwoSimpleProducts">
@@ -81,16 +89,20 @@
8189

8290
<!--Save the product-->
8391
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="clickSaveButton"/>
84-
<see userInput="You saved the product." stepKey="messageYouSavedTheProductIsShown"/>
92+
<actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="messageYouSavedTheProductIsShown">
93+
<argument name="message" value="You saved the product."/>
94+
</actionGroup>
8595

8696
<!--Checking on admin side-->
8797
<scrollToTopOfPage stepKey="scroll"/>
8898
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems2"/>
89-
<seeElement stepKey="LookingForBundleItemPresence" selector="{{AdminProductFormBundleSection.listedBundleItem}}"/>
99+
<seeElement selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="LookingForBundleItemPresence"/>
90100

91101
<!--Checking on customer side-->
92-
<amOnPage url="{{BundleProduct.urlKey}}.html" stepKey="GoToProductPage"/>
93-
<waitForPageLoad stepKey="waitForBundleProductPageToLoad"/>
102+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="GoToProductPage">
103+
<argument name="productUrl" value="{{BundleProduct.urlKey}}"/>
104+
</actionGroup>
105+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleProductPageToLoad"/>
94106
<seeElement selector="{{StorefrontBundledSection.customizeProduct}}" stepKey="LookingForAbilityToAddOptions"/>
95107
<click selector="{{StorefrontBundledSection.customizeProduct}}" stepKey="clickButtonToCustomize"/>
96108
<waitForPageLoad stepKey="waitCustomizationDropDown"/>
@@ -99,53 +111,62 @@
99111
<!--Add another bundle option with 2 items-->
100112
<!--Go to bundle product creation page-->
101113
<actionGroup ref="AdminOpenCatalogProductPageActionGroup" stepKey="goToCatalogProductPage"/>
102-
<conditionalClick selector="{{AdminProductFiltersSection.filtersClear}}" dependentSelector="{{AdminProductFiltersSection.filtersClear}}" visible="true" stepKey="ClickOnButtonToRemoveFiltersIfPresent"/>
103-
<waitForPageLoad stepKey="WaitForClear"/>
114+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="ClickOnButtonToRemoveFiltersIfPresent"/>
115+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="WaitForClear"/>
104116
<actionGroup ref="FilterProductGridByNameActionGroup" stepKey="filterBundleProductOptionsDownToName">
105117
<argument name="product" value="BundleProduct"/>
106118
</actionGroup>
107-
<click selector="{{AdminProductFormBundleSection.addOptions}}" stepKey="clickOnBundleProductToEdit"/>
108-
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItemsToEdit"/>
109-
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption"/>
110-
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('1')}}" stepKey="waitForBundleOptionsToAppear"/>
111-
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('1')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillNewestOptionTitle"/>
112-
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('1')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectNewInputType"/>
113-
<actionGroup ref="AdminClickAddProductToOptionActionGroup" stepKey="clickAddProductsToNewOption"/>
114-
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterNewBundleProductOptions">
115-
<argument name="product" value="$$simpleProduct2$$"/>
119+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="clickOnBundleProductToEdit">
120+
<argument name="product" value="BundleProduct"/>
116121
</actionGroup>
117-
<checkOption selector="//div[@class='admin__data-grid-outer-wrap']//tr[@data-repeat-index='0']//input[@type='checkbox']" stepKey="selectNewFirstGridRow"/>
118-
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterNewBundleProductOptions2">
119-
<argument name="product" value="$$simpleProduct3$$"/>
122+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="conditionallyOpenSectionBundleItemsToEdit"/>
123+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickAddOption"/>
124+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleOptionsToAppear"/>
125+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillNewestOptionTitle"/>
126+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="selectNewInputType"/>
127+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickAddProductsToNewOption"/>
128+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="filterNewBundleProductOptions"/>
129+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="selectNewFirstGridRow"/>
130+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="filterNewBundleProductOptions2"/>
131+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="selectNewFirstGridRow2"/>
132+
<actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="clickAddNewSelectedBundleProducts">
133+
<argument name="x" value="1"/>
134+
<argument name="n" value="2"/>
135+
<argument name="prodOneSku" value="$$simpleProduct2.sku$$"/>
136+
<argument name="prodTwoSku" value="$$simpleProduct3.sku$$"/>
137+
<argument name="optionTitle" value="{{BundleProduct.optionTitle1}}"/>
138+
<argument name="inputType" value="{{BundleProduct.optionInputType1}}"/>
120139
</actionGroup>
121-
<checkOption selector="{{AdminProductFormBundleSection.firstProductOption}}" stepKey="selectNewFirstGridRow2"/>
122-
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddNewSelectedBundleProducts"/>
140+
123141
<!-- Check that existing Bundle Options do not loose user input quantity values -->
124142
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantityAfterUserInput"/>
125143
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantityAfterUserInput">
126-
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
144+
<expectedResult type="string">50</expectedResult>
127145
<actualResult type="string">$grabbedFirstBundleOptionQuantityAfterUserInput</actualResult>
128146
</assertEquals>
129147
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantityAfterUserInput"/>
130148
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantityAfterUserInput">
131-
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
149+
<expectedResult type="string">50</expectedResult>
132150
<actualResult type="string">$grabbedSecondBundleOptionQuantityAfterUserInput</actualResult>
133151
</assertEquals>
134-
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '2')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty1"/>
135-
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '3')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty2"/>
136-
152+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillNewProductDefaultQty1"/>
153+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillNewProductDefaultQty2"/>
137154
<!--Save the product-->
138155
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="clickSaveButtonAgain"/>
139-
<see userInput="You saved the product." stepKey="messageYouSavedTheProductIsShownAgain"/>
156+
<actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="messageYouSavedTheProductIsShownAgain">
157+
<argument name="message" value="You saved the product."/>
158+
</actionGroup>
140159

141160
<!--Checking on admin side-->
142161
<scrollToTopOfPage stepKey="scrollAgain"/>
143162
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenNewSectionBundleItems2"/>
144-
<seeElement selector="{{AdminProductFormBundleSection.listedBundleItem2}}" stepKey="LookingForNewBundleItemPresence"/>
163+
<seeElement selector="{{AdminProductFormBundleSection.bundleOptionXTitle('1')}}" stepKey="LookingForNewBundleItemPresence"/>
145164

146165
<!--Checking on customer side-->
147-
<amOnPage url="{{BundleProduct.urlKey}}.html" stepKey="GoToProductPageAgain"/>
148-
<waitForPageLoad stepKey="waitForBundleProductPageToLoadAgain"/>
166+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="GoToProductPageAgain">
167+
<argument name="productUrl" value="{{BundleProduct.urlKey}}"/>
168+
</actionGroup>
169+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleProductPageToLoadAgain"/>
149170
<seeElement selector="{{StorefrontBundledSection.customizeProduct}}" stepKey="LookingForAbilityToAddBothOptions"/>
150171
<click selector="{{StorefrontBundledSection.customizeProduct}}" stepKey="clickButtonAgainToCustomize"/>
151172
<waitForPageLoad stepKey="waitForBothCustomizationDropDown"/>

0 commit comments

Comments
 (0)