Skip to content

Commit

Permalink
Merge branch '2.4-develop' into Refactoring-AdminConfigurableProductC…
Browse files Browse the repository at this point in the history
…reateTest
  • Loading branch information
kate-kyzyma committed Mar 17, 2021
2 parents e762b52 + 592c792 commit 8d08e94
Show file tree
Hide file tree
Showing 58 changed files with 1,321 additions and 178 deletions.
33 changes: 33 additions & 0 deletions app/code/Magento/AwsS3/Test/Mftf/Helper/S3FileAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ public function assertFileExists($filePath, $message = ''): void
$this->assertTrue($this->driver->isExists($filePath), $message);
}

/**
* Asserts that a file with the given glob pattern exists in the given path on the remote storage system
*
* @param string $path
* @param string $pattern
* @param string $message
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertGlobbedFileExists($path, $pattern, $message = ""): void
{
$files = $this->driver->search($pattern, $path);
$this->assertNotEmpty($files, $message);
}

/**
* Assert a file does not exist on the remote storage system
*
Expand Down Expand Up @@ -206,6 +221,24 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), $message);
}

/**
* Asserts that a file with the given glob pattern at the given path on the remote storage system contains a given string
*
* @param string $path
* @param string $pattern
* @param string $text
* @param int $fileIndex
* @param string $message
* @return void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ""): void
{
$files = $this->driver->search($pattern, $path);
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), $message);
}

/**
* Assert a file on the remote storage system does not contain a given string
*
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/Block/Ui/ProductViewCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public function getCurrentProductData()
$this->productRenderCollectorComposite
->collect($product, $productRender);
$data = $this->hydrator->extract($productRender);
$data['is_available'] = $product->isAvailable();

$currentProductData = [
'items' => [
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<data key="name">TestFooBar</data>
<data key="sku" unique="suffix">foobar</data>
</entity>
<entity name="ApiSimpleProductWithDoubleSpaces" type="product" extends="ApiSimpleProduct">
<data key="name">Simple Product Double Space</data>
<data key="sku" unique="suffix">simple-product double-space</data>
</entity>
<entity name="ApiSimpleProductWithSpecCharInName" type="product" extends="ApiSimpleProduct">
<data key="name">Pursuit Lumaflex&#38;trade; Tone Band</data>
<data key="sku" unique="suffix">x&#38;trade;</data>
Expand Down
35 changes: 35 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Helper/LocalFileAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ public function assertFileExists($filePath, $message = ''): void
$this->assertTrue($this->driver->isExists($realPath), $message);
}

/**
* Asserts that a file with the given glob pattern exists in the given path
*
* @param string $path
* @param string $pattern
* @param string $message
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertGlobbedFileExists($path, $pattern, $message = ""): void
{
$realPath = $this->expandPath($path);
$files = $this->driver->search($pattern, $realPath);
$this->assertNotEmpty($files, $message);
}

/**
* Assert a file does not exist
*
Expand Down Expand Up @@ -195,6 +211,25 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
$this->assertStringContainsString($text, $this->driver->fileGetContents($realPath), $message);
}

/**
* Asserts that a file with the given glob pattern at the given path contains a given string
*
* @param string $path
* @param string $pattern
* @param string $text
* @param int $fileIndex
* @param string $message
* @return void
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ""): void
{
$realPath = $this->expandPath($path);
$files = $this->driver->search($pattern, $realPath);
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), $message);
}

/**
* Assert a file does not contain a given string
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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="AdminShowDoubleSpacesInProductGrid">
<annotations>
<features value="Catalog"/>
<stories value="Edit products"/>
<title value="Show double spaces in the product grid"/>
<description value="Admin should be able to see double spaces in the Name and Sku fields in the product grid"/>
<testCaseId value="MC-40725"/>
<useCaseId value="MC-40122"/>
<severity value="AVERAGE"/>
<group value="Catalog"/>
</annotations>

<before>
<createData entity="ApiCategory" stepKey="createCategory"/>
<createData entity="ApiSimpleProductWithDoubleSpaces" stepKey="createProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<magentoCLI command="cron:run --group=index" stepKey="cronRun"/>
<magentoCLI command="cron:run --group=index" stepKey="cronRunSecondTime"/>
</before>

<after>
<actionGroup ref="AdminDeleteAllProductsFromGridActionGroup" stepKey="deleteProduct"/>
<actionGroup ref="ClearFiltersAdminProductGridActionGroup" stepKey="clearGridFilters"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
</after>

<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="AdminOpenCatalogProductPageActionGroup" stepKey="goToProductCatalogPage"/>
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="searchForProduct">
<argument name="product" value="$createProduct$"/>
</actionGroup>
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="assertProductName">
<argument name="column" value="Name"/>
<argument name="value" value="$createProduct.name$"/>
</actionGroup>
<actionGroup ref="AssertAdminProductGridCellActionGroup" stepKey="assertProductSku">
<argument name="column" value="SKU"/>
<argument name="value" value="$createProduct.sku$"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ public function testGetCurrentProductDataWithNonEmptyProduct()
{
$productMock = $this->getMockBuilder(ProductInterface::class)
->disableOriginalConstructor()
->addMethods(['isAvailable'])
->getMockForAbstractClass();
$productRendererMock = $this->getMockBuilder(ProductRenderInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$storeMock = $this->getMockBuilder(Store::class)
->disableOriginalConstructor()
->getMock();

$this->registryMock->expects($this->once())
->method('registry')
->with('product')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<settings>
<addField>true</addField>
<filter>text</filter>
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
<bodyTmpl>Magento_Catalog/grid/cells/preserved</bodyTmpl>
<label translate="true">Name</label>
</settings>
</column>
Expand All @@ -155,7 +155,7 @@
<column name="sku" sortOrder="60">
<settings>
<filter>text</filter>
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
<bodyTmpl>Magento_Catalog/grid/cells/preserved</bodyTmpl>
<label translate="true">SKU</label>
</settings>
</column>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<div class="data-grid-cell-content white-space-preserved" html="$col.getLabel($row())"/>
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ define([
return row['is_salable'];
},

/**
* Depends on this option, stock status text can be "In stock" or "Out Of Stock"
*
* @param {Object} row
* @returns {Boolean}
*/
isAvailable: function (row) {
return row['is_available'];
},

/**
* Depends on this option, "Add to cart" button can be shown or hide. Depends on backend configuration
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</button>
</form>
<?php else :?>
<?php if ($item->getIsSalable()) :?>
<?php if ($item->isAvailable()) :?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else :?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ $_helper = $block->getData('outputHelper');
<?php endforeach; ?>
</ol>
</div>
<?= $block->getToolbarHtml() ?>
<?= $block->getChildBlock('toolbar')->setIsBottom(true)->toHtml() ?>
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ $_item = null;
</form>
<?php endif; ?>
<?php else:?>
<?php if ($_item->getIsSalable()):?>
<?php if ($_item->isAvailable()):?>
<div class="stock available">
<span><?= $block->escapeHtml(__('In stock')) ?></span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,23 @@
*
* @var $block \Magento\Catalog\Block\Product\ProductList\Toolbar
*/

// phpcs:disable Magento2.Security.IncludeFile.FoundIncludeFile
// phpcs:disable PSR2.Methods.FunctionCallSignature.SpaceBeforeOpenBracket
?>
<?php if ($block->getCollection()->getSize()) :?>
<?php $widget = $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonDecode($block->getWidgetOptionsJson());
$widgetOptions = $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($widget['productListToolbarForm']);
?>
<div class="toolbar toolbar-products" data-mage-init='{"productListToolbarForm":<?= /* @noEscape */ $widgetOptions ?>}'>
<?php if ($block->isExpanded()) :?>
<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/viewmode.phtml')) ?>
<?php endif; ?>

<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/amount.phtml')) ?>

<?= $block->getPagerHtml() ?>

<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/limiter.phtml')) ?>

<?php if ($block->isExpanded()) :?>
<?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/sorter.phtml')) ?>
<?php endif; ?>
<?php if ($block->getIsBottom()): ?>
<?= $block->getPagerHtml() ?>
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/limiter.phtml')) ?>
<?php else: ?>
<?php if ($block->isExpanded()): ?>
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/viewmode.phtml')) ?>
<?php endif ?>
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/amount.phtml')) ?>
<?php if ($block->isExpanded()): ?>
<?= $block->fetchView($block->getTemplateFile('Magento_Catalog::product/list/toolbar/sorter.phtml')) ?>
<?php endif ?>
<?php endif ?>
</div>
<?php endif ?>
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
. ' data-mage-init=\'{ "redirectUrl": { "event": "click", url: "' . $block->escapeUrl($block->getAddToCartUrl($_product)) . '"} }\'>'
. '<span>' . $block->escapeHtml(__('Add to Cart')) . '</span></button>';
} else {
$info['button'] = $_product->getIsSalable() ? '<div class="stock available"><span>' . $block->escapeHtml(__('In stock')) . '</span></div>' :
$info['button'] = $_product->isAvailable() ? '<div class="stock available"><span>' . $block->escapeHtml(__('In stock')) . '</span></div>' :
'<div class="stock unavailable"><span>' . $block->escapeHtml(__('Out of stock')) . '</span></div>';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</button>
<?php endif; ?>
<?php else :?>
<?php if ($_product->getIsSalable()) :?>
<?php if ($_product->isAvailable()) :?>
<div class="stock available" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
<span><?= $block->escapeHtml(__('In stock')) ?></span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
</button>
<?php endif; ?>
<?php else :?>
<?php if ($_item->getIsSalable()) :?>
<?php if ($_item->isAvailable()) :?>
<div class="stock available">
<span><?= $block->escapeHtml(__('In stock')) ?></span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
</button>
<?php endif; ?>
<?php else :?>
<?php if ($_item->getIsSalable()) :?>
<?php if ($_item->isAvailable()) :?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else :?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
</button>
</if>

<ifnot args="isSalable($row())">
<if args="isAvailable($row()) === false">
<div class="stock unavailable">
<text args="$t('Availability')"/>
<span translate="'Out of stock'"/>
</div>
</ifnot>
</if>
</if>
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use Magento\Framework\App\Action\Action;
</button>
</form>
<?php else: ?>
<?php if ($_item->getIsSalable()): ?>
<?php if ($_item->isAvailable()): ?>
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
<?php else: ?>
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
Expand Down
Loading

0 comments on commit 8d08e94

Please sign in to comment.