Skip to content

Commit

Permalink
Merge branch '2.4-develop' into ASI-1830-stabilize-failing-mftf-tests…
Browse files Browse the repository at this point in the history
…-in-media-gallery-catalog-ui
  • Loading branch information
sivaschenko authored Sep 21, 2020
2 parents 5a7fc3b + 7ddd47e commit a3a3b7c
Show file tree
Hide file tree
Showing 27 changed files with 410 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,52 @@
* See COPYING.txt for license details.
*/

/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
use Magento\Framework\Escaper;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

/**
* @var SecureHtmlRenderer $secureRenderer
* @var Escaper $escaper
*/
?>
<!-- <?php if ($block->getTitle()): ?>
<h3><?= $block->escapeHtml($block->getTitle()) ?></h3>
<?php endif ?> -->
<?php if (!empty($tabs)): ?>
<div id="<?= $block->escapeHtmlAttr($block->getId()) ?>">
<?php $blockId = $block->getId() ?>
<div id="<?= $escaper->escapeHtmlAttr($blockId) ?>" class="hidden">
<ul class="tabs-horiz">
<?php foreach ($tabs as $_tab): ?>
<?php $tabId = $block->getTabId($_tab) ?>
<?php $_tabClass = 'tab-item-link ' . $block->getTabClass($_tab) . ' ' .
(preg_match('/\s?ajax\s?/', $_tab->getClass()) ? 'notloaded' : '') ?>
<?php $_tabType = (!preg_match('/\s?ajax\s?/', $_tabClass) && $block->getTabUrl($_tab) != '#') ? 'link' : '' ?>
<?php $_tabHref = $block->getTabUrl($_tab) == '#' ?
'#' . $block->getTabId($_tab) . '_content' :
'#' . $tabId . '_content' :
$block->getTabUrl($_tab) ?>
<li>
<a href="<?= $block->escapeUrl($_tabHref) ?>"
id="<?= $block->escapeHtmlAttr($block->getTabId($_tab)) ?>"
title="<?= $block->escapeHtmlAttr($block->getTabTitle($_tab)) ?>"
class="<?= $block->escapeHtmlAttr($_tabClass) ?>"
data-tab-type="<?= $block->escapeHtmlAttr($_tabType) ?>">
<a href="<?= $escaper->escapeUrl($_tabHref) ?>"
id="<?= $escaper->escapeHtmlAttr($tabId) ?>"
title="<?= $escaper->escapeHtmlAttr($block->getTabTitle($_tab)) ?>"
class="<?= $escaper->escapeHtmlAttr($_tabClass) ?>"
data-tab-type="<?= $escaper->escapeHtmlAttr($_tabType) ?>">
<span>
<span class="changed"
title="<?= $block->escapeHtmlAttr(__('The information in this tab has been changed.')) ?>"></span>
title="<?= $escaper->escapeHtmlAttr(__(
'The information in this tab has been changed.'
)) ?>"></span>
<span class="error"
title="<?= $block->escapeHtmlAttr(__(
title="<?= $escaper->escapeHtmlAttr(__(
'This tab contains invalid data. Please resolve this before saving.'
)) ?>"></span>
<span class="loader"
title="<?= $block->escapeHtmlAttr(__('Loading...')) ?>"></span>
<?= $block->escapeHtml($block->getTabLabel($_tab)) ?>
title="<?= $escaper->escapeHtmlAttr(__('Loading...')) ?>"></span>
<?= $escaper->escapeHtml($block->getTabLabel($_tab)) ?>
</span>
</a>
<div id="<?= $block->escapeHtmlAttr($block->getTabId($_tab)) ?>_content">
<div id="<?= $escaper->escapeHtmlAttr($tabId) ?>_content">
<?= /* @noEscape */ $block->getTabContent($_tab) ?>
</div>
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
'display:none',
'#' . $block->escapeJs($block->getTabId($_tab)) . '_content'
'#' . $escaper->escapeJs($tabId) . '_content'
); ?>
</li>
<?php endforeach; ?>
Expand All @@ -51,11 +58,12 @@
<?php $scriptString = <<<script
require(["jquery","mage/backend/tabs"], function($){
$(function() {
$('#{$block->getId()}').tabs({
active: '{$block->getActiveTabId()}',
destination: '#{$block->getDestElementId()}',
$('#{$escaper->escapeJs($blockId)}').tabs({
active: '{$escaper->escapeJs($block->getActiveTabId())}',
destination: '#{$escaper->escapeJs($block->getDestElementId())}',
shadowTabs: {$block->getAllShadowTabs()}
});
$('#{$escaper->escapeJs($blockId)}').removeClass('hidden');
});
});
script;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?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="AdminDeleteBundleDynamicPriceProductTest">
<annotations>
<features value="Bundle"/>
<stories value="Delete products"/>
<title value="Delete Bundle Dynamic Product"/>
<description value="Admin should be able to delete a bundle dynamic product"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-26056"/>
<group value="mtf_migrated"/>
<group value="bundle"/>
</annotations>
<before>
<!-- Create category and simple product -->
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
<createData entity="SimpleProduct2" stepKey="createSimpleProduct"/>

<!-- Create bundle product -->
<createData entity="ApiBundleProductPriceViewRange" stepKey="createDynamicBundleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="DropDownBundleOption" stepKey="bundleOption">
<requiredEntity createDataKey="createDynamicBundleProduct"/>
</createData>
<createData entity="ApiBundleLink" stepKey="createNewBundleLink">
<requiredEntity createDataKey="createDynamicBundleProduct"/>
<requiredEntity createDataKey="bundleOption"/>
<requiredEntity createDataKey="createSimpleProduct"/>
</createData>
<!-- TODO: Remove this action when MC-37719 will be fixed -->
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindexInvalidatedIndices">
<argument name="indices" value="cataloginventory_stock"/>
</actionGroup>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>
<actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteBundleProductBySku">
<argument name="sku" value="$createDynamicBundleProduct.sku$"/>
</actionGroup>
<!-- Verify product on Product Page -->
<amOnPage url="{{StorefrontProductPage.url($createDynamicBundleProduct.custom_attributes[url_key]$)}}" stepKey="openBundleProductPage"/>
<see selector="{{StorefrontProductInfoMainSection.productName}}" userInput="Whoops, our bad..." stepKey="seeWhoopsMessage"/>
<!-- Search for the product by sku -->
<actionGroup ref="StoreFrontQuickSearchActionGroup" stepKey="searchBySku">
<argument name="query" value="$createDynamicBundleProduct.sku$"/>
</actionGroup>
<!-- Should not see bundle product -->
<dontSee userInput="$createDynamicBundleProduct.sku$" selector="{{StorefrontCatalogSearchMainSection.searchResults}}" stepKey="dontSeeProduct"/>
<amOnPage url="{{StorefrontCategoryPage.url($createCategory.custom_attributes[url_key]$)}}" stepKey="openCategoryPage"/>
<!-- Should not see any products in category -->
<dontSee userInput="$createDynamicBundleProduct.name$" selector="{{StorefrontCategoryMainSection.productsList}}" stepKey="dontSeeProductInCategory"/>
<see selector="{{StorefrontCategoryMainSection.emptyProductMessage}}" userInput="We can't find products matching the selection." stepKey="seeEmptyProductMessage"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminDeleteBundleDynamicProductTest">
<test name="AdminDeleteBundleDynamicProductTest" deprecated="Use AdminDeleteBundleDynamicPriceProductTest instead">
<annotations>
<features value="Bundle"/>
<stories value="Delete products"/>
<title value="Delete Bundle Dynamic Product"/>
<description value="Admin should be able to delete a bundle dynamic product"/>
<title value="Deprecated. Delete Bundle Dynamic Product"/>
<description value="Deprecated. Admin should be able to delete a bundle dynamic product"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-11016"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MC-16393"/>
<issueId value="DEPRECATED">Use AdminDeleteBundleDynamicPriceProductTest instead</issueId>
</skip>
</annotations>
<before>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminOpenAttributeSetGridPageActionGroup">
<annotations>
<description>Open the Attribute Sets grid page.</description>
</annotations>

<amOnPage url="{{AdminProductAttributeSetGridPage.url}}" stepKey="goToAttributeSetPage"/>
<waitForPageLoad stepKey="waitForAttributeSetPageLoad"/>
</actionGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="GoToAttributeGridPageActionGroup">
<actionGroup name="GoToAttributeGridPageActionGroup" deprecated="Use AdminOpenAttributeSetGridPageActionGroup instead.">
<annotations>
<description>Goes to the Attribute Sets grid page.</description>
</annotations>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<!-- Assign attribute to set -->
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="GoToAttributeGridPageActionGroup" stepKey="goToAttributeSetPage"/>
<actionGroup ref="AdminOpenAttributeSetGridPageActionGroup" stepKey="goToAttributeSetPage"/>
<actionGroup ref="GoToAttributeSetByNameActionGroup" stepKey="openAttributeSetByName">
<argument name="name" value="$createAttributeSet.attribute_set_name$"/>
</actionGroup>
Expand Down
19 changes: 14 additions & 5 deletions app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*
* @api
* @since 100.0.2
Expand Down Expand Up @@ -152,6 +153,11 @@ class Storage extends \Magento\Framework\DataObject
*/
private $ioFile;

/**
* @var \Magento\Framework\File\Mime|null
*/
private $mime;

/**
* Construct
*
Expand All @@ -174,6 +180,7 @@ class Storage extends \Magento\Framework\DataObject
* @param \Magento\Framework\Filesystem\DriverInterface $file
* @param \Magento\Framework\Filesystem\Io\File|null $ioFile
* @param \Psr\Log\LoggerInterface|null $logger
* @param \Magento\Framework\File\Mime $mime
*
* @throws \Magento\Framework\Exception\FileSystemException
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
Expand All @@ -197,7 +204,8 @@ public function __construct(
array $data = [],
\Magento\Framework\Filesystem\DriverInterface $file = null,
\Magento\Framework\Filesystem\Io\File $ioFile = null,
\Psr\Log\LoggerInterface $logger = null
\Psr\Log\LoggerInterface $logger = null,
\Magento\Framework\File\Mime $mime = null
) {
$this->_session = $session;
$this->_backendUrl = $backendUrl;
Expand All @@ -217,6 +225,7 @@ public function __construct(
$this->_dirs = $dirs;
$this->file = $file ?: ObjectManager::getInstance()->get(\Magento\Framework\Filesystem\Driver\File::class);
$this->ioFile = $ioFile ?: ObjectManager::getInstance()->get(\Magento\Framework\Filesystem\Io\File::class);
$this->mime = $mime ?: ObjectManager::getInstance()->get(\Magento\Framework\File\Mime::class);
parent::__construct($data);
}

Expand Down Expand Up @@ -362,7 +371,7 @@ public function getFilesCollection($path, $type = null)
$item->setUrl($this->_cmsWysiwygImages->getCurrentUrl() . $item->getBasename());
$itemStats = $this->file->stat($item->getFilename());
$item->setSize($itemStats['size']);
$item->setMimeType(\mime_content_type($item->getFilename()));
$item->setMimeType($this->mime->getMimeType($item->getFilename()));

if ($this->isImage($item->getBasename())) {
$thumbUrl = $this->getThumbnailUrl($item->getFilename(), true);
Expand Down Expand Up @@ -647,7 +656,7 @@ public function resizeFile($source, $keepRatio = true)
$image->keepAspectRatio($keepRatio);

list($imageWidth, $imageHeight) = $this->getResizedParams($source);

$image->resize($imageWidth, $imageHeight);
$dest = $targetDir . '/' . $this->ioFile->getPathInfo($source)['basename'];
$image->save($dest);
Expand All @@ -670,7 +679,7 @@ private function getResizedParams(string $source): array

//phpcs:ignore Generic.PHP.NoSilencedErrors
list($imageWidth, $imageHeight) = @getimagesize($source);

if ($imageWidth && $imageHeight) {
$imageWidth = $configWidth > $imageWidth ? $imageWidth : $configWidth;
$imageHeight = $configHeight > $imageHeight ? $imageHeight : $configHeight;
Expand All @@ -679,7 +688,7 @@ private function getResizedParams(string $source): array
}
return [$configWidth, $configHeight];
}

/**
* Resize images on the fly in controller action
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<section name="AdminCustomerGridMainActionsSection">
<element name="addNewCustomer" type="button" selector="#add" timeout="30"/>
<element name="multicheck" type="checkbox" selector="#container>div>div.admin__data-grid-wrap>table>thead>tr>th.data-grid-multicheck-cell>div>label"/>
<element name="multicheckTick" type="checkbox" selector="#container>div>div.admin__data-grid-wrap>table>thead>tr>th.data-grid-multicheck-cell>div>input"/>
<element name="delete" type="button" selector="//*[contains(@class, 'admin__data-grid-header')]//span[contains(@class,'action-menu-item') and text()='Delete']"/>
<element name="actions" type="text" selector=".action-select"/>
<element name="customerCheckbox" type="button" selector="//*[contains(text(),'{{arg}}')]/parent::td/preceding-sibling::td/label[@class='data-grid-checkbox-cell-inner']//input" parameterized="true"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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="AdminGridSearchSelectAllTest">
<annotations>
<stories value="Selection should be removed during search."/>
<title value="Selection should be removed during search."/>
<description value="Empty selected before and after search, like it works for filter"/>
<testCaseId value="MC-37659"/>
<severity value="CRITICAL"/>
<group value="uI"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<!--Create three customers-->
<createData entity="Simple_US_Customer" stepKey="firstCustomer"/>
<createData entity="Simple_US_Customer" stepKey="secondCustomer"/>
<createData entity="Simple_US_Customer" stepKey="thirdCustomer"/>
</before>
<after>
<!--Remove two created customers, third already deleted-->
<deleteData createDataKey="firstCustomer" stepKey="deleteFirstCustomer"/>
<deleteData createDataKey="secondCustomer" stepKey="deleteSecondCustomer"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="openCustomerPage"/>
<!-- search Admin Data Grid By Keyword -->
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
<fillField selector="{{AdminDataGridHeaderSection.search}}" userInput="$$secondCustomer.email$$" stepKey="fillKeywordSearchFieldWithSecondCustomerEmail"/>
<click selector="{{AdminDataGridHeaderSection.submitSearch}}" stepKey="clickKeywordSearch"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<!-- Select all from dropdown -->
<actionGroup ref="AdminGridSelectAllActionGroup" stepKey="selectAllCustomers"/>
<!-- Clear searching By Keyword-->
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFiltersAfterSearch"/>
<waitForPageLoad stepKey="waitForPageLoadAfterSearchRemoved"/>
<!-- Check if selection has bee removed -->
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$secondCustomer.email$$)}}" stepKey="checkSecondCustomerCheckboxIsUnchecked"/>
<!-- Check delete action -->
<click selector="{{AdminCustomerGridMainActionsSection.customerCheckbox(($$thirdCustomer.email$$)}}" stepKey="selectThirdCustomer"/>
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$thirdCustomer.email$$)}}" stepKey="checkThirdCustomerIsChecked"/>
<!-- Use delete action for selected -->
<click selector="{{AdminCustomerGridMainActionsSection.actions}}" stepKey="clickActions"/>
<click selector="{{AdminCustomerGridMainActionsSection.delete}}" stepKey="clickDelete"/>
<waitForAjaxLoad stepKey="waitForLoadConfirmation"/>
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete"/>
<!-- Check if only one record record has been deleted -->
<see selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) were deleted" stepKey="seeSuccess"/>
</test>
</tests>
Loading

0 comments on commit a3a3b7c

Please sign in to comment.