Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.4-devel…
Browse files Browse the repository at this point in the history
…op latest changes

Accepted Community Pull Requests:
 - #29921: Fixed saving asset keywords links with db prefix (by @sivaschenko)
 - #29896: Move "Add Selected" button to be the last in Old Media Gallery (by @joweecaquicla)
 - #28653: Removed unused construct parameters (by @Usik2203)
 - #29724: #29704 :- Submit search button in form-mini should be disabled until minimum search length is reached (by @konarshankar07)


Fixed GitHub Issues:
 - #29531: [Issue] Removed unused construct parameters (reported by @m2-assistant[bot]) has been fixed in #28653 by @Usik2203 in 2.4-develop branch
   Related commits:
     1. 7eeba38
     2. e15fc1d
     3. de7dab3
     4. 35043cf

 - #29704: Submit search button in form-mini should be disabled until minimum search length is reached (reported by @markshust) has been fixed in #29724 by @konarshankar07 in 2.4-develop branch
   Related commits:
     1. f230257
     2. 1973efb
     3. 50b83be
     4. 268277e
  • Loading branch information
sivaschenko authored Sep 7, 2020
2 parents f61214d + 46b6ed5 commit 1c9ba3e
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;

/**
* Class AdvancedPricing
* Import advanced pricing class
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand All @@ -19,43 +19,27 @@
class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
{
const VALUE_ALL_GROUPS = 'ALL GROUPS';

const VALUE_ALL_WEBSITES = 'All Websites';

const COL_SKU = 'sku';

const COL_TIER_PRICE_WEBSITE = 'tier_price_website';

const COL_TIER_PRICE_CUSTOMER_GROUP = 'tier_price_customer_group';

const COL_TIER_PRICE_QTY = 'tier_price_qty';

const COL_TIER_PRICE = 'tier_price';

const COL_TIER_PRICE_PERCENTAGE_VALUE = 'percentage_value';

const COL_TIER_PRICE_TYPE = 'tier_price_value_type';

const TIER_PRICE_TYPE_FIXED = 'Fixed';

const TIER_PRICE_TYPE_PERCENT = 'Discount';

const TABLE_TIER_PRICE = 'catalog_product_entity_tier_price';

const DEFAULT_ALL_GROUPS_GROUPED_PRICE_VALUE = '0';

const ENTITY_TYPE_CODE = 'advanced_pricing';

const VALIDATOR_MAIN = 'validator';

const VALIDATOR_WEBSITE = 'validator_website';

/**
* @deprecated
* @see VALIDATOR_TIER_PRICE
*/
private const VALIDATOR_TEAR_PRICE = 'validator_tier_price';

private const VALIDATOR_TIER_PRICE = 'validator_tier_price';

/**
Expand Down Expand Up @@ -176,10 +160,8 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
* @param \Magento\ImportExport\Helper\Data $importExportData
* @param \Magento\ImportExport\Model\ResourceModel\Import\Data $importData
* @param \Magento\Eav\Model\Config $config
* @param \Magento\Framework\App\ResourceConnection $resource
* @param \Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper
* @param \Magento\Framework\Stdlib\StringUtils $string
* @param ProcessingErrorAggregatorInterface $errorAggregator
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
* @param \Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory $resourceFactory
Expand All @@ -197,10 +179,8 @@ public function __construct(
\Magento\Framework\Json\Helper\Data $jsonHelper,
\Magento\ImportExport\Helper\Data $importExportData,
\Magento\ImportExport\Model\ResourceModel\Import\Data $importData,
\Magento\Eav\Model\Config $config,
\Magento\Framework\App\ResourceConnection $resource,
\Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper,
\Magento\Framework\Stdlib\StringUtils $string,
ProcessingErrorAggregatorInterface $errorAggregator,
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
\Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory $resourceFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as RowValidatorInterface;
use Magento\CatalogImportExport\Model\Import\Product\StoreResolver;
use Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory as ResourceFactory;
use Magento\Eav\Model\Config;
use Magento\Eav\Model\Entity\Type;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
Expand All @@ -26,7 +25,6 @@
use Magento\Framework\Json\Helper\Data;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\Stdlib\StringUtils;
use Magento\ImportExport\Model\Import;
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
use Magento\ImportExport\Model\ResourceModel\Helper;
Expand Down Expand Up @@ -99,11 +97,6 @@ class AdvancedPricingTest extends AbstractImportTestCase
*/
protected $dataSourceModel;

/**
* @var Config
*/
protected $eavConfig;

/**
* @var TimezoneInterface|MockObject
*/
Expand Down Expand Up @@ -139,11 +132,6 @@ class AdvancedPricingTest extends AbstractImportTestCase
*/
protected $advancedPricing;

/**
* @var StringUtils
*/
protected $stringObject;

/**
* @var ProcessingErrorAggregatorInterface
*/
Expand All @@ -165,10 +153,8 @@ protected function setUp(): void
);
$this->resource->method('getConnection')->willReturn($this->connection);
$this->dataSourceModel = $this->createMock(\Magento\ImportExport\Model\ResourceModel\Import\Data::class);
$this->eavConfig = $this->createMock(Config::class);
$entityType = $this->createMock(Type::class);
$entityType->method('getEntityTypeId')->willReturn('');
$this->eavConfig->method('getEntityType')->willReturn($entityType);
$this->resourceFactory = $this->getMockBuilder(
\Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory::class
)
Expand All @@ -193,7 +179,6 @@ protected function setUp(): void
$this->tierPriceValidator = $this->createMock(
TierPrice::class
);
$this->stringObject = $this->createMock(StringUtils::class);
$this->errorAggregator = $this->getErrorAggregatorObject();
$this->dateTime = $this->getMockBuilder(DateTime::class)
->disableOriginalConstructor()
Expand Down Expand Up @@ -1070,10 +1055,8 @@ private function getAdvancedPricingMock($methods = [])
$this->jsonHelper,
$this->importExportData,
$this->dataSourceModel,
$this->eavConfig,
$this->resource,
$this->resourceHelper,
$this->stringObject,
$this->errorAggregator,
$this->dateTime,
$this->resourceFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected function _construct()
'type' => 'button'
],
0,
0,
100,
'header'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private function deleteAssetKeywords(int $assetId, array $obsoleteKeywordIds): v
/** @var Mysql $connection */
$connection = $this->resourceConnection->getConnection();
$connection->delete(
$connection->getTableName(
$this->resourceConnection->getTableName(
self::TABLE_ASSET_KEYWORD
),
[
Expand Down Expand Up @@ -196,7 +196,7 @@ private function setAssetUpdatedAt(int $assetId): void
try {
$connection = $this->resourceConnection->getConnection();
$connection->update(
$connection->getTableName(self::TABLE_MEDIA_ASSET),
$this->resourceConnection->getTableName(self::TABLE_MEDIA_ASSET),
['updated_at' => null],
['id =?' => $assetId]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ public function testAssetKeywordsSave(int $assetId, array $keywordIds, array $va
$this->resourceConnectionMock->expects($this->exactly(2))
->method('getConnection')
->willReturn($this->connectionMock);
$this->resourceConnectionMock->expects($this->once())
$this->resourceConnectionMock->expects($this->any())
->method('getTableName')
->with('media_gallery_asset_keyword')
->willReturn('prefix_media_gallery_asset_keyword');
->willReturnMap(
[
['media_gallery_asset_keyword', 'default', 'prefix_media_gallery_asset_keyword'],
['media_gallery_asset', 'default', 'prefix_media_gallery_asset']
]
);
$this->connectionMock->expects($this->once())
->method('insertArray')
->with(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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">
<!-- Filter by search query and select -->
<actionGroup name="AssertStorefrontVerifySearchButtonIsDisabledActionGroup">
<annotations>
<description>Verify search button has disabled attribute</description>
</annotations>

<grabAttributeFrom selector="{{StorefrontQuickSearchSection.searchButton}}" userInput="disabled" stepKey="grabSearchButtonDisabledAttribute"/>

<assertEquals stepKey="assertSearchButtonDisabled">
<actualResult type="const">$grabSearchButtonDisabledAttribute</actualResult>
<expectedResult type="string">true</expectedResult>
</assertEquals>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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">
<!-- Filter by search query and select -->
<actionGroup name="AssertStorefrontVerifySearchButtonIsEnabledActionGroup">
<annotations>
<description>Verify search button does not disabled attribute</description>
</annotations>

<grabAttributeFrom selector="{{StorefrontQuickSearchSection.searchButton}}" userInput="disabled" stepKey="grabSearchButtonAttribute"/>

<assertEmpty stepKey="assertSearchButtonEnabled">
<actualResult type="string">$grabSearchButtonAttribute</actualResult>
</assertEmpty>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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="StoreFrontFillSearchActionGroup">
<arguments>
<argument name="query" type="string"/>
</arguments>

<fillField stepKey="fillSearchField" selector="{{StorefrontQuickSearchSection.searchPhrase}}" userInput="{{query}}"/>
<waitForElementVisible selector="{{StorefrontQuickSearchSection.searchButton}}" stepKey="waitForSubmitButton"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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="StorefrontVerifySearchButtonDisabledTillMinimumSearchLengthHitTest">
<annotations>
<stories value="Search Term Disabled"/>
<title value="Verify search button is disabled if search term is less than minimum search length"/>
<description value="Storefront verify search button is disabled if search term is less than minimum search length"/>
<severity value="AVERAGE"/>
<testCaseId value="MC-37380"/>
<group value="searchFrontend"/>
</annotations>

<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="openStoreFrontHomePage"/>

<actionGroup ref="StoreFrontFillSearchActionGroup" stepKey="fillSearchByTextLessThanMinimumSearchLength">
<argument name="query" value="Te"/>
</actionGroup>

<actionGroup ref="AssertStorefrontVerifySearchButtonIsDisabledActionGroup" stepKey="assertSearchButtonIsDisabled"/>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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="StorefrontVerifySearchButtonEnabledAfterMinimumSearchLengthHitTest">
<annotations>
<stories value="Search Button Not Disabled"/>
<title value="Verify search button is not disabled if search term is equal or greater than minimum search length"/>
<description value="Storefront verify search button is not disabled if search term is equal or greater than minimum search length"/>
<severity value="AVERAGE"/>
<testCaseId value="MC-37381"/>
<group value="searchFrontend"/>
</annotations>

<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="openStoreFrontHomePage"/>

<actionGroup ref="StoreFrontFillSearchActionGroup" stepKey="fillSearchByTextMoreThanMinimumSearchLength">
<argument name="query" value="Magento"/>
</actionGroup>

<actionGroup ref="AssertStorefrontVerifySearchButtonIsEnabledActionGroup" stepKey="assertSearchButtonIsNotDisabled"/>
</test>
</tests>
9 changes: 6 additions & 3 deletions app/code/Magento/Search/view/frontend/web/js/form-mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ define([
break;

case $.ui.keyCode.ENTER:
this.searchForm.trigger('submit');
e.preventDefault();
if (this.element.val().length >= parseInt(this.options.minSearchLength, 10)) {
this.searchForm.trigger('submit');
e.preventDefault();
}
break;

case $.ui.keyCode.DOWN:
Expand Down Expand Up @@ -294,9 +296,10 @@ define([
dropdown = $('<ul role="listbox"></ul>'),
value = this.element.val();

this.submitBtn.disabled = isEmpty(value);
this.submitBtn.disabled = true;

if (value.length >= parseInt(this.options.minSearchLength, 10)) {
this.submitBtn.disabled = false;
$.getJSON(this.options.url, {
q: value
}, $.proxy(function (data) {
Expand Down

0 comments on commit 1c9ba3e

Please sign in to comment.