Skip to content

Commit 41bbc64

Browse files
committed
Refactoring the test
1 parent c46d9bf commit 41bbc64

File tree

5 files changed

+105
-18
lines changed

5 files changed

+105
-18
lines changed
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="waitForSeoSection"/>
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontTextOnCmsPageActionGroup">
11+
<arguments>
12+
<argument name="cmsTitle" type="string"/>
13+
<argument name="cmsContent" type="string"/>
14+
</arguments>
15+
<seeInTitle userInput="{{cmsTitle}}" stepKey="seePageTitle"/>
16+
<see userInput="{{cmsContent}}" stepKey="seePageContent"/>
17+
</actionGroup>
18+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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="AdminInsertCatalogProductsListWidgetForCmsPageContentSectionActionGroup">
12+
<annotations>
13+
<description>Insert "Catalog Products List" Widget into Content Section of CMS page</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="title" type="string" defaultValue=""/>
17+
<argument name="numberOfProductsToDisplay" type="string" defaultValue="10"/>
18+
<argument name="displayPageControl" type="string" defaultValue="No"/>
19+
<argument name="template" type="string" defaultValue="Products Grid Template"/>
20+
<argument name="cacheLifetime" type="string" defaultValue=""/>
21+
<argument name="categoryName" type="string" defaultValue="{{DefaultCategory.name}}"/>
22+
</arguments>
23+
<click selector="{{CmsWYSIWYGSection.InsertWidgetBtn}}" stepKey="clickInsertWidgetButton"/>
24+
<waitForPageLoad stepKey="waitForSlideOut"/>
25+
<selectOption selector="{{WidgetSection.WidgetType}}" userInput="Catalog Products List" stepKey="selectWidgetType"/>
26+
<waitForPageLoad stepKey="waitForWidgetOptions"/>
27+
<fillField selector="{{AdminNewWidgetSection.title}}" userInput="{{title}}" stepKey="setTitle"/>
28+
<selectOption selector="{{AdminNewWidgetSection.displayPageControl}}" userInput="{{displayPageControl}}" stepKey="selectDisplayPageControl"/>
29+
<fillField selector="{{AdminNewWidgetSection.numberOfProductsToDisplay}}" userInput="{{numberOfProductsToDisplay}}" stepKey="fillNumberOfProductsToDisplay"/>
30+
<selectOption selector="{{AdminNewWidgetSection.template}}" userInput="{{template}}" stepKey="selectTemplate"/>
31+
<fillField selector="{{AdminNewWidgetSection.cacheLifetime}}" userInput="{{cacheLifetime}}" stepKey="fillCacheLifetime"/>
32+
<click selector="{{AdminNewWidgetSection.addNewCondition}}" stepKey="clickAddNewCondition"/>
33+
<selectOption selector="{{AdminNewWidgetSection.selectCondition}}" userInput="Magento\CatalogWidget\Model\Rule\Condition\Product|category_ids" stepKey="selectCondition"/>
34+
<waitForElement selector="{{AdminNewWidgetSection.ruleParameter}}" stepKey="waitRuleParameter"/>
35+
<click selector="{{AdminNewWidgetSection.ruleParameter}}" stepKey="clickRuleParameter"/>
36+
<click selector="{{AdminNewWidgetSection.openChooser}}" stepKey="clickChooser"/>
37+
<waitForAjaxLoad stepKey="waitForAjaxLoad"/>
38+
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree(categoryName)}}" stepKey="clickCategoryToEditInitial"/>
39+
<click selector="{{AdminNewWidgetSection.applyParameter}}" stepKey="clickApplyRuleParameter"/>
40+
</actionGroup>
41+
</actionGroups>

app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<element name="title" type="input" selector="[name='parameters[title]']"/>
5454
<element name="displayPageControl" type="select" selector="[name='parameters[show_pager]']"/>
5555
<element name="numberOfProductsToDisplay" type="input" selector="[name='parameters[products_count]']"/>
56+
<element name="template" type="select" selector="[name='parameters[template]']"/>
5657
<element name="cacheLifetime" type="input" selector="[name='parameters[cache_lifetime]']"/>
5758
<element name="deleteWidgetLayoutAction" type="button" selector="#page_group_container > div:first-of-type > div.fieldset-wrapper-title > div > .action-default.action-delete"/>
5859
<element name="CountDeleteButtons" type="button" selector="#page_group_container > .fieldset-wrapper.page_group_container > div.fieldset-wrapper-title > div > .action-default.action-delete"/>

app/code/Magento/Widget/Test/Mftf/Test/ProductsListWidgetTest.xml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,32 @@
3636
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCmsList"/>
3737
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
3838
<actionGroup ref="AdminClickAddNewPageOnPagesGridActionGroup" stepKey="clickAddNewPageButton"/>
39-
<fillField selector="{{CmsNewPagePageBasicFieldsSection.pageTitle}}" userInput="{{_newDefaultCmsPage.title}}" stepKey="fillPageTitle"/>
40-
<click selector="{{CmsNewPagePageContentSection.header}}" stepKey="expandContentSection"/>
41-
<waitForPageLoad stepKey="waitForContentSection"/>
42-
<click selector="{{CmsWYSIWYGSection.InsertWidgetBtn}}" stepKey="clickInsertWidgetButton"/>
43-
<waitForPageLoad stepKey="waitForSlideOut"/>
44-
<selectOption selector="{{WidgetSection.WidgetType}}" userInput="Catalog Products List" stepKey="selectWidgetType"/>
45-
<waitForPageLoad stepKey="waitForWidgetOptions"/>
46-
<click selector="{{AdminNewWidgetSection.addNewCondition}}" stepKey="clickAddNewCondition"/>
47-
<selectOption selector="{{AdminNewWidgetSection.selectCondition}}" userInput="Magento\CatalogWidget\Model\Rule\Condition\Product|category_ids" stepKey="selectCondition"/>
48-
<waitForElement selector="{{AdminNewWidgetSection.ruleParameter}}" stepKey="waitRuleParameter"/>
49-
<click selector="{{AdminNewWidgetSection.ruleParameter}}" stepKey="clickRuleParameter"/>
50-
<click selector="{{AdminNewWidgetSection.openChooser}}" stepKey="clickChooser"/>
51-
<waitForAjaxLoad stepKey="waitForAjaxLoad"/>
52-
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$createCategory.name$$)}}" stepKey="clickCategoryToEditInitial"/>
53-
<click selector="{{AdminNewWidgetSection.applyParameter}}" stepKey="clickApplyRuleParameter"/>
39+
<actionGroup ref="AdminCmsPageSetTitleActionGroup" stepKey="fillPageTitle">
40+
<argument name="newTitle" value="{{_newDefaultCmsPage.title}}"/>
41+
</actionGroup>
42+
<actionGroup ref="AdminExpandContentSectionActionGroup" stepKey="expandContentSection"/>
43+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForContentSection"/>
44+
<actionGroup ref="AdminInsertCatalogProductsListWidgetForCmsPageContentSectionActionGroup" stepKey="clickInsertWidgetButton">
45+
<argument name="categoryName" value="$$createCategory.name$$"/>
46+
</actionGroup>
47+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForSlideOut"/>
48+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="selectWidgetType"/>
49+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForWidgetOptions"/>
50+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickAddNewCondition"/>
51+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="selectCondition"/>
52+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitRuleParameter"/>
53+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickRuleParameter"/>
54+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickChooser"/>
55+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForAjaxLoad"/>
56+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickCategoryToEditInitial"/>
57+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickApplyRuleParameter"/>
5458
<actionGroup ref="AdminClickInsertWidgetActionGroup" stepKey="clickInsertWidget"/>
5559
<click selector="{{CmsNewPagePageActionsSection.expandSplitButton}}" stepKey="expandSplitBtn"/>
5660
<click selector="{{CmsNewPagePageActionsSection.saveAndClose}}" stepKey="clickSaveAndClose"/>
5761
<waitForPageLoad stepKey="waitForCmsList2"/>
58-
<see userInput="You saved the page." stepKey="seeSuccessMessage"/>
62+
<actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeSuccessMessage">
63+
<argument name="message" value="You saved the page."/>
64+
</actionGroup>
5965
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clearGridFilters"/>
6066
<!-- Verify CMS page on storefront -->
6167
<waitForElementVisible selector="{{CmsPagesPageActionsSection.select(_newDefaultCmsPage.title)}}" stepKey="waitForCMSPageListItem" />
@@ -64,8 +70,11 @@
6470
<click selector="{{CmsPagesPageActionsSection.preview(_newDefaultCmsPage.title)}}" stepKey="clickEdit" />
6571
<switchToNextTab stepKey="switchToNextTab"/>
6672
<waitForPageLoad stepKey="waitForCMSPage"/>
67-
<seeInTitle userInput="{{_newDefaultCmsPage.title}}" stepKey="seePageTitle"/>
68-
<see userInput="{{_newDefaultCmsPage.title}}" stepKey="seeProduct"/>
73+
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seePageTitle"/>
74+
<actionGroup ref="AssertStorefrontTextOnCmsPageActionGroup" stepKey="seeProduct">
75+
<argument name="cmsTitle" value="{{_newDefaultCmsPage.title}}"/>
76+
<argument name="cmsContent" value="$$createSimpleProduct.name$$"/>
77+
</actionGroup>
6978
<closeTab stepKey="closeCurrentTab"/>
7079
</test>
7180
</tests>

0 commit comments

Comments
 (0)