Skip to content

Commit

Permalink
Merge pull request #7755 from magento-l3/PR_29_JUN_2022_odubovyk
Browse files Browse the repository at this point in the history
L3 Bugfix delivery
  • Loading branch information
ishakhsuvarov authored Jul 19, 2022
2 parents 9c3a50c + ab5e651 commit 25822df
Show file tree
Hide file tree
Showing 20 changed files with 504 additions and 92 deletions.
6 changes: 2 additions & 4 deletions app/code/Magento/Authorization/Test/Fixture/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@

use Magento\Authorization\Model\Acl\Role\Group;
use Magento\Authorization\Model\ResourceModel\Role as RoleResource;
use Magento\Authorization\Model\RoleFactory;
use Magento\Authorization\Model\RulesFactory;
use Magento\Authorization\Model\UserContextInterface;
use Magento\Framework\DataObject;
use Magento\SharedCatalog\Model\SharedCatalogFactory;
use Magento\TestFramework\Fixture\Data\ProcessorInterface;
use Magento\TestFramework\Fixture\RevertibleDataFixtureInterface;
use Magento\Authorization\Model\RoleFactory;
use Magento\Authorization\Model\RulesFactory;
use Magento\User\Model\UserFactory;

/**
* Creating a new admin role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,23 @@
<selectOption selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$simpleProduct1.name$$ +$$$simpleProduct1.price$$.00" stepKey="selectOption0Product0"/>
<seeOptionIsSelected selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$simpleProduct1.name$$ +$$$simpleProduct1.price$$.00" stepKey="checkOption0Product0"/>
<fillField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="3" stepKey="fillQuantity00"/>
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="3" stepKey="checkQuantity00"/>
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="03" stepKey="checkQuantity00"/>

<selectOption selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$simpleProduct2.name$$ +$$$simpleProduct2.price$$.00" stepKey="selectOption0Product1"/>
<seeOptionIsSelected selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$simpleProduct2.name$$ +$$$simpleProduct2.price$$.00" stepKey="checkOption0Product1"/>
<fillField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="3" stepKey="fillQuantity01"/>
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="3" stepKey="checkQuantity01"/>
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="03" stepKey="checkQuantity01"/>

<!--"Radio Buttons" type option-->
<checkOption selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '1')}}" stepKey="selectOption1Product0"/>
<seeCheckboxIsChecked selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '1')}}" stepKey="checkOption1Product0"/>
<fillField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="3" stepKey="fillQuantity10"/>
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="3" stepKey="checkQuantity10"/>
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="03" stepKey="checkQuantity10"/>

<checkOption selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '2')}}" stepKey="selectOption1Product1"/>
<seeCheckboxIsChecked selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '2')}}" stepKey="checkOption1Product1"/>
<fillField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="3" stepKey="fillQuantity11"/>
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="3" stepKey="checkQuantity11"/>
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="03" stepKey="checkQuantity11"/>

<!--"Checkbox" type option-->
<!--This option does not support user defined quantities-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<!--"Drop-down" type option-->
<selectOption selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$createProduct1.name$$ +$$$createProduct1.price$$.00" stepKey="selectOption0Product0"/>
<seeOptionIsSelected selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$createProduct1.name$$ +$$$createProduct1.price$$.00" stepKey="checkOption0Product0"/>
<fillField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="-" stepKey="emptyDropdownQuantity"/>
<fillField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="-1" stepKey="fillQuantity00"/>
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="-1" stepKey="checkQuantity00"/>
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCartDropDown"/>
Expand All @@ -88,6 +89,7 @@
<!--"Radio Buttons" type option-->
<checkOption selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '1')}}" stepKey="selectOption1Product0"/>
<seeCheckboxIsChecked selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '1')}}" stepKey="checkOption1Product0"/>
<fillField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="-" stepKey="emptyRadioQuantity"/>
<fillField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="-1" stepKey="fillQuantity10"/>
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="-1" stepKey="checkQuantity10"/>
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCartRadioButton"/>
Expand Down
22 changes: 9 additions & 13 deletions app/code/Magento/Bundle/ViewModel/ValidateQuantity.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\View\Element\Block\ArgumentInterface;
use Magento\Catalog\Block\Product\View as ProductView;

/**
* ViewModel for Bundle Option Block
Expand All @@ -21,27 +20,24 @@ class ValidateQuantity implements ArgumentInterface
*/
private $serializer;

/**
* @var ProductView
*/
private $productView;

/**
* @param Json $serializer
* @param ProductView $productView
*/
public function __construct(
Json $serializer,
ProductView $productView
Json $serializer
) {
$this->serializer = $serializer;
$this->productView = $productView;
}

/**
* Returns quantity validator.
*
* @return string
*/
public function getQuantityValidators(): string
{
return $this->serializer->serialize(
$this->productView->getQuantityValidators()
);
$validators['validate-item-quantity'] = [];

return $this->serializer->serialize($validators);
}
}
12 changes: 3 additions & 9 deletions app/code/Magento/Bundle/view/base/web/js/price-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,9 @@ define([
function isValidQty(bundleOption) {
var isValid = true,
qtyElem = bundleOption.data('qtyField'),
bundleOptionType = bundleOption.prop('type'),
qtyValidator = qtyElem.data('validate') &&
typeof qtyElem.data('validate')['validate-item-quantity'] === 'object' ?
qtyElem.data('validate')['validate-item-quantity'] : null;

if (['radio', 'select-one'].includes(bundleOptionType) &&
qtyValidator &&
(qtyElem.val() < qtyValidator.minAllowed || qtyElem.val() > qtyValidator.maxAllowed)
) {
bundleOptionType = bundleOption.prop('type');

if (['radio', 'select-one'].includes(bundleOptionType) && qtyElem.val() < 0) {
isValid = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="uncheckMiniQtyCheckBox"/>
<actionGroup ref="AdminSetMinAllowedQtyForProductActionGroup" stepKey="fillMiniAllowedQty">
<argument name="qty" value="1"/>
<argument name="qty" value="4"/>
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="uncheckMaxQtyCheckBox"/>
<actionGroup ref="AdminSetMaxAllowedQtyForProductActionGroup" stepKey="fillMaxAllowedQty">
Expand Down Expand Up @@ -107,16 +107,20 @@
<!--Add Product to the cart-->
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductQuantity"/>
<actionGroup ref="StorefrontAddProductToCartWithQtyActionGroup" stepKey="addToCartFromStorefrontProductPage">
<argument name="productQty" value="4"/>
</actionGroup>
<actionGroup ref="StorefrontAddProductToCartWithQtyActionGroup" stepKey="addAdditionalProductToCart">
<argument name="productQty" value="1"/>
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeSuccessSaveMessage"/>
<seeElement selector="{{StorefrontMinicartSection.quantity(1)}}" stepKey="seeAddedProductQuantityInCart"/>
<seeElement selector="{{StorefrontMinicartSection.quantity(6)}}" stepKey="seeAddedProductQuantityInCart"/>
<actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/>
<executeJS function="return {{SimpleProduct.price}} * 5" stepKey="expectedCartSubtotal"/>
<actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="seeProductNameInMiniCart">
<argument name="productName" value="{{SimpleProduct.name}}"/>
<argument name="productPrice" value="{{SimpleProduct.price}}"/>
<argument name="cartSubtotal" value="{{SimpleProduct.price}}" />
<argument name="qty" value="1"/>
<argument name="cartSubtotal" value="{$expectedCartSubtotal}" />
<argument name="qty" value="5"/>
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeProductPriceInMiniCart"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeCheckOutButtonInMiniCart"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public function __construct(
}

/**
* Adds quantities validator.
*
* @param \Magento\Catalog\Block\Product\View $block
* @param array $validators
* @return array
Expand All @@ -38,7 +40,6 @@ public function afterGetQuantityValidators(
);

$params = [];
$params['minAllowed'] = (float)$stockItem->getMinSaleQty();
if ($stockItem->getMaxSaleQty()) {
$params['maxAllowed'] = (float)$stockItem->getMaxSaleQty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public function testAfterGetQuantityValidators()
{
$result = [
'validate-item-quantity' => [
'minAllowed' => 0.5,
'maxAllowed' => 5.0,
'qtyIncrements' => 3.0
]
Expand All @@ -85,7 +84,6 @@ public function testAfterGetQuantityValidators()
->method('getStockItem')
->with('productId', 'websiteId')
->willReturn($this->stockItem);
$this->stockItem->expects($this->once())->method('getMinSaleQty')->willReturn(0.5);
$this->stockItem->expects($this->any())->method('getMaxSaleQty')->willReturn(5);
$this->stockItem->expects($this->any())->method('getQtyIncrements')->willReturn(3);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CatalogRule\Test\Fixture\Data;

use Magento\CatalogRule\Model\Rule\Action\Collection;
use Magento\Framework\Serialize\Serializer\Json;

class ActionsSerializer
{
/**
* @var Json
*/
private Json $json;

/**
* @param Json $json
*/
public function __construct(
Json $json
) {
$this->json = $json;
}

/**
* Normalizes and serializes actions data
*
* @param array $data
* @return string
*/
public function serialize(array $data): string
{
return $this->json->serialize($this->normalize($data));
}

/**
* Normalizes actions data
*
* @param array $data
* @return array
*/
private function normalize(array $data) : array
{
$actions = $data;
$actions += [
'type' => Collection::class,
'attribute' => null,
'value' => null,
'operator' => '=',
];
return $actions;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CatalogRule\Test\Fixture\Data;

use Magento\CatalogRule\Model\Rule\Condition\Combine;
use Magento\CatalogRule\Model\Rule\Condition\Product;
use Magento\Framework\Serialize\Serializer\Json;

class ConditionsSerializer
{
/**
* @var Json
*/
private Json $json;

/**
* @param Json $json
*/
public function __construct(
Json $json
) {
$this->json = $json;
}

/**
* Normalizes and serializes conditions data
*
* @param array $data
* @return string
*/
public function serialize(array $data): string
{
return $this->json->serialize($this->normalize($data));
}

/**
* Normalizes conditions data
*
* @param array $data
* @return array
*/
private function normalize(array $data) : array
{
$conditions = $data;
if (array_is_list($conditions)) {
$conditions = [
'conditions' => $conditions,
];
}
$conditions += [
'type' => Combine::class,
'attribute' => null,
'value' => true,
'operator' => null,
'aggregator' => 'all',
'is_value_processed' => null,
'conditions' => [

],
];
$subConditions = $conditions['conditions'];
$conditions['conditions'] = [];

foreach ($subConditions as $condition) {
if (isset($condition['conditions']) && array_is_list($condition)) {
$condition = $this->normalize($condition);
} else {
$condition += [
'type' => Product::class,
'attribute' => null,
'value' => null,
'operator' => '==',
'is_value_processed' => false,
];
}

$conditions['conditions'][] = $condition;
}
return $conditions;
}
}
Loading

0 comments on commit 25822df

Please sign in to comment.