Skip to content

Commit fad1764

Browse files
ENGCOM-9064: Replace repetitive actions with Action Groups in ProductsListWidgetTest #32714
- Merge Pull Request #32714 from kate-kyzyma/magento2:Refactoring-ProductsListWidgetTest - Merged commits: 1. b1ff2c3 2. 41bbc64 3. b5c06d7 4. 6b8304a 5. 6996d64 6. 07bc24f 7. e22f98a 8. 9f7c4e6 9. 0c87662 10. e2c81c4 11. a3f308f 12. 7800c18 13. da3792c 14. 5e37cdc 15. 1a71e8e
2 parents 710b9cc + 1a71e8e commit fad1764

15 files changed

+291
-72
lines changed

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@
4040
<actionGroup ref="AdminClickAddProductToggleAndSelectProductTypeActionGroup" stepKey="clickAddBundleProduct">
4141
<argument name="productType" value="bundle"/>
4242
</actionGroup>
43-
<fillField selector="{{AdminProductFormSection.productName}}" userInput="{{_defaultProduct.name}}" stepKey="fillProductName"/>
44-
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{_defaultProduct.sku}}" stepKey="fillProductSku"/>
45-
<fillField selector="{{AdminProductFormSection.setProductAsNewFrom}}" userInput="01/1/2000" stepKey="fillProductNewFrom"/>
46-
<fillField selector="{{AdminProductFormSection.setProductAsNewTo}}" userInput="01/1/2099" stepKey="fillProductNewTo"/>
47-
43+
<actionGroup ref="FillProductNameAndSkuInProductFormActionGroup" stepKey="fillProductName">
44+
<argument name="product" value="_defaultProduct"/>
45+
</actionGroup>
46+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductSku"/>
47+
<actionGroup ref="AdminSetProductAsNewDateActionGroup" stepKey="fillProductNewFrom">
48+
<argument name="fromDate" value="01/1/2000"/>
49+
<argument name="toDate" value="01/1/2099"/>
50+
</actionGroup>
51+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductNewTo"/>
4852
<!-- and then configure bundled items for this product -->
4953

5054
<scrollTo selector="{{AdminProductFormBundleSection.addOption}}" stepKey="scrollToAddOptionButton"/>
@@ -69,9 +73,12 @@
6973
<!-- If PageCache is enabled, Cache clearing happens here, via merge -->
7074

7175
<!-- Check for product on the CMS page with the New Products widget -->
72-
73-
<amOnPage url="{{_newDefaultCmsPage.identifier}}" stepKey="amOnCmsPage"/>
74-
<waitForPageLoad stepKey="waitForCmsPage"/>
75-
<see selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" userInput="{{_defaultProduct.name}}" stepKey="seeProductName"/>
76+
<actionGroup ref="StorefrontGoToCMSPageActionGroup" stepKey="amOnCmsPage">
77+
<argument name="identifier" value="{{_newDefaultCmsPage.identifier}}"/>
78+
</actionGroup>
79+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCmsPage"/>
80+
<actionGroup ref="AssertStorefrontProductIsShownOnCmsPageActionGroup" stepKey="seeProductName">
81+
<argument name="cmsTitle" value="{{_newDefaultCmsPage.title}}"/>
82+
</actionGroup>
7683
</test>
7784
</tests>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminSetProductAsNewDateActionGroup">
11+
<arguments>
12+
<argument name="fromDate" type="string"/>
13+
<argument name="toDate" type="string"/>
14+
</arguments>
15+
16+
<fillField selector="{{AdminProductFormSection.setProductAsNewFrom}}" userInput="{{fromDate}}" stepKey="fillProductNewFrom"/>
17+
<fillField selector="{{AdminProductFormSection.setProductAsNewTo}}" userInput="{{toDate}}" stepKey="fillProductNewTo"/>
18+
</actionGroup>
19+
</actionGroups>

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,27 @@
2424

2525
<!-- Create a Simple Product to appear in the widget -->
2626
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="amOnProductList"/>
27-
<click selector="{{AdminProductGridActionSection.addProductBtn}}" stepKey="clickAddProduct"/>
28-
<fillField selector="{{AdminProductFormSection.productName}}" userInput="{{_defaultProduct.name}}" stepKey="fillProductName"/>
29-
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{_defaultProduct.sku}}" stepKey="fillProductSku"/>
30-
<fillField selector="{{AdminProductFormSection.productPrice}}" userInput="{{_defaultProduct.price}}" stepKey="fillProductPrice"/>
31-
<fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="100" stepKey="fillProductQuantity"/>
32-
<fillField selector="{{AdminProductFormSection.setProductAsNewFrom}}" userInput="01/1/2000" stepKey="fillProductNewFrom"/>
33-
<fillField selector="{{AdminProductFormSection.setProductAsNewTo}}" userInput="01/1/2099" stepKey="fillProductNewTo"/>
27+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="clickAddProduct"/>
28+
<actionGroup ref="FillMainProductFormActionGroup" stepKey="fillProductName"/>
29+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductSku"/>
30+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductPrice"/>
31+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductQuantity"/>
32+
<actionGroup ref="AdminSetProductAsNewDateActionGroup" stepKey="fillProductNewFrom">
33+
<argument name="fromDate" value="01/1/2000"/>
34+
<argument name="toDate" value="01/1/2099"/>
35+
</actionGroup>
36+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductNewTo"/>
3437
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="clickSaveProduct"/>
3538

3639
<!-- If PageCache is enabled, Cache clearing happens here via merge -->
3740

3841
<!-- Check for product on the CMS page with the New Products widget -->
39-
<amOnPage url="{{_newDefaultCmsPage.identifier}}" stepKey="amOnCmsPage"/>
40-
<waitForPageLoad stepKey="waitForCmsPage"/>
41-
<see selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" userInput="{{_defaultProduct.name}}" stepKey="seeProductName"/>
42+
<actionGroup ref="StorefrontGoToCMSPageActionGroup" stepKey="amOnCmsPage">
43+
<argument name="identifier" value="{{_newDefaultCmsPage.identifier}}"/>
44+
</actionGroup>
45+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCmsPage"/>
46+
<actionGroup ref="AssertStorefrontProductIsShownOnCmsPageActionGroup" stepKey="seeProductName">
47+
<argument name="cmsTitle" value="{{_newDefaultCmsPage.title}}"/>
48+
</actionGroup>
4249
</test>
4350
</tests>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminCmsPageSetUrlActionGroup">
11+
<arguments>
12+
<argument name="urlKey" type="string"/>
13+
</arguments>
14+
15+
<fillField selector="{{CmsNewPagePageSeoSection.urlKey}}" userInput="{{urlKey}}" stepKey="fillPageUrlKey"/>
16+
</actionGroup>
17+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminExpandContentSectionActionGroup">
12+
<annotations>
13+
<description>Expand Content section on the Admin CMS Page creation/edit.</description>
14+
</annotations>
15+
<click selector="{{CmsNewPagePageContentSection.header}}" stepKey="expandContentSection"/>
16+
<waitForPageLoad stepKey="waitForContentSection"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminExpandSeoSectionActionGroup">
12+
<annotations>
13+
<description>Expand SEO section on the Admin CMS Page creation/edit.</description>
14+
</annotations>
15+
<click selector="{{CmsNewPagePageSeoSection.header}}" stepKey="expandSeoSection"/>
16+
<waitForPageLoad stepKey="waitForSeoSection"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontProductIsShownOnCmsPageActionGroup">
11+
<arguments>
12+
<argument name="cmsTitle" type="string"/>
13+
<argument name="productName" type="string" defaultValue="{{_defaultProduct.name}}"/>
14+
</arguments>
15+
16+
<seeInTitle userInput="{{cmsTitle}}" stepKey="seePageTitle"/>
17+
<see selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" userInput="{{productName}}" stepKey="seeProductName"/>
18+
</actionGroup>
19+
</actionGroups>

app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NewProductsListWidgetConfigurableProductTest.xml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,23 @@
8282
<argument name="productId" value="$$createConfigProduct.id$$"/>
8383
</actionGroup>
8484
<waitForPageLoad stepKey="waitForEditPage"/>
85-
<fillField selector="{{AdminProductFormSection.setProductAsNewFrom}}" userInput="01/1/2000" stepKey="fillProductNewFrom"/>
86-
<fillField selector="{{AdminProductFormSection.setProductAsNewTo}}" userInput="01/1/2099" stepKey="fillProductNewTo"/>
85+
<actionGroup ref="AdminSetProductAsNewDateActionGroup" stepKey="fillProductNewFrom">
86+
<argument name="fromDate" value="01/1/2000"/>
87+
<argument name="toDate" value="01/1/2099"/>
88+
</actionGroup>
89+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductNewTo"/>
8790
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="clickSaveProduct"/>
8891

8992
<!-- If PageCache is enabled, Cache clearing happens here, via merge -->
9093

9194
<!-- Check for product on the CMS page with the New Products widget -->
92-
<amOnPage url="{{_newDefaultCmsPage.identifier}}" stepKey="amOnCmsPage"/>
93-
<waitForPageLoad stepKey="waitForCmsPage"/>
94-
<see selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" userInput="$$createConfigProduct.name$$" stepKey="seeProductName"/>
95+
<actionGroup ref="StorefrontGoToCMSPageActionGroup" stepKey="amOnCmsPage">
96+
<argument name="identifier" value="{{_newDefaultCmsPage.identifier}}"/>
97+
</actionGroup>
98+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCmsPage"/>
99+
<actionGroup ref="AssertStorefrontProductIsShownOnCmsPageActionGroup" stepKey="seeProductName">
100+
<argument name="cmsTitle" value="{{_newDefaultCmsPage.title}}"/>
101+
<argument name="productName" value="$$createConfigProduct.name$$"/>
102+
</actionGroup>
95103
</test>
96104
</tests>

app/code/Magento/Downloadable/Test/Mftf/Test/NewProductsListWidgetDownloadableProductTest.xml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@
3636
<actionGroup ref="AdminClickAddProductToggleAndSelectProductTypeActionGroup" stepKey="clickAddDownloadableProduct">
3737
<argument name="productType" value="downloadable"/>
3838
</actionGroup>
39-
<fillField selector="{{AdminProductFormSection.productName}}" userInput="{{_defaultProduct.name}}" stepKey="fillProductName"/>
40-
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{_defaultProduct.sku}}" stepKey="fillProductSku"/>
41-
<fillField selector="{{AdminProductFormSection.productPrice}}" userInput="{{_defaultProduct.price}}" stepKey="fillProductPrice"/>
42-
<fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="100" stepKey="fillProductQuantity"/>
43-
<fillField selector="{{AdminProductFormSection.setProductAsNewFrom}}" userInput="01/1/2000" stepKey="fillProductNewFrom"/>
44-
<fillField selector="{{AdminProductFormSection.setProductAsNewTo}}" userInput="01/1/2099" stepKey="fillProductNewTo"/>
39+
<actionGroup ref="FillMainDownloadableProductFormActionGroup" stepKey="fillProductName">
40+
<argument name="product" value="_defaultProduct"/>
41+
</actionGroup>
42+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductSku"/>
43+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductPrice"/>
44+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductQuantity"/>
45+
<actionGroup ref="AdminSetProductAsNewDateActionGroup" stepKey="fillProductNewFrom">
46+
<argument name="fromDate" value="01/1/2000"/>
47+
<argument name="toDate" value="01/1/2099"/>
48+
</actionGroup>
49+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductNewTo"/>
4550
<click selector="{{AdminProductDownloadableSection.sectionHeader}}" stepKey="openDownloadableSection"/>
4651
<checkOption selector="{{AdminProductDownloadableSection.isDownloadableProduct}}" stepKey="checkIsDownloadable"/>
4752
<fillField userInput="This Is A Title" selector="{{AdminProductDownloadableSection.linksTitleInput}}" stepKey="fillDownloadableLinkTitle"/>
@@ -55,9 +60,12 @@
5560
<!-- If PageCache is enabled, Cache clearing happens here, via merge -->
5661

5762
<!-- Check for product on the CMS page with the New Products widget -->
58-
59-
<amOnPage url="{{_newDefaultCmsPage.identifier}}" stepKey="amOnCmsPage"/>
60-
<waitForPageLoad stepKey="waitForCmsPage"/>
61-
<see selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" userInput="{{_defaultProduct.name}}" stepKey="seeProductName"/>
63+
<actionGroup ref="StorefrontGoToCMSPageActionGroup" stepKey="amOnCmsPage">
64+
<argument name="identifier" value="{{_newDefaultCmsPage.identifier}}"/>
65+
</actionGroup>
66+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCmsPage"/>
67+
<actionGroup ref="AssertStorefrontProductIsShownOnCmsPageActionGroup" stepKey="seeProductName">
68+
<argument name="cmsTitle" value="{{_newDefaultCmsPage.title}}"/>
69+
</actionGroup>
6270
</test>
6371
</tests>

app/code/Magento/GroupedProduct/Test/Mftf/Test/NewProductsListWidgetGroupedProductTest.xml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@
4545
<actionGroup ref="AdminClickAddProductToggleAndSelectProductTypeActionGroup" stepKey="clickAddGroupedProduct">
4646
<argument name="productType" value="grouped"/>
4747
</actionGroup>
48-
<fillField selector="{{AdminProductFormSection.productName}}" userInput="{{_defaultProduct.name}}" stepKey="fillProductName"/>
49-
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{_defaultProduct.sku}}" stepKey="fillProductSku"/>
50-
<fillField selector="{{AdminProductFormSection.setProductAsNewFrom}}" userInput="01/1/2000" stepKey="fillProductNewFrom"/>
51-
<fillField selector="{{AdminProductFormSection.setProductAsNewTo}}" userInput="01/1/2099" stepKey="fillProductNewTo"/>
48+
<actionGroup ref="FillProductNameAndSkuInProductFormActionGroup" stepKey="fillProductName">
49+
<argument name="product" value="_defaultProduct"/>
50+
</actionGroup>
51+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductSku"/>
52+
<actionGroup ref="AdminSetProductAsNewDateActionGroup" stepKey="fillProductNewFrom">
53+
<argument name="fromDate" value="01/1/2000"/>
54+
<argument name="toDate" value="01/1/2099"/>
55+
</actionGroup>
56+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductNewTo"/>
5257
<conditionalClick selector="{{AdminProductFormGroupedProductsSection.toggleGroupedProduct}}" dependentSelector="{{AdminProductFormGroupedProductsSection.addProductsToGroup}}" visible="false" stepKey="openGroupedProductsSection"/>
5358
<scrollTo selector="{{AdminProductFormGroupedProductsSection.addProductsToGroup}}" stepKey="scrollToAddProductsToGroup"/>
5459
<click selector="{{AdminProductFormGroupedProductsSection.addProductsToGroup}}" stepKey="clickAddProductsToGroup"/>
@@ -64,9 +69,12 @@
6469
<!-- If PageCache is enabled, Cache clearing happens here, via merge -->
6570

6671
<!-- Check for product on the CMS page with the New Products widget -->
67-
68-
<amOnPage url="{{_newDefaultCmsPage.identifier}}" stepKey="amOnCmsPage"/>
69-
<waitForPageLoad stepKey="waitForCmsPage"/>
70-
<see selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" userInput="{{_defaultProduct.name}}" stepKey="seeProductName"/>
72+
<actionGroup ref="StorefrontGoToCMSPageActionGroup" stepKey="amOnCmsPage">
73+
<argument name="identifier" value="{{_newDefaultCmsPage.identifier}}"/>
74+
</actionGroup>
75+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCmsPage"/>
76+
<actionGroup ref="AssertStorefrontProductIsShownOnCmsPageActionGroup" stepKey="seeProductName">
77+
<argument name="cmsTitle" value="{{_newDefaultCmsPage.title}}"/>
78+
</actionGroup>
7179
</test>
7280
</tests>

0 commit comments

Comments
 (0)