Skip to content

Commit

Permalink
Add functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartlomiejsz committed Apr 29, 2020
1 parent 92b29c6 commit 475be33
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontCategoryCurrentPageIsFirstActionGroup">
<grabTextFrom selector="{{StorefrontCategoryBottomToolbarSection.currentPage}}" stepKey="currentPageText"/>
<assertEquals stepKey="assertIsPageFirst">
<expectedResult type="string">1</expectedResult>
<actualResult type="variable">currentPageText</actualResult>
</assertEquals>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<element name="previousPage" type="button" selector=".//*[@class='toolbar toolbar-products'][2]//a[contains(@class, 'previous')]" timeout="30"/>
<element name="pageNumber" type="text" selector="//*[@class='toolbar toolbar-products'][2]//a[contains(@class, 'page')]//span[2][contains(text() ,'{{var1}}')]" parameterized="true"/>
<element name="perPage" type="select" selector="//*[@class='toolbar toolbar-products'][2]//select[@id='limiter']"/>
<element name="currentPage" type="text" selector=".products.wrapper + .toolbar-products .pages .current span:nth-of-type(2)"/>
<element name="currentPage" type="text" selector=".//*[@class='toolbar toolbar-products'][2]//li[contains(@class, 'current')]//span[2]" timeout="30"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<argument name="option2" defaultValue="textSwatchOption2" type="string"/>
<argument name="option3" defaultValue="textSwatchOption3" type="string"/>
<argument name="usedInProductListing" defaultValue="No" type="string"/>
<argument name="usedInLayeredNavigation" defaultValue="No" type="string"/>
</arguments>

<amOnPage url="{{ProductAttributePage.url}}" stepKey="goToNewProductAttributePage"/>
Expand All @@ -41,6 +42,7 @@
<click selector="{{StorefrontPropertiesSection.StoreFrontPropertiesTab}}" stepKey="clickStorefrontPropertiesTab"/>
<waitForElementVisible selector="{{AdvancedAttributePropertiesSection.UseInProductListing}}" stepKey="waitForTabSwitch"/>
<selectOption selector="{{AdvancedAttributePropertiesSection.UseInProductListing}}" userInput="{{usedInProductListing}}" stepKey="useInProductListing"/>
<selectOption selector="{{AttributePropertiesSection.useInLayeredNavigation}}" userInput="{{usedInLayeredNavigation}}" stepKey="useInLayeredNavigation"/>
<click selector="{{AttributePropertiesSection.SaveAndEdit}}" stepKey="clickSave"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontRedirectToFirstPageOnFilteringBySwatchTest">
<annotations>
<features value="Swatches"/>
<stories value="Filter by swatch attribute on plp layered navigation"/>
<title value="Customers are redirected to first plp page after filtering by swatch"/>
<description value="Customers are redirected to first plp page after filtering by swatch"/>
<severity value="MINOR"/>
<group value="Swatches"/>
</annotations>

<before>
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
<createData entity="SimpleProduct" stepKey="createSimpleProduct1">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="SimpleProduct" stepKey="createSimpleProduct2">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="SimpleProduct" stepKey="createSimpleProduct3">
<requiredEntity createDataKey="createCategory"/>
</createData>

<magentoCLI command="config:set catalog/frontend/grid_per_page 1" stepKey="setOneProductPerPage"/>
<magentoCLI command="config:set catalog/frontend/grid_per_page_values 1" stepKey="setGridPerPage"/>
<magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches"/>

<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="AddTextSwatchToProductActionGroup" stepKey="addSwatchAttribute">
<argument name="usedInLayeredNavigation" value="1"/>
</actionGroup>
</before>

<after>
<actionGroup ref="DeleteProductAttributeActionGroup" stepKey="deleteSwatchAttribute">
<argument name="ProductAttribute" value="textSwatchAttribute"/>
</actionGroup>
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>

<magentoCLI command="config:set catalog/frontend/grid_per_page 12" stepKey="setDefaultProductsPerPage"/>
<magentoCLI command="config:set catalog/frontend/grid_per_page_values 12,24,36" stepKey="setDefaultGridPerPage"/>
<magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches"/>

<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<deleteData createDataKey="createSimpleProduct1" stepKey="deleteSimpleProduct1"/>
<deleteData createDataKey="createSimpleProduct2" stepKey="deleteSimpleProduct2"/>
<deleteData createDataKey="createSimpleProduct3" stepKey="deleteSimpleProduct3"/>
</after>

<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/{{AddToDefaultSet.attributeSetId}}/" stepKey="onAttributeSetEdit"/>
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToGroup">
<argument name="group" value="Product Details"/>
<argument name="attribute" value="{{textSwatchAttribute.attribute_code}}"/>
</actionGroup>
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="SaveAttributeSet"/>

<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductsGridPage"/>

<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="goToProduct1EditPage">
<argument name="product" value="$$createSimpleProduct1$$"/>
</actionGroup>
<selectOption selector="{{AdminProductAttributesSection.attributeDropdownByCode(textSwatchAttribute.attribute_code)}}" userInput="textSwatchOption1" stepKey="selectProduct1AttributeOption"/>
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct1"/>

<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductsGridPage2"/>
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="goToProduct2EditPage">
<argument name="product" value="$$createSimpleProduct2$$"/>
</actionGroup>
<selectOption selector="{{AdminProductAttributesSection.attributeDropdownByCode(textSwatchAttribute.attribute_code)}}" userInput="textSwatchOption1" stepKey="selectProduct2AttributeOption"/>
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct2"/>

<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductsGridPage3"/>
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="goToProduct3EditPage">
<argument name="product" value="$$createSimpleProduct3$$"/>
</actionGroup>
<selectOption selector="{{AdminProductAttributesSection.attributeDropdownByCode(textSwatchAttribute.attribute_code)}}" userInput="textSwatchOption2" stepKey="selectProduct3AttributeOption"/>
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct3"/>

<magentoCLI command="cron:run --group=index" stepKey="runCronIndexer"/>

<amOnPage url="$$createCategory.name$$.html" stepKey="amOnCategoryPage"/>
<waitForPageLoad stepKey="waitForPageToLoad"/>

<scrollTo selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="scrollToNextButton"/>
<click selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="clickOnNextPage"/>
<waitForPageLoad stepKey="waitForPageToLoad2"/>

<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle(textSwatchAttribute.default_label)}}" stepKey="expandAttribute"/>
<click selector="{{StorefrontCategorySidebarSection.attributeNthOption(textSwatchAttribute.attribute_code, '1')}}" stepKey="filterBySwatch1"/>
<waitForPageLoad stepKey="waitForPageToLoad3"/>

<actionGroup ref="AssertStorefrontCategoryCurrentPageIsFirstActionGroup" stepKey="assertCurrentPageIsFirst"/>
</test>
</tests>

0 comments on commit 475be33

Please sign in to comment.