Skip to content

Commit 475be33

Browse files
committed
Add functional test
1 parent 92b29c6 commit 475be33

File tree

4 files changed

+123
-1
lines changed

4 files changed

+123
-1
lines changed
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="AssertStorefrontCategoryCurrentPageIsFirstActionGroup">
11+
<grabTextFrom selector="{{StorefrontCategoryBottomToolbarSection.currentPage}}" stepKey="currentPageText"/>
12+
<assertEquals stepKey="assertIsPageFirst">
13+
<expectedResult type="string">1</expectedResult>
14+
<actualResult type="variable">currentPageText</actualResult>
15+
</assertEquals>
16+
</actionGroup>
17+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryBottomToolbarSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
<element name="previousPage" type="button" selector=".//*[@class='toolbar toolbar-products'][2]//a[contains(@class, 'previous')]" timeout="30"/>
1313
<element name="pageNumber" type="text" selector="//*[@class='toolbar toolbar-products'][2]//a[contains(@class, 'page')]//span[2][contains(text() ,'{{var1}}')]" parameterized="true"/>
1414
<element name="perPage" type="select" selector="//*[@class='toolbar toolbar-products'][2]//select[@id='limiter']"/>
15-
<element name="currentPage" type="text" selector=".products.wrapper + .toolbar-products .pages .current span:nth-of-type(2)"/>
15+
<element name="currentPage" type="text" selector=".//*[@class='toolbar toolbar-products'][2]//li[contains(@class, 'current')]//span[2]" timeout="30"/>
1616
</section>
1717
</sections>

app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddTextSwatchToProductActionGroup.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<argument name="option2" defaultValue="textSwatchOption2" type="string"/>
2020
<argument name="option3" defaultValue="textSwatchOption3" type="string"/>
2121
<argument name="usedInProductListing" defaultValue="No" type="string"/>
22+
<argument name="usedInLayeredNavigation" defaultValue="No" type="string"/>
2223
</arguments>
2324

2425
<amOnPage url="{{ProductAttributePage.url}}" stepKey="goToNewProductAttributePage"/>
@@ -41,6 +42,7 @@
4142
<click selector="{{StorefrontPropertiesSection.StoreFrontPropertiesTab}}" stepKey="clickStorefrontPropertiesTab"/>
4243
<waitForElementVisible selector="{{AdvancedAttributePropertiesSection.UseInProductListing}}" stepKey="waitForTabSwitch"/>
4344
<selectOption selector="{{AdvancedAttributePropertiesSection.UseInProductListing}}" userInput="{{usedInProductListing}}" stepKey="useInProductListing"/>
45+
<selectOption selector="{{AttributePropertiesSection.useInLayeredNavigation}}" userInput="{{usedInLayeredNavigation}}" stepKey="useInLayeredNavigation"/>
4446
<click selector="{{AttributePropertiesSection.SaveAndEdit}}" stepKey="clickSave"/>
4547
</actionGroup>
4648
</actionGroups>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontRedirectToFirstPageOnFilteringBySwatchTest">
12+
<annotations>
13+
<features value="Swatches"/>
14+
<stories value="Filter by swatch attribute on plp layered navigation"/>
15+
<title value="Customers are redirected to first plp page after filtering by swatch"/>
16+
<description value="Customers are redirected to first plp page after filtering by swatch"/>
17+
<severity value="MINOR"/>
18+
<group value="Swatches"/>
19+
</annotations>
20+
21+
<before>
22+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
23+
<createData entity="SimpleProduct" stepKey="createSimpleProduct1">
24+
<requiredEntity createDataKey="createCategory"/>
25+
</createData>
26+
<createData entity="SimpleProduct" stepKey="createSimpleProduct2">
27+
<requiredEntity createDataKey="createCategory"/>
28+
</createData>
29+
<createData entity="SimpleProduct" stepKey="createSimpleProduct3">
30+
<requiredEntity createDataKey="createCategory"/>
31+
</createData>
32+
33+
<magentoCLI command="config:set catalog/frontend/grid_per_page 1" stepKey="setOneProductPerPage"/>
34+
<magentoCLI command="config:set catalog/frontend/grid_per_page_values 1" stepKey="setGridPerPage"/>
35+
<magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches"/>
36+
37+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
38+
<actionGroup ref="AddTextSwatchToProductActionGroup" stepKey="addSwatchAttribute">
39+
<argument name="usedInLayeredNavigation" value="1"/>
40+
</actionGroup>
41+
</before>
42+
43+
<after>
44+
<actionGroup ref="DeleteProductAttributeActionGroup" stepKey="deleteSwatchAttribute">
45+
<argument name="ProductAttribute" value="textSwatchAttribute"/>
46+
</actionGroup>
47+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
48+
49+
<magentoCLI command="config:set catalog/frontend/grid_per_page 12" stepKey="setDefaultProductsPerPage"/>
50+
<magentoCLI command="config:set catalog/frontend/grid_per_page_values 12,24,36" stepKey="setDefaultGridPerPage"/>
51+
<magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches"/>
52+
53+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
54+
<deleteData createDataKey="createSimpleProduct1" stepKey="deleteSimpleProduct1"/>
55+
<deleteData createDataKey="createSimpleProduct2" stepKey="deleteSimpleProduct2"/>
56+
<deleteData createDataKey="createSimpleProduct3" stepKey="deleteSimpleProduct3"/>
57+
</after>
58+
59+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/{{AddToDefaultSet.attributeSetId}}/" stepKey="onAttributeSetEdit"/>
60+
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToGroup">
61+
<argument name="group" value="Product Details"/>
62+
<argument name="attribute" value="{{textSwatchAttribute.attribute_code}}"/>
63+
</actionGroup>
64+
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="SaveAttributeSet"/>
65+
66+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductsGridPage"/>
67+
68+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="goToProduct1EditPage">
69+
<argument name="product" value="$$createSimpleProduct1$$"/>
70+
</actionGroup>
71+
<selectOption selector="{{AdminProductAttributesSection.attributeDropdownByCode(textSwatchAttribute.attribute_code)}}" userInput="textSwatchOption1" stepKey="selectProduct1AttributeOption"/>
72+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct1"/>
73+
74+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductsGridPage2"/>
75+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="goToProduct2EditPage">
76+
<argument name="product" value="$$createSimpleProduct2$$"/>
77+
</actionGroup>
78+
<selectOption selector="{{AdminProductAttributesSection.attributeDropdownByCode(textSwatchAttribute.attribute_code)}}" userInput="textSwatchOption1" stepKey="selectProduct2AttributeOption"/>
79+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct2"/>
80+
81+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductsGridPage3"/>
82+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="goToProduct3EditPage">
83+
<argument name="product" value="$$createSimpleProduct3$$"/>
84+
</actionGroup>
85+
<selectOption selector="{{AdminProductAttributesSection.attributeDropdownByCode(textSwatchAttribute.attribute_code)}}" userInput="textSwatchOption2" stepKey="selectProduct3AttributeOption"/>
86+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct3"/>
87+
88+
<magentoCLI command="cron:run --group=index" stepKey="runCronIndexer"/>
89+
90+
<amOnPage url="$$createCategory.name$$.html" stepKey="amOnCategoryPage"/>
91+
<waitForPageLoad stepKey="waitForPageToLoad"/>
92+
93+
<scrollTo selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="scrollToNextButton"/>
94+
<click selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="clickOnNextPage"/>
95+
<waitForPageLoad stepKey="waitForPageToLoad2"/>
96+
97+
<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle(textSwatchAttribute.default_label)}}" stepKey="expandAttribute"/>
98+
<click selector="{{StorefrontCategorySidebarSection.attributeNthOption(textSwatchAttribute.attribute_code, '1')}}" stepKey="filterBySwatch1"/>
99+
<waitForPageLoad stepKey="waitForPageToLoad3"/>
100+
101+
<actionGroup ref="AssertStorefrontCategoryCurrentPageIsFirstActionGroup" stepKey="assertCurrentPageIsFirst"/>
102+
</test>
103+
</tests>

0 commit comments

Comments
 (0)