Skip to content

Commit

Permalink
Merge pull request #8626 from magento-l3/Tier4-Kings-PR-11-08-2023
Browse files Browse the repository at this point in the history
Tier4 Kings PR Delivery 11.08.2023
  • Loading branch information
dhorytskyi authored Dec 1, 2023
2 parents 50c513f + 7f2b597 commit 7d724b7
Show file tree
Hide file tree
Showing 11 changed files with 335 additions and 65 deletions.
3 changes: 3 additions & 0 deletions app/code/Magento/Catalog/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
*
* @var \Magento\UrlRewrite\Model\UrlRewrite
* @deprecated 102.0.0
* @see \Magento\UrlRewrite\Model\UrlFinderInterface
*/
protected $_urlRewrite;

Expand Down Expand Up @@ -315,6 +316,7 @@ protected function getCustomAttributesCodes()
* @throws \Magento\Framework\Exception\LocalizedException
* @return \Magento\Catalog\Model\ResourceModel\Category
* @deprecated 102.0.6 because resource models should be used directly
* @see \Magento\Catalog\Model\ResourceModel\Category
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
* @since 102.0.6
*/
Expand Down Expand Up @@ -615,6 +617,7 @@ public function getUrl()
UrlRewrite::ENTITY_ID => $this->getId(),
UrlRewrite::ENTITY_TYPE => CategoryUrlRewriteGenerator::ENTITY_TYPE,
UrlRewrite::STORE_ID => $this->getStoreId(),
UrlRewrite::REDIRECT_TYPE => 0
]
);
if ($rewrite) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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="ProductViewPageCustomOptionValidationErrorMessageTest">
<annotations>
<features value="Catalog"/>
<stories value="Product view page"/>
<title value="[Magento Cloud] Bug of product custom option validation in product view page"/>
<description value="Check custom option validation error message is displayed in product view page"/>
<severity value="AVERAGE"/>
<testCaseId value="AC-9978"/>
<useCaseId value="ACP2E-2404"/>
<group value="Catalog"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin" />
<createData entity="SimpleProduct2" stepKey="createProduct"/>
<!-- open product edit page -->
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="goToProductEditPage">
<argument name="productId" value="$$createProduct.id$$"/>
</actionGroup>
<!-- Create a custom option(radio button) with 2 values -->
<click stepKey="openCustomizableOptions" selector="{{AdminProductCustomizableOptionsSection.customizableOptions}}"/>
<waitForPageLoad stepKey="waitForCustomOptionsOpen"/>
<actionGroup ref="CreateCustomRadioOptionsActionGroup" stepKey="createCustomOption1">
<argument name="customOptionName" value="ProductOptionRadiobutton.title"/>
<argument name="productOption" value="ProductOptionField"/>
<argument name="productOption2" value="ProductOptionField2"/>
</actionGroup>
<!-- Save the product -->
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="saveProduct"/>
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="assertSuccess"/>
<!-- indexer reindex -->
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
<argument name="indices" value=""/>
</actionGroup>
</before>
<after>
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>
<!-- Navigate to Product Page on StoreFront -->
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openStorefrontProductPage">
<argument name="productUrl" value="$$createProduct.custom_attributes[url_key]$$"/>
</actionGroup>
<!-- Add Product to Cart from product detail page -->
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addToCart"/>
<!-- see custom option validation message -->
<see userInput="This is a required field." stepKey="seeRequiredField"/>
</test>
</tests>
118 changes: 59 additions & 59 deletions app/code/Magento/Catalog/view/frontend/web/product/view/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,78 +12,78 @@ define([

$.widget('mage.validation', $.mage.validation, {
options: {
radioCheckboxClosest: 'ul, ol',
radioCheckboxClosest: 'ul, ol'
},

/**
* @param {*} error
* @param {HTMLElement} element
*/
errorPlacement: function (error, element) {
var messageBox,
dataValidate;
/**
* @param {*} error
* @param {HTMLElement} element
*/
errorPlacement: function (error, element) {
var messageBox,
dataValidate;

if ($(element).hasClass('datetime-picker')) {
element = $(element).parent();
if ($(element).hasClass('datetime-picker')) {
element = $(element).parent();

if (element.parent().find('.mage-error').length) {
return;
}
if (element.parent().find('.mage-error').length) {
return;
}
}

if (element.attr('data-errors-message-box')) {
messageBox = $(element.attr('data-errors-message-box'));
messageBox.html(error);
if (element.attr('data-errors-message-box')) {
messageBox = $(element.attr('data-errors-message-box'));
messageBox.html(error);

return;
}
return;
}

dataValidate = element.attr('data-validate');
dataValidate = element.attr('data-validate');

if (dataValidate && dataValidate.indexOf('validate-one-checkbox-required-by-name') > 0) {
error.appendTo('#links-advice-container');
} else if (element.is(':radio, :checkbox')) {
element.closest(this.radioCheckboxClosest).after(error);
} else {
element.after(error);
}
},
if (dataValidate && dataValidate.indexOf('validate-one-checkbox-required-by-name') > 0) {
error.appendTo('#links-advice-container');
} else if (element.is(':radio, :checkbox')) {
element.closest(this.radioCheckboxClosest).after(error);
} else {
element.after(error);
}
},

/**
* @param {HTMLElement} element
* @param {String} errorClass
*/
highlight: function (element, errorClass) {
var dataValidate = $(element).attr('data-validate');
/**
* @param {HTMLElement} element
* @param {String} errorClass
*/
highlight: function (element, errorClass) {
var dataValidate = $(element).attr('data-validate');

if (dataValidate && dataValidate.indexOf('validate-required-datetime') > 0) {
$(element).parent().find('.datetime-picker').each(function () {
$(this).removeClass(errorClass);
if (dataValidate && dataValidate.indexOf('validate-required-datetime') > 0) {
$(element).parent().find('.datetime-picker').each(function () {
$(this).removeClass(errorClass);

if ($(this).val().length === 0) {
$(this).addClass(errorClass);
}
});
} else if ($(element).is(':radio, :checkbox')) {
$(element).closest(this.radioCheckboxClosest).addClass(errorClass);
} else {
$(element).addClass(errorClass);
}
},
if ($(this).val().length === 0) {
$(this).addClass(errorClass);
}
});
} else if ($(element).is(':radio, :checkbox')) {
$(element).closest(this.radioCheckboxClosest).addClass(errorClass);
} else {
$(element).addClass(errorClass);
}
},

/**
* @param {HTMLElement} element
* @param {String} errorClass
*/
unhighlight: function (element, errorClass) {
var dataValidate = $(element).attr('data-validate');
/**
* @param {HTMLElement} element
* @param {String} errorClass
*/
unhighlight: function (element, errorClass) {
var dataValidate = $(element).attr('data-validate');

if (dataValidate && dataValidate.indexOf('validate-required-datetime') > 0) {
$(element).parent().find('.datetime-picker').removeClass(errorClass);
} else if ($(element).is(':radio, :checkbox')) {
$(element).closest(this.radioCheckboxClosest).removeClass(errorClass);
} else {
$(element).removeClass(errorClass);
}
if (dataValidate && dataValidate.indexOf('validate-required-datetime') > 0) {
$(element).parent().find('.datetime-picker').removeClass(errorClass);
} else if ($(element).is(':radio, :checkbox')) {
$(element).closest(this.radioCheckboxClosest).removeClass(errorClass);
} else {
$(element).removeClass(errorClass);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/Model/Validator/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class Name extends AbstractValidator
{
private const PATTERN_NAME = '/(?:[\p{L}\p{M}\,\-\_\.\'’`\s\d]){1,255}+/u';
private const PATTERN_NAME = '/(?:[\p{L}\p{M}\,\-\_\.\'’`&\s\d]){1,255}+/u';

/**
* Validate name fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public function expectedPunctuationInNamesDataProvider(): array
'middleName' => '',
'lastNameName' => 'O`Doe',
'message' => 'Grave accent back quote character must be allowed in names'
],
[
'firstName' => 'John & Smith',
'middleName' => '',
'lastNameName' => 'O`Doe',
'message' => 'Special character ampersand(&) must be allowed in names'
]
];
}
Expand Down
6 changes: 6 additions & 0 deletions app/code/Magento/QuoteGraphQl/Model/Resolver/PlaceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

namespace Magento\QuoteGraphQl\Model\Resolver;

use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
Expand Down Expand Up @@ -78,6 +80,10 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
$cart = $this->getCartForCheckout->execute($maskedCartId, $userId, $storeId);
$orderId = $this->placeOrder->execute($cart, $maskedCartId, $userId);
$order = $this->orderRepository->get($orderId);
} catch (AuthorizationException $exception) {
throw new GraphQlAuthorizationException(
__($exception->getMessage())
);
} catch (LocalizedException $e) {
throw $this->errorMessageFormatter->getFormatted(
$e,
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Tax/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,9 @@ public function needPriceConversion($store = null)
$res = false;
$priceIncludesTax = $this->priceIncludesTax($store)
|| $this->getNeedUseShippingExcludeTax()
|| $this->shippingPriceIncludesTax($store);
|| $this->shippingPriceIncludesTax($store)
|| $this->displayCartShippingInclTax()
|| $this->displayCartShippingBoth();
if ($priceIncludesTax) {
switch ($this->getPriceDisplayType($store)) {
case self::DISPLAY_TYPE_EXCLUDING_TAX:
Expand Down
46 changes: 46 additions & 0 deletions app/code/Magento/Tax/Test/Unit/Model/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,50 @@ public function dataProviderScopeConfigMethods(): array
]
];
}

/**
* Tests check if necessary do product price conversion
*
* @return void
*/
public function testNeedPriceConversion(): void
{
$scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
$scopeConfigMock
->method('getValue')
->willReturnMap(
[
[
Config::XML_PATH_DISPLAY_CART_SHIPPING,
ScopeInterface::SCOPE_STORE,
null,
true
],
[
Config::XML_PATH_DISPLAY_CART_SHIPPING,
ScopeInterface::SCOPE_STORE,
null,
false
],
[
Config::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE,
ScopeInterface::SCOPE_STORE,
null,
true
],
[
Config::XML_PATH_DISPLAY_CART_PRICE,
ScopeInterface::SCOPE_STORE,
null,
false
]
]
);
/** @var Config */
$model = new Config($scopeConfigMock);
$model->setPriceIncludesTax(false);
$model->setNeedUseShippingExcludeTax(false);
$model->setShippingPriceIncludeTax(false);
$this->assertEquals(true, $model->needPriceConversion());
}
}
Loading

0 comments on commit 7d724b7

Please sign in to comment.