Skip to content

Commit 0572853

Browse files
Merge pull request #4977 from magento-engcom/fix-nightly-fails-with-msi
[EngCom][Combined] Inventory Stabilization + GraphQl + SSL MySql + DBC
2 parents 1ebd7cc + c0f9fb7 commit 0572853

28 files changed

+704
-63
lines changed

app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<severity value="CRITICAL"/>
1717
<testCaseId value="MC-148"/>
1818
<group value="CatalogRule"/>
19+
<skip>
20+
<issueId value="MC-22577"/>
21+
</skip>
1922
</annotations>
2023
<before>
2124
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
@@ -148,7 +151,7 @@
148151
<argument name="attribute" value="{{productAttributeDropdownTwoOptions.attribute_code}}"/>
149152
</actionGroup>
150153
<actionGroup ref="SaveAttributeSet" stepKey="saveAttributeSet"/>
151-
154+
152155
<!-- First Simple Product: choose green as attribute value -->
153156
<actionGroup ref="filterAndSelectProduct" stepKey="openFirstSimpleProduct">
154157
<argument name="productSku" value="$$createFirstProduct.sku$$"/>

app/code/Magento/QuoteGraphQl/Model/Cart/Address/SaveQuoteAddressToCustomerAddressBook.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Customer\Api\Data\AddressInterfaceFactory;
1313
use Magento\Customer\Api\Data\RegionInterface;
1414
use Magento\Customer\Api\Data\RegionInterfaceFactory;
15+
use Magento\Framework\Exception\InputException;
1516
use Magento\Framework\Exception\LocalizedException;
1617
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1718
use Magento\Quote\Model\Quote\Address as QuoteAddress;
@@ -89,8 +90,15 @@ public function execute(QuoteAddress $quoteAddress, int $customerId): void
8990
$customerAddress->setRegion($region);
9091

9192
$this->addressRepository->save($customerAddress);
92-
} catch (LocalizedException $e) {
93-
throw new GraphQlInputException(__($e->getMessage()), $e);
93+
} catch (InputException $inputException) {
94+
$graphQlInputException = new GraphQlInputException(__($inputException->getMessage()));
95+
$errors = $inputException->getErrors();
96+
foreach ($errors as $error) {
97+
$graphQlInputException->addError(new GraphQlInputException(__($error->getMessage())));
98+
}
99+
throw $graphQlInputException;
100+
} catch (LocalizedException $exception) {
101+
throw new GraphQlInputException(__($exception->getMessage()), $exception);
94102
}
95103
}
96104
}

app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1616
use Magento\Quote\Model\Quote\Address as QuoteAddress;
1717
use Magento\Quote\Model\Quote\AddressFactory as BaseQuoteAddressFactory;
18+
use Magento\Directory\Model\ResourceModel\Region\CollectionFactory as RegionCollectionFactory;
19+
use Magento\Directory\Helper\Data as CountryHelper;
20+
use Magento\Directory\Model\AllowedCountries;
1821

1922
/**
2023
* Create QuoteAddress
@@ -36,36 +39,77 @@ class QuoteAddressFactory
3639
*/
3740
private $addressHelper;
3841

42+
/**
43+
* @var RegionCollectionFactory
44+
*/
45+
private $regionCollectionFactory;
46+
47+
/**
48+
* @var CountryHelper
49+
*/
50+
private $countryHelper;
51+
52+
/**
53+
* @var AllowedCountries
54+
*/
55+
private $allowedCountries;
56+
3957
/**
4058
* @param BaseQuoteAddressFactory $quoteAddressFactory
4159
* @param GetCustomerAddress $getCustomerAddress
4260
* @param AddressHelper $addressHelper
61+
* @param RegionCollectionFactory $regionCollectionFactory
62+
* @param CountryHelper $countryHelper
63+
* @param AllowedCountries $allowedCountries
4364
*/
4465
public function __construct(
4566
BaseQuoteAddressFactory $quoteAddressFactory,
4667
GetCustomerAddress $getCustomerAddress,
47-
AddressHelper $addressHelper
68+
AddressHelper $addressHelper,
69+
RegionCollectionFactory $regionCollectionFactory,
70+
CountryHelper $countryHelper,
71+
AllowedCountries $allowedCountries
4872
) {
4973
$this->quoteAddressFactory = $quoteAddressFactory;
5074
$this->getCustomerAddress = $getCustomerAddress;
5175
$this->addressHelper = $addressHelper;
76+
$this->regionCollectionFactory = $regionCollectionFactory;
77+
$this->countryHelper = $countryHelper;
78+
$this->allowedCountries = $allowedCountries;
5279
}
5380

5481
/**
5582
* Create QuoteAddress based on input data
5683
*
5784
* @param array $addressInput
85+
*
5886
* @return QuoteAddress
5987
* @throws GraphQlInputException
6088
*/
6189
public function createBasedOnInputData(array $addressInput): QuoteAddress
6290
{
6391
$addressInput['country_id'] = '';
64-
if ($addressInput['country_code']) {
92+
if (isset($addressInput['country_code']) && $addressInput['country_code']) {
6593
$addressInput['country_code'] = strtoupper($addressInput['country_code']);
6694
$addressInput['country_id'] = $addressInput['country_code'];
6795
}
6896

97+
$allowedCountries = $this->allowedCountries->getAllowedCountries();
98+
if (!in_array($addressInput['country_code'], $allowedCountries, true)) {
99+
throw new GraphQlInputException(__('Country is not available'));
100+
}
101+
$isRegionRequired = $this->countryHelper->isRegionRequired($addressInput['country_code']);
102+
if ($isRegionRequired && !empty($addressInput['region'])) {
103+
$regionCollection = $this->regionCollectionFactory
104+
->create()
105+
->addRegionCodeFilter($addressInput['region'])
106+
->addCountryFilter($addressInput['country_code']);
107+
if ($regionCollection->getSize() === 0) {
108+
throw new GraphQlInputException(
109+
__('Region is not available for the selected country')
110+
);
111+
}
112+
}
69113
$maxAllowedLineCount = $this->addressHelper->getStreetLines();
70114
if (is_array($addressInput['street']) && count($addressInput['street']) > $maxAllowedLineCount) {
71115
throw new GraphQlInputException(

app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ private function createBillingAddress(
132132
(int)$context->getUserId()
133133
);
134134
}
135+
$errors = $billingAddress->validate();
136+
137+
if (true !== $errors) {
138+
$e = new GraphQlInputException(__('Billing address errors'));
139+
foreach ($errors as $error) {
140+
$e->addError(new GraphQlInputException($error));
141+
}
142+
throw $e;
143+
}
135144

136145
return $billingAddress;
137146
}

app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1111
use Magento\GraphQl\Model\Query\ContextInterface;
1212
use Magento\Quote\Api\Data\CartInterface;
13+
use Magento\Quote\Model\Quote\Address;
1314

1415
/**
1516
* Set single shipping address for a specified shopping cart
@@ -52,6 +53,15 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
5253

5354
$shippingAddress = $this->getShippingAddress->execute($context, $shippingAddressInput);
5455

56+
$errors = $shippingAddress->validate();
57+
58+
if (true !== $errors) {
59+
$e = new GraphQlInputException(__('Shipping address errors'));
60+
foreach ($errors as $error) {
61+
$e->addError(new GraphQlInputException($error));
62+
}
63+
throw $e;
64+
}
5565
$this->assignShippingAddressToCart->execute($cart, $shippingAddress);
5666
}
5767
}

app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
<actionGroup ref="orderSelectFlatRateShipping" stepKey="orderSelectFlatRateShippingMethod"/>
4040
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>
4141
<actionGroup ref="verifyCreatedOrderInformation" stepKey="verifyCreatedOrderInformation"/>
42+
<grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId"/>
43+
<actionGroup ref="OpenOrderById" stepKey="openOrder">
44+
<argument name="orderId" value="$getOrderId"/>
45+
</actionGroup>
46+
<click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShipAction"/>
47+
<click selector="{{AdminShipmentMainActionsSection.submitShipment}}" stepKey="clickSubmitShipment"/>
4248
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="frontendCustomerLogIn">
4349
<argument name="Customer" value="$$simpleCustomer$$"/>
4450
</actionGroup>

app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
<actionGroup ref="orderSelectFlatRateShipping" stepKey="orderSelectFlatRateShippingMethod"/>
4040
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>
4141
<actionGroup ref="verifyCreatedOrderInformation" stepKey="verifyCreatedOrderInformation"/>
42+
<grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId"/>
43+
<actionGroup ref="OpenOrderById" stepKey="openOrder">
44+
<argument name="orderId" value="$getOrderId"/>
45+
</actionGroup>
46+
<click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShipAction"/>
47+
<click selector="{{AdminShipmentMainActionsSection.submitShipment}}" stepKey="clickSubmitShipment"/>
4248
<actionGroup ref="AssertAdminProductStockStatusActionGroup" stepKey="checkProductStockStatus">
4349
<argument name="productId" value="$$simpleProduct.id$$"/>
4450
<argument name="stockStatus" value="Out of Stock"/>

0 commit comments

Comments
 (0)