Skip to content

Commit

Permalink
Merge pull request #4793 from magento-epam/EPAM-PR-73
Browse files Browse the repository at this point in the history
- Fixed [FT] Not pass functional test \Magento\Catalog\Test\TestCase\Product\ProductTypeSwitchingOnUpdateTest
- Fixed [GITHUB] Inconsistent CSV file Import error: #7495
- Fixed Incorrect behavior in the category menu on the Storefront
  • Loading branch information
irenelagno authored Sep 18, 2019
2 parents 0a390bb + 102f608 commit 3ee05a4
Show file tree
Hide file tree
Showing 14 changed files with 692 additions and 10 deletions.
27 changes: 24 additions & 3 deletions app/code/Magento/Catalog/Plugin/Block/Topmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Plugin\Block;

use Magento\Catalog\Model\Category;
Expand Down Expand Up @@ -156,12 +158,13 @@ private function getCurrentCategory()
*/
private function getCategoryAsArray($category, $currentCategory, $isParentActive)
{
$categoryId = $category->getId();
return [
'name' => $category->getName(),
'id' => 'category-node-' . $category->getId(),
'id' => 'category-node-' . $categoryId,
'url' => $this->catalogCategory->getCategoryUrl($category),
'has_active' => in_array((string)$category->getId(), explode('/', $currentCategory->getPath()), true),
'is_active' => $category->getId() == $currentCategory->getId(),
'has_active' => in_array((string)$categoryId, explode('/', (string)$currentCategory->getPath()), true),
'is_active' => $categoryId == $currentCategory->getId(),
'is_category' => true,
'is_parent_active' => $isParentActive
];
Expand Down Expand Up @@ -193,4 +196,22 @@ protected function getCategoryTree($storeId, $rootId)

return $collection;
}

/**
* Add active
*
* @param \Magento\Theme\Block\Html\Topmenu $subject
* @param string[] $result
* @return string[]
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetCacheKeyInfo(\Magento\Theme\Block\Html\Topmenu $subject, array $result)
{
$activeCategory = $this->getCurrentCategory();
if ($activeCategory) {
$result[] = Category::CACHE_TAG . '_' . $activeCategory->getId();
}

return $result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@
<attachFile selector="{{AdminCategoryContentSection.uploadImageFile}}" userInput="{{image.file}}" stepKey="uploadFile"/>
<waitForAjaxLoad time="30" stepKey="waitForAjaxUpload"/>
<waitForLoadingMaskToDisappear stepKey="waitForLoading"/>
<see selector="{{AdminCategoryContentSection.imageFileName}}" userInput="{{image.file}}" stepKey="seeImage"/>
<grabTextFrom selector="{{AdminCategoryContentSection.imageFileName}}" stepKey="grabCategoryFileName"/>
<assertRegExp stepKey="assertEquals" message="pass">
<expectedResult type="string">/magento-logo(_[0-9]+)*?\.png$/</expectedResult>
<actualResult type="variable">grabCategoryFileName</actualResult>
</assertRegExp>
</actionGroup>

<!-- Remove image from category -->
Expand Down Expand Up @@ -128,7 +132,11 @@
<conditionalClick selector="{{AdminCategoryContentSection.sectionHeader}}" dependentSelector="{{AdminCategoryContentSection.uploadButton}}" visible="false" stepKey="openContentSection"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<waitForElementVisible selector="{{AdminCategoryContentSection.uploadButton}}" stepKey="seeImageSectionIsReady"/>
<see selector="{{AdminCategoryContentSection.imageFileName}}" userInput="{{image.file}}" stepKey="seeImage"/>
<grabTextFrom selector="{{AdminCategoryContentSection.imageFileName}}" stepKey="grabCategoryFileName"/>
<assertRegExp stepKey="assertEquals" message="pass">
<expectedResult type="string">/magento-logo(_[0-9]+)*?\.png$/</expectedResult>
<actualResult type="variable">grabCategoryFileName</actualResult>
</assertRegExp>
</actionGroup>

<!-- Action to navigate to Media Gallery. Used in tests to cleanup uploaded images -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<section name="AdminCategorySidebarTreeSection">
<element name="collapseAll" type="button" selector=".tree-actions a:first-child"/>
<element name="expandAll" type="button" selector=".tree-actions a:last-child"/>
<element name="categoryHighlighted" type="text" selector="//div[@id='store.menu']//span[contains(text(),'{{name}}')]/ancestor::li" parameterized="true" timeout="30"/>
<element name="categoryNotHighlighted" type="text" selector="ul[id=\'ui-id-2\'] li[class~=\'active\']" timeout="30"/>
<element name="categoryTreeRoot" type="text" selector="div.x-tree-root-node>li.x-tree-node:first-of-type>div.x-tree-node-el:first-of-type" timeout="30"/>
<element name="categoryInTree" type="text" selector="//a/span[contains(text(), '{{name}}')]" parameterized="true" timeout="30"/>
<element name="categoryInTreeUnderRoot" type="text" selector="//li/ul/li[@class='x-tree-node']/div/a/span[contains(text(), '{{name}}')]" parameterized="true"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?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="AdminVirtualProductTypeSwitchingToDownloadableProductTest">
<annotations>
<features value="Catalog"/>
<stories value="Product type switching"/>
<title value="Virtual product type switching on editing to Downloadable product"/>
<description value="Virtual product type switching on editing to Downloadable product"/>
<testCaseId value="MC-17954"/>
<useCaseId value="MAGETWO-44170"/>
<severity value="MAJOR"/>
<group value="catalog"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
<!--Create product-->
<comment userInput="Create product" stepKey="commentCreateProduct"/>
<createData entity="VirtualProduct" stepKey="createProduct"/>
</before>
<after>
<!--Delete product-->
<comment userInput="Delete product" stepKey="commentDeleteProduct"/>
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearProductFilters"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>
<!--Change product type to Downloadable-->
<comment userInput="Change product type to Downloadable" stepKey="commentCreateDownloadable"/>
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="gotToDownloadableProductPage"/>
<waitForPageLoad stepKey="waitForDownloadableProductPageLoad"/>
<actionGroup ref="AdminAddDownloadableLinkInformationActionGroup" stepKey="addDownloadableLinkInformation"/>
<checkOption selector="{{AdminProductDownloadableSection.isLinksPurchasedSeparately}}" stepKey="checkOptionPurchaseSeparately"/>
<actionGroup ref="addDownloadableProductLinkWithMaxDownloads" stepKey="addDownloadableProductLink">
<argument name="link" value="downloadableLinkWithMaxDownloads"/>
</actionGroup>
<actionGroup ref="saveProductForm" stepKey="saveDownloadableProductForm"/>
<!--Assert downloadable product on Admin product page grid-->
<comment userInput="Assert configurable product in Admin product page grid" stepKey="commentAssertDownloadableProductOnAdmin"/>
<amOnPage url="{{AdminCatalogProductPage.url}}" stepKey="goToCatalogProductPage"/>
<actionGroup ref="filterProductGridBySku2" stepKey="filterProductGridBySku">
<argument name="sku" value="$$createProduct.sku$$"/>
</actionGroup>
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="$$createProduct.name$$" stepKey="seeDownloadableProductNameInGrid"/>
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Downloadable Product" stepKey="seeDownloadableProductTypeInGrid"/>
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearDownloadableProductFilters"/>
<!--Assert downloadable product on storefront-->
<comment userInput="Assert downloadable product on storefront" stepKey="commentAssertDownloadableProductOnStorefront"/>
<amOnPage url="{{StorefrontProductPage.url($$createProduct.name$$)}}" stepKey="openDownloadableProductPage"/>
<waitForPageLoad stepKey="waitForStorefrontDownloadableProductPageLoad"/>
<see userInput="IN STOCK" selector="{{StorefrontProductInfoMainSection.productStockStatus}}" stepKey="assertDownloadableProductInStock"/>
<scrollTo selector="{{StorefrontDownloadableProductSection.downloadableLinkBlock}}" stepKey="scrollToLinksInStorefront"/>
<seeElement selector="{{StorefrontDownloadableProductSection.downloadableLinkLabel(downloadableLinkWithMaxDownloads.title)}}" stepKey="seeDownloadableLink" />
</test>
<test name="AdminDownloadableProductTypeSwitchingToSimpleProductTest" extends="AdminVirtualProductTypeSwitchingToDownloadableProductTest">
<annotations>
<features value="Catalog"/>
<stories value="Product type switching"/>
<title value="Downloadable product type switching on editing to Simple product"/>
<description value="Downloadable product type switching on editing to Simple product"/>
<testCaseId value="MC-17955"/>
<useCaseId value="MAGETWO-44170"/>
<severity value="MAJOR"/>
<group value="catalog"/>
</annotations>
<!--Change product type to Simple-->
<comment userInput="Change product type to Simple Product" stepKey="commentCreateSimple"/>
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="gotToProductPage"/>
<waitForPageLoad stepKey="waitForProductPageLoad"/>
<actionGroup ref="AdminAddDownloadableLinkInformationActionGroup" stepKey="addDownloadableLinkInformation"/>
<selectOption selector="{{AdminProductFormSection.productWeightSelect}}" userInput="This item has weight" stepKey="selectWeightForProduct"/>
<actionGroup ref="saveProductForm" stepKey="saveProductForm"/>
<!--Assert simple product on Admin product page grid-->
<comment userInput="Assert simple product in Admin product page grid" stepKey="commentAssertProductOnAdmin"/>
<amOnPage url="{{AdminCatalogProductPage.url}}" stepKey="goToCatalogSimpleProductPage"/>
<actionGroup ref="filterProductGridBySku2" stepKey="filterSimpleProductGridBySku">
<argument name="sku" value="$$createProduct.sku$$"/>
</actionGroup>
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="$$createProduct.name$$" stepKey="seeSimpleProductNameInGrid"/>
<see selector="{{AdminProductGridSection.productGridCell('1', 'Type')}}" userInput="Simple Product" stepKey="seeSimpleProductTypeInGrid"/>
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearSimpleProductFilters"/>
<!--Assert simple product on storefront-->
<comment userInput="Assert simple product on storefront" stepKey="commentAssertSimpleProductOnStorefront"/>
<amOnPage url="{{StorefrontProductPage.url($$createProduct.name$$)}}" stepKey="openSimpleProductPage"/>
<waitForPageLoad stepKey="waitForStorefrontSimpleProductPageLoad"/>
<see userInput="IN STOCK" selector="{{StorefrontProductInfoMainSection.productStockStatus}}" stepKey="assertSimpleProductInStock"/>
<dontSeeElement selector="{{StorefrontDownloadableProductSection.downloadableLinkLabel(downloadableLinkWithMaxDownloads.title)}}" stepKey="dontSeeDownloadableLink" />
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?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="StorefrontCategoryHighlightedAndProductDisplayedTest">
<annotations>
<features value="Catalog"/>
<stories value="Category"/>
<title value="Сheck that current category is highlighted and all products displayed for it"/>
<description value="Сheck that current category is highlighted and all products displayed for it"/>
<severity value="MAJOR"/>
<testCaseId value="MC-19626"/>
<useCaseId value="MAGETWO-98748"/>
<group value="Catalog"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
<createData entity="SimpleSubCategory" stepKey="category1"/>
<createData entity="SimpleSubCategory" stepKey="category2"/>
<createData entity="SimpleSubCategory" stepKey="category3"/>
<createData entity="SimpleSubCategory" stepKey="category4"/>
<createData entity="SimpleProduct" stepKey="product1">
<requiredEntity createDataKey="category1"/>
</createData>
<createData entity="SimpleProduct" stepKey="product2">
<requiredEntity createDataKey="category1"/>
</createData>
<createData entity="SimpleProduct" stepKey="product3">
<requiredEntity createDataKey="category2"/>
</createData>
<createData entity="SimpleProduct" stepKey="product4">
<requiredEntity createDataKey="category2"/>
</createData>
</before>
<after>
<deleteData createDataKey="product1" stepKey="deleteProduct1"/>
<deleteData createDataKey="product2" stepKey="deleteProduct2"/>
<deleteData createDataKey="product3" stepKey="deleteProduct3"/>
<deleteData createDataKey="product4" stepKey="deleteProduct4"/>
<deleteData createDataKey="category1" stepKey="deleteCategory1"/>
<deleteData createDataKey="category2" stepKey="deleteCategory2"/>
<deleteData createDataKey="category3" stepKey="deleteCategory3"/>
<deleteData createDataKey="category4" stepKey="deleteCategory4"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>
<!--Open Storefront home page-->
<comment userInput="Open Storefront home page" stepKey="openStorefrontHomePage"/>
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToStorefrontHomePage"/>
<waitForPageLoad stepKey="waitForSimpleProductPage"/>
<!--Click on first category-->
<comment userInput="Click on first category" stepKey="openFirstCategoryPage"/>
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$category1.name$$)}}" stepKey="clickCategory1Name"/>
<waitForPageLoad stepKey="waitForCategory1Page"/>
<!--Check if current category is highlighted and the others are not-->
<comment userInput="Check if current category is highlighted and the others are not" stepKey="checkCateg1NameIsHighlighted"/>
<grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$category1.name$$)}}" userInput="class" stepKey="grabCategory1Class"/>
<assertContains expectedType="string" expected="active" actual="$grabCategory1Class" stepKey="assertCategory1IsHighlighted"/>
<executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedAmount"/>
<assertEquals expectedType="int" expected="1" actual="$highlightedAmount" stepKey="assertRestCategories1IsNotHighlighted"/>
<!--See products in the category page-->
<comment userInput="See products in the category page" stepKey="seeProductsInCategoryPage"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($product1.name$)}}" stepKey="seeProduct1InCategoryPage"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($product2.name$)}}" stepKey="seeProduct2InCategoryPage"/>
<!--Click on second category-->
<comment userInput="Click on second category" stepKey="openSecondCategoryPage"/>
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$category2.name$$)}}" stepKey="clickCategory2Name"/>
<waitForPageLoad stepKey="waitForCategory2Page"/>
<!--Check if current category is highlighted and the others are not-->
<comment userInput="Check if current category is highlighted and the others are not" stepKey="checkCateg2NameIsHighlighted"/>
<grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$category2.name$$)}}" userInput="class" stepKey="grabCategory2Class"/>
<assertContains expectedType="string" expected="active" actual="$grabCategory2Class" stepKey="assertCategory2IsHighlighted"/>
<executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedAmount2"/>
<assertEquals expectedType="int" expected="1" actual="$highlightedAmount2" stepKey="assertRestCategories1IsNotHighlighted2"/>
<!--Assert products in second category page-->
<comment userInput="Assert products in second category page" stepKey="commentAssertProducts"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($product3.name$)}}" stepKey="seeProduct3InCategoryPage"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($product4.name$)}}" stepKey="seeProduct4InCategoryPage"/>
</test>
</tests>
9 changes: 4 additions & 5 deletions app/code/Magento/CatalogImportExport/Model/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
const COL_PRODUCT_WEBSITES = '_product_websites';

/**
* Media gallery attribute code.
* Attribute code for media gallery.
*/
const MEDIA_GALLERY_ATTRIBUTE_CODE = 'media_gallery';

Expand All @@ -151,12 +151,12 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
const COL_MEDIA_IMAGE = '_media_image';

/**
* Inventory use config.
* Inventory use config label.
*/
const INVENTORY_USE_CONFIG = 'Use Config';

/**
* Inventory use config prefix.
* Prefix for inventory use config.
*/
const INVENTORY_USE_CONFIG_PREFIX = 'use_config_';

Expand Down Expand Up @@ -1886,6 +1886,7 @@ protected function _saveProducts()

return $this;
}
//phpcs:enable Generic.Metrics.NestingLevel

/**
* Prepare array with image states (visible or hidden from product page)
Expand Down Expand Up @@ -2736,8 +2737,6 @@ protected function _saveValidatedBunches()
try {
$rowData = $source->current();
} catch (\InvalidArgumentException $e) {
$this->addRowError($e->getMessage(), $this->_processedRowsCount);
$this->_processedRowsCount++;
$source->next();
continue;
}
Expand Down
Loading

0 comments on commit 3ee05a4

Please sign in to comment.