Skip to content

Commit 59dfc49

Browse files
Merge pull request #7371 from magento-cia/2.4.4-develop-2.4-develop-sync-122321
Final sync of 2.4.4-develop with 2.4-develop
2 parents 61fe1d1 + 043092b commit 59dfc49

File tree

149 files changed

+2589
-439
lines changed

Some content is hidden

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

149 files changed

+2589
-439
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Analytics\Plugin;
10+
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Integration\Model\Integration;
13+
use Magento\Integration\Model\Validator\BearerTokenValidator;
14+
15+
/**
16+
* Overrides authorization config to always allow analytics token to be used as bearer
17+
*/
18+
class BearerTokenValidatorPlugin
19+
{
20+
/**
21+
* @var ScopeConfigInterface
22+
*/
23+
private ScopeConfigInterface $config;
24+
25+
/**
26+
* @param ScopeConfigInterface $config
27+
*/
28+
public function __construct(ScopeConfigInterface $config)
29+
{
30+
$this->config = $config;
31+
}
32+
33+
/***
34+
* Always allow access token for analytics to be used as bearer
35+
*
36+
* @param BearerTokenValidator $subject
37+
* @param bool $result
38+
* @param Integration $integration
39+
* @return bool
40+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
41+
*/
42+
public function afterIsIntegrationAllowedAsBearerToken(
43+
BearerTokenValidator $subject,
44+
bool $result,
45+
Integration $integration
46+
): bool {
47+
return $result || $integration->getName() === $this->config->getValue('analytics/integration_name');
48+
}
49+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Analytics\Test\Unit\Plugin;
10+
11+
use Magento\Analytics\Plugin\BearerTokenValidatorPlugin;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Integration\Model\Integration;
14+
use Magento\Integration\Model\Validator\BearerTokenValidator;
15+
use PHPUnit\Framework\MockObject\MockObject;
16+
use PHPUnit\Framework\TestCase;
17+
18+
class BearerTokenValidatorPluginTest extends TestCase
19+
{
20+
/**
21+
* @var BearerTokenValidatorPlugin
22+
*/
23+
private BearerTokenValidatorPlugin $plugin;
24+
25+
/**
26+
* @var BearerTokenValidator|MockObject
27+
*/
28+
private $validator;
29+
30+
public function setUp(): void
31+
{
32+
$config = $this->createMock(ScopeConfigInterface::class);
33+
$config->method('getValue')
34+
->with('analytics/integration_name')
35+
->willReturn('abc');
36+
$this->plugin = new BearerTokenValidatorPlugin($config);
37+
$this->validator = $this->createMock(BearerTokenValidator::class);
38+
}
39+
40+
public function testTrueIsPassedThrough()
41+
{
42+
$integration = $this->createMock(Integration::class);
43+
$integration->method('__call')
44+
->with('getName')
45+
->willReturn('invalid');
46+
47+
$result = $this->plugin->afterIsIntegrationAllowedAsBearerToken($this->validator, true, $integration);
48+
self::assertTrue($result);
49+
}
50+
51+
public function testFalseWhenIntegrationDoesntMatch()
52+
{
53+
$integration = $this->createMock(Integration::class);
54+
$integration->method('__call')
55+
->with('getName')
56+
->willReturn('invalid');
57+
58+
$result = $this->plugin->afterIsIntegrationAllowedAsBearerToken($this->validator, false, $integration);
59+
self::assertFalse($result);
60+
}
61+
62+
public function testTrueWhenIntegrationMatches()
63+
{
64+
$integration = $this->createMock(Integration::class);
65+
$integration->method('__call')
66+
->with('getName')
67+
->willReturn('abc');
68+
69+
$result = $this->plugin->afterIsIntegrationAllowedAsBearerToken($this->validator, true, $integration);
70+
self::assertTrue($result);
71+
}
72+
}

app/code/Magento/Analytics/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,7 @@
271271
<argument name="connectionFactory" xsi:type="object">Magento\Framework\Model\ResourceModel\Type\Db\ConnectionFactory</argument>
272272
</arguments>
273273
</type>
274+
<type name="Magento\Integration\Model\Validator\BearerTokenValidator">
275+
<plugin name="allow_bearer_token" type="Magento\Analytics\Plugin\BearerTokenValidatorPlugin"/>
276+
</type>
274277
</config>

app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminDashboardDisplayedWithNoErrorsActionGroup.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
<description>Checks if Dashboard is displayed properly</description>
1414
</annotations>
1515

16-
<seeElement selector="{{AdminDashboardSection.dashboardDiagramOrderContentTab}}" stepKey="seeOrderContentTab"/>
17-
<seeElement selector="{{AdminDashboardSection.dashboardDiagramContent}}" stepKey="seeDiagramContent"/>
16+
<waitForElementVisible selector="{{AdminDashboardSection.dashboardDiagramOrderContentTab}}" stepKey="seeOrderContentTab"/>
17+
<waitForElementVisible selector="{{AdminDashboardSection.dashboardDiagramContent}}" stepKey="seeDiagramContent"/>
1818
<click selector="{{AdminDashboardSection.dashboardDiagramAmounts}}" stepKey="clickDashboardAmount"/>
19-
<waitForLoadingMaskToDisappear stepKey="waitForDashboardAmountLoading"/>
20-
<seeElement selector="{{AdminDashboardSection.dashboardDiagramAmountsContentTab}}" stepKey="seeDiagramAmountContent"/>
21-
<seeElement selector="{{AdminDashboardSection.dashboardDiagramTotals}}" stepKey="seeAmountTotals"/>
19+
<waitForPageLoad stepKey="waitForDashboardAmountLoading"/>
20+
<waitForElementVisible selector="{{AdminDashboardSection.dashboardDiagramAmountsContentTab}}" stepKey="seeDiagramAmountContent"/>
21+
<waitForElementVisible selector="{{AdminDashboardSection.dashboardDiagramTotals}}" stepKey="seeAmountTotals"/>
2222
<dontSeeJsError stepKey="dontSeeJsError"/>
2323
</actionGroup>
2424
</actionGroups>

app/code/Magento/Backend/Test/Mftf/Test/AdminCheckDashboardWithChartsTest.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88

9-
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1111
<test name="AdminCheckDashboardWithChartsTest">
1212
<annotations>
@@ -22,6 +22,9 @@
2222
</annotations>
2323
<before>
2424
<magentoCLI command="config:set admin/dashboard/enable_charts 1" stepKey="setEnableCharts"/>
25+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCaches">
26+
<argument name="tags" value="config full_page"/>
27+
</actionGroup>
2528
<createData entity="SimpleProduct2" stepKey="createProduct">
2629
<field key="price">150</field>
2730
</createData>
@@ -43,11 +46,15 @@
4346
</before>
4447
<after>
4548
<magentoCLI command="config:set admin/dashboard/enable_charts 0" stepKey="setDisableChartsAsDefault"/>
49+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCaches">
50+
<argument name="tags" value="config full_page"/>
51+
</actionGroup>
4652
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
4753
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
4854
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
4955
</after>
5056

57+
<waitForElementVisible selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="waitForQuantityBefore"/>
5158
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabQuantityBefore"/>
5259

5360
<updateData createDataKey="createCustomerCart" entity="CustomerOrderPaymentMethod" stepKey="sendCustomerPaymentInformation">
@@ -60,8 +67,9 @@
6067
<requiredEntity createDataKey="createCustomerCart"/>
6168
</createData>
6269

63-
<reloadPage stepKey="refreshPage"/>
70+
<actionGroup ref="ReloadPageActionGroup" stepKey="refreshPage"/>
6471
<actionGroup ref="AssertAdminDashboardDisplayedWithNoErrorsActionGroup" stepKey="assertAdminDashboardNotBroken"/>
72+
<waitForElementVisible selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="waitForQuantityAfter"/>
6573
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabQuantityAfter"/>
6674
<assertGreaterThan stepKey="checkQuantityWasChanged">
6775
<actualResult type="const">$grabQuantityAfter</actualResult>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddProductImageActionGroup.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
<argument name="image" defaultValue="ProductImage"/>
1717
</arguments>
1818

19+
<waitForElementVisible selector="{{AdminProductImagesSection.productImagesToggle}}" stepKey="waitForImagesSection"/>
1920
<conditionalClick selector="{{AdminProductImagesSection.productImagesToggle}}" dependentSelector="{{AdminProductImagesSection.imageUploadButton}}" visible="false" stepKey="openProductImagesSection"/>
20-
<waitForPageLoad time="30" stepKey="waitForPageRefresh"/>
21+
<waitForPageLoad stepKey="waitForPageRefresh"/>
2122
<waitForElementVisible selector="{{AdminProductImagesSection.imageUploadButton}}" stepKey="seeImageSectionIsReady"/>
2223
<attachFile selector="{{AdminProductImagesSection.imageFileUpload}}" userInput="{{image.file}}" stepKey="uploadFile"/>
24+
<waitForPageLoad stepKey="waitForImageUpload"/>
2325
<waitForElementNotVisible selector="{{AdminProductImagesSection.uploadProgressBar}}" stepKey="waitForUpload"/>
2426
<waitForElementVisible selector="{{AdminProductImagesSection.imageFile(image.fileName)}}" stepKey="waitForThumbnail"/>
2527
</actionGroup>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssertProductImageOnProductPageActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<arguments>
1616
<argument name="image" defaultValue="{{MagentoLogo.filename}}" type="string"/>
1717
</arguments>
18+
<waitForElementVisible selector="{{AdminProductImagesSection.productImagesToggle}}" stepKey="waitForProductImagesSection"/>
1819
<conditionalClick selector="{{AdminProductImagesSection.productImagesToggle}}" dependentSelector="{{AdminProductImagesSection.imageUploadButton}}" visible="false" stepKey="openProductImagesSection"/>
1920
<waitForPageLoad stepKey="waitForPageLoad"/>
2021
<waitForElementVisible selector="{{AdminProductImagesSection.imageFile(image)}}" stepKey="seeImage"/>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAssertImageAltTextActionGroup.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@
1616
<argument name="image" defaultValue="ProductImage"/>
1717
<argument name="altText" defaultValue="{{ProductImage.title}}" type="string"/>
1818
</arguments>
19+
<waitForElementVisible selector="{{AdminProductImagesSection.productImagesToggle}}" stepKey="waitForImagesSection"/>
1920
<conditionalClick selector="{{AdminProductImagesSection.productImagesToggle}}" dependentSelector="{{AdminProductImagesSection.imageFile(image.fileName)}}" visible="false" stepKey="expandImages"/>
21+
<waitForPageLoad stepKey="waitForImages"/>
2022
<waitForElementVisible selector="{{AdminProductImagesSection.imageFile(image.fileName)}}" stepKey="seeProductImageName"/>
2123
<click selector="{{AdminProductImagesSection.imageFile(image.fileName)}}" stepKey="clickProductImage"/>
24+
<waitForPageLoad stepKey="waitForImageDetails"/>
2225
<waitForElementVisible selector="{{AdminProductImagesSection.altText}}" stepKey="seeAltTextSection"/>
2326
<grabValueFrom selector="{{AdminProductImagesSection.altText}}" stepKey="actualAltText"/>
2427
<assertEquals stepKey="assertAltText">
2528
<expectedResult type="string">{{altText}}</expectedResult>
2629
<actualResult type="variable">actualAltText</actualResult>
2730
</assertEquals>
2831
<click selector="{{AdminSlideOutDialogSection.closeButton}}" stepKey="clickCloseButton"/>
32+
<waitForPageLoad stepKey="waitForClose"/>
33+
<waitForElementNotVisible selector="{{AdminProductImagesSection.altText}}" stepKey="waitForDetailsGone"/>
2934
</actionGroup>
3035
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductChangeImageAltTextActionGroup.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@
1616
<argument name="image" defaultValue="ProductImage"/>
1717
<argument name="altText" defaultValue="{{ProductImage.title}}" type="string"/>
1818
</arguments>
19+
<waitForElementVisible selector="{{AdminProductImagesSection.productImagesToggle}}" stepKey="waitForImagesSection"/>
1920
<conditionalClick selector="{{AdminProductImagesSection.productImagesToggle}}" dependentSelector="{{AdminProductImagesSection.imageFile(image.fileName)}}" visible="false" stepKey="expandImages"/>
21+
<waitForPageLoad stepKey="waitForImages"/>
2022
<waitForElementVisible selector="{{AdminProductImagesSection.imageFile(image.fileName)}}" stepKey="seeProductImageName"/>
2123
<click selector="{{AdminProductImagesSection.imageFile(image.fileName)}}" stepKey="clickProductImage"/>
24+
<waitForPageLoad stepKey="waitForImageDetails"/>
2225
<waitForElementVisible selector="{{AdminProductImagesSection.altText}}" stepKey="seeAltTextSection"/>
2326
<fillField selector="{{AdminProductImagesSection.altText}}" userInput="{{altText}}" stepKey="fillAltTextSection"/>
2427
<click selector="{{AdminSlideOutDialogSection.closeButton}}" stepKey="clickCloseButton"/>
28+
<waitForPageLoad stepKey="waitForClose"/>
29+
<waitForElementNotVisible selector="{{AdminProductImagesSection.altText}}" stepKey="waitForDetailsGone"/>
2530
</actionGroup>
2631
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Test/AdminVerifyCreateCloseCreateCustomProductAttributeTest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
<actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteCreatedAttribute">
3333
<argument name="productAttributeLabel" value="{{ProductAttributeFrontendLabel.label}}"/>
3434
</actionGroup>
35+
<!-- Reindex after deleting product attribute -->
36+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
37+
<argument name="indices" value=""/>
38+
</actionGroup>
3539
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdminPanel"/>
3640
</after>
3741
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="navigateToProductPage">

app/code/Magento/Catalog/Test/Mftf/Test/AdminVerifyCreateCustomProductAttributeTest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
<actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteCreatedAttribute">
3333
<argument name="productAttributeLabel" value="{{ProductAttributeFrontendLabel.label}}"/>
3434
</actionGroup>
35+
<!-- Reindex after deleting product attribute -->
36+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
37+
<argument name="indices" value=""/>
38+
</actionGroup>
3539
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdminPanel"/>
3640
</after>
3741
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="navigateToProductPage">

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckNoAppearDefaultOptionConfigurableProductTest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteAttribute">
2626
<argument name="productAttributeLabel" value="{{colorProductAttribute.default_label}}" />
2727
</actionGroup>
28+
<!-- Reindex after deleting product attribute -->
29+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
30+
<argument name="indices" value=""/>
31+
</actionGroup>
2832
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
2933
</after>
3034

app/code/Magento/Catalog/etc/acl.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<resource id="Magento_Catalog::catalog" title="Catalog" translate="title" sortOrder="30">
1313
<resource id="Magento_Catalog::catalog_inventory" title="Inventory" translate="title" sortOrder="10">
1414
<resource id="Magento_Catalog::products" title="Products" translate="title" sortOrder="10">
15-
<resource id="Magento_Catalog::update_attributes" title="Update Attributes" translate="title" sortOrder="10" />
15+
<resource id="Magento_Catalog::update_attributes" title="Mass Update Attributes" translate="title" sortOrder="10" />
1616
<resource id="Magento_Catalog::edit_product_design" title="Edit Product Design" translate="title" sortOrder="20" />
1717
</resource>
1818
<resource id="Magento_Catalog::categories" title="Categories" translate="title" sortOrder="20">
@@ -27,7 +27,7 @@
2727
</resource>
2828
</resource>
2929
<resource id="Magento_Backend::stores_attributes">
30-
<resource id="Magento_Catalog::attributes_attributes" title="Product" translate="title" sortOrder="30" />
30+
<resource id="Magento_Catalog::attributes_attributes" title="Product" translate="title" sortOrder="30"/>
3131
<resource id="Magento_Catalog::sets" title="Attribute Set" translate="title" sortOrder="40"/>
3232
</resource>
3333
</resource>

app/code/Magento/Catalog/i18n/en_US.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Quantity,Quantity
148148
Edit,Edit
149149
"Are you sure?","Are you sure?"
150150
"Change Status","Change Status"
151-
"Update Attributes","Update Attributes"
151+
"Mass Update Attributes","Mass Update Attributes"
152152
"start typing to search category","start typing to search category"
153153
"New Category","New Category"
154154
"Images (.gif, .jpg, .png)","Images (.gif, .jpg, .png)"

app/code/Magento/CatalogInventory/Model/StockManagement.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
use Magento\CatalogInventory\Model\Spi\StockRegistryProviderInterface;
1515
use Magento\Catalog\Api\ProductRepositoryInterface;
1616
use Magento\CatalogInventory\Model\ResourceModel\Stock as ResourceStock;
17+
use Magento\Framework\Exception\LocalizedException;
1718

1819
/**
1920
* Implements a few interfaces for backward compatibility
21+
*
22+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2023
*/
2124
class StockManagement implements StockManagementInterface, RegisterProductSaleInterface, RevertProductSaleInterface
2225
{
@@ -91,7 +94,8 @@ public function __construct(
9194
* @param string[] $items
9295
* @param int $websiteId
9396
* @return StockItemInterface[]
94-
* @throws \Magento\Framework\Exception\LocalizedException
97+
* @throws StockStateException
98+
* @throws LocalizedException
9599
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
96100
*/
97101
public function registerProductsSale($items, $websiteId = null)
@@ -118,7 +122,7 @@ public function registerProductsSale($items, $websiteId = null)
118122
&& !$this->stockState->checkQty($productId, $orderedQty, $stockItem->getWebsiteId())
119123
) {
120124
$this->getResource()->commit();
121-
throw new \Magento\Framework\Exception\LocalizedException(
125+
throw new StockStateException(
122126
__('Some of the products are out of stock.')
123127
);
124128
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogInventory\Model;
7+
8+
use Magento\Framework\Exception\LocalizedException;
9+
10+
/**
11+
* Exception class reflecting when an operation cannot be completed due to the current stock status of an inventory item
12+
*
13+
* @api
14+
*/
15+
class StockStateException extends LocalizedException
16+
{
17+
}

app/code/Magento/CatalogInventory/Test/Unit/Model/StockManagementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function testRegisterProductsSale(
203203
*/
204204
public function testRegisterProductsSaleException(array $items, array $lockedItems)
205205
{
206-
$this->expectException('Magento\Framework\Exception\LocalizedException');
206+
$this->expectException('Magento\CatalogInventory\Model\StockStateException');
207207
$this->expectExceptionMessage('Some of the products are out of stock.');
208208
$this->stockResourceMock
209209
->expects($this->once())

0 commit comments

Comments
 (0)