Skip to content

Commit b578586

Browse files
[EngCom] Public Pull Requests - 2.3-develop
- merged latest code from mainline branch
2 parents a03883c + 85b9cf0 commit b578586

File tree

89 files changed

+1599
-492
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1599
-492
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Products.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ public function resolve(array $args, ResolverContextInterface $context)
5555
{
5656
$searchCriteria = $this->searchCriteriaBuilder->build($args);
5757

58-
if (isset($args['search'])) {
58+
if (!isset($args['search']) && !isset($args['filter'])) {
59+
throw new GraphQlInputException(
60+
__("One of 'search' or 'filter' input arguments needs to be specified in products request.")
61+
);
62+
} elseif (isset($args['search'])) {
5963
$searchResult = $this->searchQuery->getResult($searchCriteria);
6064
} else {
6165
$searchResult = $this->filterQuery->getResult($searchCriteria);
@@ -67,8 +71,10 @@ public function resolve(array $args, ResolverContextInterface $context)
6771
} else {
6872
$maxPages = 0;
6973
}
74+
75+
$currentPage = $searchCriteria->getCurrentPage();
7076
if ($searchCriteria->getCurrentPage() > $maxPages && $searchResult->getTotalCount() > 0) {
71-
throw new GraphQlInputException(
77+
$currentPage = new GraphQlInputException(
7278
__(
7379
'The value specified in the currentPage attribute is greater than the number'
7480
. ' of pages available (%1).',
@@ -82,7 +88,7 @@ public function resolve(array $args, ResolverContextInterface $context)
8288
'items' => $searchResult->getProductsSearchResult(),
8389
'page_info' => [
8490
'page_size' => $searchCriteria->getPageSize(),
85-
'current_page' => $searchCriteria->getCurrentPage()
91+
'current_page' => $currentPage
8692
]
8793
];
8894
}

app/code/Magento/Cms/Helper/Wysiwyg/Images.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/**
1111
* Wysiwyg Images Helper
12+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1213
*/
1314
class Images extends \Magento\Framework\App\Helper\AbstractHelper
1415
{

app/code/Magento/CustomerGraphQl/Model/Resolver/Customer.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\CustomerGraphQl\Model\Resolver;
88

9+
use Magento\Framework\Exception\NoSuchEntityException;
10+
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
911
use Magento\GraphQl\Model\ResolverInterface;
1012
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1113
use Magento\GraphQl\Model\ResolverContextInterface;
@@ -36,10 +38,17 @@ public function resolve(array $args, ResolverContextInterface $context)
3638
{
3739
if ((!$context->getUserId()) || $context->getUserType() == 4) {
3840
throw new GraphQlInputException(
39-
__('Current customer does not have access to the resource "%1"', 'customer')
41+
__(
42+
'Current customer does not have access to the resource "%1"',
43+
[\Magento\Customer\Model\Customer::ENTITY]
44+
)
4045
);
4146
}
4247

43-
return $this->customerResolver->getCustomerById($context->getUserId());
48+
try {
49+
return $this->customerResolver->getCustomerById($context->getUserId());
50+
} catch (NoSuchEntityException $exception) {
51+
return new GraphQlNoSuchEntityException(__('Customer id %1 does not exist.', [$context->getUserId()]));
52+
}
4453
}
4554
}

app/code/Magento/CustomerGraphQl/Model/Resolver/Customer/CustomerDataProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\CustomerGraphQl\Model\Resolver\Customer;
88

99
use Magento\Customer\Api\CustomerRepositoryInterface;
10+
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\Framework\Exception\NoSuchEntityException;
1112
use Magento\Framework\Serialize\SerializerInterface;
1213
use Magento\Framework\Webapi\ServiceOutputProcessor;
@@ -51,6 +52,7 @@ public function __construct(
5152
*
5253
* @param int $customerId
5354
* @return array|null
55+
* @throws NoSuchEntityException|LocalizedException
5456
*/
5557
public function getCustomerById(int $customerId)
5658
{

app/code/Magento/EavGraphQl/Model/Resolver/CustomAttributeMetadata.php

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
namespace Magento\EavGraphQl\Model\Resolver;
88

9+
use Magento\Framework\Exception\InputException;
10+
use Magento\Framework\GraphQl\Argument\ArgumentValueInterface;
911
use Magento\Framework\GraphQl\ArgumentInterface;
12+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
13+
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1014
use Magento\GraphQl\Model\ResolverInterface;
11-
use Magento\Framework\Exception\InputException;
1215
use \Magento\GraphQl\Model\ResolverContextInterface;
1316
use Magento\EavGraphQl\Model\Resolver\Query\Type;
1417

@@ -35,25 +38,64 @@ public function __construct(Type $type)
3538
*/
3639
public function resolve(array $args, ResolverContextInterface $context)
3740
{
38-
if (!isset($args['attributes']) || empty($args['attributes'])) {
39-
throw new InputException(__('Missing arguments for correct type resolution.'));
40-
}
41-
4241
$attributes['items'] = null;
4342
/** @var ArgumentInterface $attributeInputs */
4443
$attributeInputs = $args['attributes'];
4544
foreach ($attributeInputs->getValue() as $attribute) {
46-
$type = $this->type->getType($attribute['attribute_code'], $attribute['entity_type']);
47-
48-
if (!empty($type)) {
49-
$attributes['items'][] = [
50-
'attribute_code' => $attribute['attribute_code'],
51-
'entity_type' => $attribute['entity_type'],
52-
'attribute_type' => ucfirst($type)
53-
];
45+
if (!isset($attribute['attribute_code']) || !isset($attribute['entity_type'])) {
46+
$attributes['items'][] = $this->createInputException($attribute);
47+
continue;
5448
}
49+
try {
50+
$type = $this->type->getType($attribute['attribute_code'], $attribute['entity_type']);
51+
} catch (InputException $exception) {
52+
$attributes['items'][] = new GraphQlNoSuchEntityException(
53+
__(
54+
'Attribute code %1 of entity type %2 not configured to have a type.',
55+
[$attribute['attribute_code'], $attribute['entity_type']]
56+
)
57+
);
58+
continue;
59+
}
60+
61+
if (empty($type)) {
62+
continue;
63+
}
64+
65+
$attributes['items'][] = [
66+
'attribute_code' => $attribute['attribute_code'],
67+
'entity_type' => $attribute['entity_type'],
68+
'attribute_type' => ucfirst($type)
69+
];
5570
}
5671

5772
return $attributes;
5873
}
74+
75+
/**
76+
* Create GraphQL input exception for an invalid AttributeInput ArgumentValueInterface
77+
*
78+
* @param array $attribute
79+
* @return GraphQlInputException
80+
*/
81+
private function createInputException(array $attribute)
82+
{
83+
$isCodeSet = isset($attribute['attribute_code']);
84+
$isEntitySet = isset($attribute['entity_type']);
85+
$messagePart = !$isCodeSet ? 'attribute_code' : 'entity_type';
86+
$messagePart .= !$isCodeSet && !$isEntitySet ? '/entity_type' : '';
87+
$identifier = "Empty AttributeInput";
88+
if ($isCodeSet) {
89+
$identifier = 'attribute_code: ' . $attribute['attribute_code'];
90+
} elseif ($isEntitySet) {
91+
$identifier = 'entity_type: ' . $attribute['entity_type'];
92+
}
93+
94+
return new GraphQlInputException(
95+
__(
96+
'Attribute input does not contain %1 for the input %2.',
97+
[$messagePart, $identifier]
98+
)
99+
);
100+
}
59101
}

app/code/Magento/GraphQl/Controller/GraphQl.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public function __construct(
9393
*/
9494
public function dispatch(RequestInterface $request)
9595
{
96+
$statusCode = 200;
9697
try {
9798
/** @var Http $request */
9899
$this->requestProcessor->processHeaders($request);
@@ -106,12 +107,14 @@ public function dispatch(RequestInterface $request)
106107
isset($data['variables']) ? $data['variables'] : []
107108
);
108109
} catch (\Exception $error) {
109-
$result['extensions']['exception'] = $this->graphQlError->create($error);
110+
$result['errors'] = isset($result) && isset($result['errors']) ? $result['errors'] : [];
111+
$result['errors'][] = $this->graphQlError->create($error);
112+
$statusCode = ExceptionFormatter::HTTP_GRAPH_QL_SCHEMA_ERROR_STATUS;
110113
}
111114
$this->response->setBody($this->jsonSerializer->serialize($result))->setHeader(
112115
'Content-Type',
113116
'application/json'
114-
);
117+
)->setHttpResponseCode($statusCode);
115118
return $this->response;
116119
}
117120
}

app/code/Magento/GraphQl/etc/graphql.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<type xsi:type="OutputType" name="Query" />
88
<type xsi:type="InputType" name="FilterTypeInput">
99
<field xsi:type="ScalarInputField" name="eq" type="String"/>
10-
<field xsi:type="ObjectArrayInputField" name="finset" itemType="AttributeInput"/>
10+
<field xsi:type="ScalarArrayInputField" name="finset" itemType="String"/>
1111
<field xsi:type="ScalarInputField" name="from" type="String"/>
1212
<field xsi:type="ScalarInputField" name="gt" type="String"/>
1313
<field xsi:type="ScalarInputField" name="gteq" type="String"/>
@@ -30,4 +30,4 @@
3030
<item name="asc">ASC</item>
3131
<item name="desc">DESC</item>
3232
</type>
33-
</config>
33+
</config>

app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,16 @@ define([
106106
this.$wysiwygEditorButton.removeProp('disabled');
107107
}
108108

109-
if (wysiwyg && disabled) {
110-
wysiwyg.setEnabledStatus(false);
111-
wysiwyg.getPluginButtons().prop('disabled', 'disabled');
112-
} else if (wysiwyg) {
113-
wysiwyg.setEnabledStatus(true);
114-
wysiwyg.getPluginButtons().removeProp('disabled');
109+
/* eslint-disable no-undef */
110+
if (typeof wysiwyg !== 'undefined' && wysiwyg.activeEditor()) {
111+
112+
if (wysiwyg && disabled) {
113+
wysiwyg.setEnabledStatus(false);
114+
wysiwyg.getPluginButtons().prop('disabled', 'disabled');
115+
} else if (wysiwyg) {
116+
wysiwyg.setEnabledStatus(true);
117+
wysiwyg.getPluginButtons().removeProp('disabled');
118+
}
115119
}
116120
}
117121
});

dev/tests/acceptance/tests/_suite/sampleSuite.xml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,41 @@
66
*/
77
-->
88
<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Suite/etc/suiteSchema.xsd">
9+
<suite name="mySuite">
10+
<before>
11+
<createData entity="_defaultCategory" stepKey="createCategory"/>
12+
<createData entity="_defaultProduct" stepKey="createProduct">
13+
<required-entity createDataKey="createCategory"/>
14+
</createData>
15+
</before>
16+
<after>
17+
<deleteData stepKey="deleteMyProduct" createDataKey="createProduct"/>
18+
<deleteData stepKey="deleteMyCategory" createDataKey="createCategory"/>
19+
</after>
20+
<include>
21+
<group name="example"/>
22+
<cest test="PersistMultipleEntitiesTest" name="PersistMultipleEntitiesCest"/>
23+
<module name="SampleTests" file="SampleCest.xml"/>
24+
</include>
25+
<exclude>
26+
<group name="testGroup"/>
27+
</exclude>
28+
</suite>
929
<suite name="Catalog">
1030
<include>
1131
<module name="Catalog" />
1232
</include>
1333
<exclude>
14-
<cest name="AdminCreateCategoryCest"/>
15-
<cest name="AdminCreateSimpleProductCest"/>
34+
<test name="AdminCreateCategoryCest"/>
35+
<test name="AdminCreateSimpleProductCest"/>
1636
</exclude>
1737
</suite>
1838
<suite name="Cms">
1939
<include>
2040
<module name="Cms" />
2141
</include>
2242
<exclude>
23-
<cest name="AdminCreateCmsPageCest"/>
43+
<test name="AdminCreateCmsPageCest"/>
2444
</exclude>
2545
</suite>
2646
<suite name="Newsletter">
@@ -35,9 +55,9 @@
3555
<module name="Newsletter" />
3656
</include>
3757
<exclude>
38-
<cest name="AdminCreateCmsPageCest"/>
39-
<cest name="AdminCreateCategoryCest"/>
40-
<cest name="AdminCreateSimpleProductCest"/>
58+
<test name="AdminCreateCmsPageCest"/>
59+
<test name="AdminCreateCategoryCest"/>
60+
<test name="AdminCreateSimpleProductCest"/>
4161
</exclude>
4262
</suite>
4363
</suites>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Analytics/Test/AdminConfigurationTimeToSendDataCest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MAGETWO-66464"/>
1919
<group value="analytics"/>
20+
<group value="skip"/>
21+
<!--random failure on Jenkins MAGETWO-87216-->
2022
</annotations>
2123
<after>
2224
<amOnPage stepKey="amOnLogoutPage" url="admin/admin/auth/logout/"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
10+
<section name="StorefrontProductActionSection">
11+
<element name="addToCart" type="button" selector="#product-addtocart-button"/>
12+
</section>
13+
</sections>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/StorefrontProductInfoMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="StorefrontProductInfoMainSection">
12+
<element name="stock" type="input" selector=".stock.available"/>
1213
<element name="productName" type="text" selector=".base"/>
1314
<element name="productSku" type="text" selector=".product.attribute.sku>.value"/>
1415
<element name="productPrice" type="text" selector=".price"/>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/AdminAddImageToWYSIWYGCatalogCest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
<actionGroup ref="SwitchToVersion4ActionGroup" stepKey="switchToTinyMCE4" />
1515
</before>
1616
<annotations>
17-
<features value="Add Image to WYSIWYG on Catalog Page"/>
18-
<stories value="Default WYSIWYG toolbar configuration with Magento Media Gallery-MAGETWO-42041"/>
19-
<group value="addImageCatalog"/>
17+
<features value="MAGETWO-36659-[CMS] WYSIWYG update"/>
18+
<stories value="MAGETWO-42041-Default WYSIWYG toolbar configuration with Magento Media Gallery"/>
19+
<group value="Catalog"/>
2020
<title value="Admin should be able to add image to WYSIWYG Editor on Catalog Page"/>
2121
<description value="Admin should be able to add image to WYSIWYG Editor on Catalog Page"/>
2222
<severity value="CRITICAL"/>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/AdminAddImageToWYSIWYGProductCest.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
1010
<test name="AddImageToWYSIWYGProductEditor">
1111
<annotations>
12-
<features value="Add Image to WYSIWYG on Product Page"/>
13-
<stories value="Default WYSIWYG toolbar configuration with Magento Media Gallery-MAGETWO-42041"/>
14-
<group value="addImageProduct"/>
12+
<features value="MAGETWO-36659-[CMS] WYSIWYG update"/>
13+
<stories value="MAGETWO-42041-Default WYSIWYG toolbar configuration with Magento Media Gallery"/>
14+
<group value="Catalog"/>
1515
<title value="Admin should be able to add image to WYSIWYG Editor on Product Page"/>
1616
<description value="Admin should be able to add image to WYSIWYG Editor on Product Page"/>
1717
<severity value="CRITICAL"/>
@@ -28,6 +28,7 @@
2828
<fillField userInput="{{_defaultProduct.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillPrice"/>
2929
<fillField userInput="{{_defaultProduct.sku}}" selector="{{AdminProductFormSection.productSku}}" stepKey="fillSKU"/>
3030
<fillField userInput="{{_defaultProduct.quantity}}" selector="{{AdminProductFormSection.productQuantity}}" stepKey="fillQuantity"/>
31+
<scrollTo selector="{{AdminProductFormSection.productQuantity}}" stepKey="scrollToQty" />
3132
<click selector="{{AdminProductFormSection.contentTab}}" stepKey="clickContentTab" />
3233
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.TinyMCE4}}" stepKey="waitForDescription" />
3334
<click selector="{{ProductDescriptionWYSIWYGToolbarSection.InsertImageIcon}}" stepKey="clickInsertImageIcon1" />
@@ -68,7 +69,7 @@
6869
<fillField selector="{{ProductDescriptionWYSIWYGToolbarSection.Height}}" userInput="{{ImageUpload.height}}" stepKey="fillImageHeight1" />
6970
<click selector="{{ProductDescriptionWYSIWYGToolbarSection.OkBtn}}" stepKey="clickOkBtn1" />
7071
<waitForPageLoad stepKey="waitForPageLoad3"/>
71-
72+
<scrollTo selector="{{ProductDescriptionWYSIWYGToolbarSection.TinyMCE4}}" stepKey="scrollToTinyMCE4" />
7273
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertImageIcon}}" stepKey="clickInsertImageIcon2" />
7374
<waitForPageLoad stepKey="waitForPageLoad4" />
7475
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.Browse}}" stepKey="clickBrowse2" />
@@ -98,6 +99,7 @@
9899
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.OkBtn}}" stepKey="clickOkBtn2" />
99100
<waitForPageLoad stepKey="waitForPageLoad6"/>
100101
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct"/>
102+
<waitForLoadingMaskToDisappear stepKey="waitForLoading13" />
101103
<amOnPage url="{{_defaultProduct.name}}.html" stepKey="navigateToProductPage"/>
102104
<waitForPageLoad stepKey="waitForPageLoad2"/>
103105
<seeElement selector="{{StorefrontProductInfoMainSection.mediaDescription}}" stepKey="assertMediaDescription"/>

0 commit comments

Comments
 (0)