Skip to content

Commit

Permalink
Static and functional tests fix, apply changes after review, extract …
Browse files Browse the repository at this point in the history
…navigation to next category page to action group
  • Loading branch information
Bartlomiejsz committed Apr 30, 2020
1 parent 475be33 commit 7630cb0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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">
<!-- Navigates storefront category next page from toolbar -->
<actionGroup name="StorefrontNavigateCategoryNextPageActionGroup">
<scrollTo selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="scrollToNextButton"/>
<click selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="clickOnNextPage"/>
<waitForPageLoad stepKey="waitForNextCategoryPageLoad"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ public function __construct(
}

/**
* Set filter and attribute objects
*
* @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter
*
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
Expand All @@ -108,6 +111,8 @@ public function setSwatchFilter(\Magento\Catalog\Model\Layer\Filter\AbstractFilt
}

/**
* Get attribute swatch data
*
* @return array
*/
public function getSwatchData()
Expand Down Expand Up @@ -138,8 +143,11 @@ public function getSwatchData()
}

/**
* Build filter option url
*
* @param string $attributeCode
* @param int $optionId
*
* @return string
*/
public function buildUrl($attributeCode, $optionId)
Expand All @@ -161,7 +169,10 @@ public function buildUrl($attributeCode, $optionId)
}

/**
* Get view data for option with no results
*
* @param Option $swatchOption
*
* @return array
*/
protected function getUnusedOption(Option $swatchOption)
Expand All @@ -174,8 +185,11 @@ protected function getUnusedOption(Option $swatchOption)
}

/**
* Get option data if visible
*
* @param FilterItem[] $filterItems
* @param Option $swatchOption
*
* @return array
*/
protected function getFilterOption(array $filterItems, Option $swatchOption)
Expand All @@ -190,8 +204,11 @@ protected function getFilterOption(array $filterItems, Option $swatchOption)
}

/**
* Get view data for option
*
* @param FilterItem $filterItem
* @param Option $swatchOption
*
* @return array
*/
protected function getOptionViewData(FilterItem $filterItem, Option $swatchOption)
Expand All @@ -211,7 +228,10 @@ protected function getOptionViewData(FilterItem $filterItem, Option $swatchOptio
}

/**
* Check if option should be visible
*
* @param FilterItem $filterItem
*
* @return bool
*/
protected function isOptionVisible(FilterItem $filterItem)
Expand All @@ -220,6 +240,8 @@ protected function isOptionVisible(FilterItem $filterItem)
}

/**
* Check if attribute values should be visible with no results
*
* @return bool
*/
protected function isShowEmptyResults()
Expand All @@ -228,7 +250,10 @@ protected function isShowEmptyResults()
}

/**
* Check if option should be disabled
*
* @param FilterItem $filterItem
*
* @return bool
*/
protected function isOptionDisabled(FilterItem $filterItem)
Expand All @@ -237,8 +262,11 @@ protected function isOptionDisabled(FilterItem $filterItem)
}

/**
* Retrieve filter item by id
*
* @param FilterItem[] $filterItems
* @param integer $id
*
* @return bool|FilterItem
*/
protected function getFilterItemById(array $filterItems, $id)
Expand All @@ -252,8 +280,11 @@ protected function getFilterItemById(array $filterItems, $id)
}

/**
* Get swatch image path
*
* @param string $type
* @param string $filename
*
* @return string
*/
public function getSwatchPath($type, $filename)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

<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>
<magentoCLI command="cache:clean block_html collections config full_page" stepKey="cleanInvalidatedCaches"/>
</before>

<after>
Expand All @@ -48,7 +48,7 @@

<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"/>
<magentoCLI command="cache:clean block_html collections config full_page" stepKey="cleanInvalidatedCaches"/>

<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<deleteData createDataKey="createSimpleProduct1" stepKey="deleteSimpleProduct1"/>
Expand All @@ -63,7 +63,8 @@
</actionGroup>
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="SaveAttributeSet"/>

<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductsGridPage"/>
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductIndexPage"/>
<actionGroup ref="ClearFiltersAdminProductGridActionGroup" stepKey="clearFiltersOnProductIndexPage"/>

<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="goToProduct1EditPage">
<argument name="product" value="$$createSimpleProduct1$$"/>
Expand All @@ -85,18 +86,16 @@
<selectOption selector="{{AdminProductAttributesSection.attributeDropdownByCode(textSwatchAttribute.attribute_code)}}" userInput="textSwatchOption2" stepKey="selectProduct3AttributeOption"/>
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct3"/>

<magentoCLI command="cron:run --group=index" stepKey="runCronIndexer"/>
<magentoCron groups="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"/>
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="navigateToCategoryPage">
<argument name="category" value="$$createCategory$$"/>
</actionGroup>
<actionGroup ref="StorefrontNavigateCategoryNextPageActionGroup" stepKey="navigateToCategoryNextPage"/>

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

<actionGroup ref="AssertStorefrontCategoryCurrentPageIsFirstActionGroup" stepKey="assertCurrentPageIsFirst"/>
</test>
Expand Down

0 comments on commit 7630cb0

Please sign in to comment.