Skip to content

Commit 18aab3c

Browse files
author
saphaljha
committed
Merge remote-tracking branch 'upstream/2.4-develop' into 2.4-develop
2 parents fac9b1f + 500a9e5 commit 18aab3c

File tree

219 files changed

+7020
-752
lines changed

Some content is hidden

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

219 files changed

+7020
-752
lines changed

app/code/Magento/AdminAnalytics/Test/Mftf/Test/AdminCheckAnalyticsTrackingTest.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,46 @@
3131

3232
<waitForPageLoad stepKey="waitForPageReloaded"/>
3333
<seeInPageSource html="var adminAnalyticsMetadata =" stepKey="seeInPageSource"/>
34+
<grabPageSource stepKey="pageSource"/>
35+
<assertRegExp message="adminAnalyticsMetadata object is invalid" stepKey="validateadminAnalyticsMetadata">
36+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?("[\w_]+":\s+"[^"]*?"\s+)};#s</expectedResult>
37+
<actualResult type="variable">$pageSource</actualResult>
38+
</assertRegExp>
39+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect user ID" stepKey="validateUserId">
40+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"user":\s+"[\w\d]{64}"#s</expectedResult>
41+
<actualResult type="variable">$pageSource</actualResult>
42+
</assertRegExp>
43+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect secure base URL" stepKey="validateSecureBaseURL">
44+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"secure_base_url":\s+"http(s)?\\\\u003A\\\\u002F\\\\u002F.+?\\\\u002F"#s</expectedResult>
45+
<actualResult type="variable">$pageSource</actualResult>
46+
</assertRegExp>
47+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect product version" stepKey="validateProductVersion">
48+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"version":\s+"[^\s]+"#s</expectedResult>
49+
<actualResult type="variable">$pageSource</actualResult>
50+
</assertRegExp>
51+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect product edition" stepKey="validateProductEdition">
52+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"product_edition":\s+"(Community|Enterprise|B2B)"#s</expectedResult>
53+
<actualResult type="variable">$pageSource</actualResult>
54+
</assertRegExp>
55+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect application mode" stepKey="validateApplicationMode">
56+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"mode":\s+"default|developer|production"#s</expectedResult>
57+
<actualResult type="variable">$pageSource</actualResult>
58+
</assertRegExp>
59+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect store name" stepKey="validateStoreName">
60+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"store_name_default":\s+".*?"#s</expectedResult>
61+
<actualResult type="variable">$pageSource</actualResult>
62+
</assertRegExp>
63+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect admin user created date" stepKey="validateAdminUserCreatedDate">
64+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"admin_user_created":\s+".+?"#s</expectedResult>
65+
<actualResult type="variable">$pageSource</actualResult>
66+
</assertRegExp>
67+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect admin user log date" stepKey="validateAdminUserLogDate">
68+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"admin_user_logdate":\s+".+?"#s</expectedResult>
69+
<actualResult type="variable">$pageSource</actualResult>
70+
</assertRegExp>
71+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect admin user role name" stepKey="validateAdminUserRoleName">
72+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"admin_user_role_name":\s+".+?"#s</expectedResult>
73+
<actualResult type="variable">$pageSource</actualResult>
74+
</assertRegExp>
3475
</test>
3576
</tests>

app/code/Magento/AdminAnalytics/ViewModel/Metadata.php

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\AdminAnalytics\ViewModel;
710

11+
use Magento\Config\Model\Config\Backend\Admin\Custom;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
813
use Magento\Framework\App\ProductMetadataInterface;
914
use Magento\Backend\Model\Auth\Session;
1015
use Magento\Framework\App\State;
1116
use Magento\Framework\View\Element\Block\ArgumentInterface;
17+
use Magento\Store\Model\Information;
1218

1319
/**
1420
* Gets user version and mode
@@ -30,19 +36,27 @@ class Metadata implements ArgumentInterface
3036
*/
3137
private $productMetadata;
3238

39+
/**
40+
* @var ScopeConfigInterface
41+
*/
42+
private $config;
43+
3344
/**
3445
* @param ProductMetadataInterface $productMetadata
3546
* @param Session $authSession
3647
* @param State $appState
48+
* @param ScopeConfigInterface $config
3749
*/
3850
public function __construct(
3951
ProductMetadataInterface $productMetadata,
4052
Session $authSession,
41-
State $appState
53+
State $appState,
54+
ScopeConfigInterface $config
4255
) {
4356
$this->productMetadata = $productMetadata;
4457
$this->authSession = $authSession;
4558
$this->appState = $appState;
59+
$this->config = $config;
4660
}
4761

4862
/**
@@ -55,15 +69,26 @@ public function getMagentoVersion() :string
5569
return $this->productMetadata->getVersion();
5670
}
5771

72+
/**
73+
* Get product edition
74+
*
75+
* @return string
76+
*/
77+
public function getProductEdition(): string
78+
{
79+
return $this->productMetadata->getEdition();
80+
}
81+
5882
/**
5983
* Get current user id (hash generated from email)
6084
*
6185
* @return string
6286
*/
6387
public function getCurrentUser() :string
6488
{
65-
return hash('sha512', 'ADMIN_USER' . $this->authSession->getUser()->getEmail());
89+
return hash('sha256', 'ADMIN_USER' . $this->authSession->getUser()->getEmail());
6690
}
91+
6792
/**
6893
* Get Magento mode that the user is using
6994
*
@@ -73,4 +98,62 @@ public function getMode() :string
7398
{
7499
return $this->appState->getMode();
75100
}
101+
102+
/**
103+
* Get created date for current user
104+
*
105+
* @return string
106+
*/
107+
public function getCurrentUserCreatedDate(): string
108+
{
109+
return $this->authSession->getUser()->getCreated();
110+
}
111+
112+
/**
113+
* Get log date for current user
114+
*
115+
* @return string|null
116+
*/
117+
public function getCurrentUserLogDate(): ?string
118+
{
119+
return $this->authSession->getUser()->getLogdate();
120+
}
121+
122+
/**
123+
* Get secure base URL
124+
*
125+
* @param string $scope
126+
* @param string|null $scopeCode
127+
* @return string|null
128+
*/
129+
public function getSecureBaseUrlForScope(
130+
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
131+
?string $scopeCode = null
132+
): ?string {
133+
return $this->config->getValue(Custom::XML_PATH_SECURE_BASE_URL, $scope, $scopeCode);
134+
}
135+
136+
/**
137+
* Get store name
138+
*
139+
* @param string $scope
140+
* @param string|null $scopeCode
141+
* @return string|null
142+
*/
143+
public function getStoreNameForScope(
144+
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
145+
?string $scopeCode = null
146+
): ?string {
147+
return $this->config->getValue(Information::XML_PATH_STORE_INFO_NAME, $scope, $scopeCode);
148+
}
149+
150+
/**
151+
* Get current user role name
152+
*
153+
* @return string
154+
*/
155+
public function getCurrentUserRoleName(): string
156+
{
157+
return $this->authSession->getUser()->getRole()->getRoleName();
158+
}
76159
}

app/code/Magento/AdminAnalytics/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"magento/framework": "*",
1010
"magento/module-backend": "*",
1111
"magento/module-config": "*",
12+
"magento/module-store": "*",
1213
"magento/module-ui": "*",
1314
"magento/module-release-notification": "*"
1415
},
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
10+
<policies>
11+
<policy id="script-src">
12+
<values>
13+
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
14+
</values>
15+
</policy>
16+
<policy id="style-src">
17+
<values>
18+
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
19+
<value id="fonts_googleapis" type="host">fonts.googleapis.com</value>
20+
</values>
21+
</policy>
22+
<policy id="img-src">
23+
<values>
24+
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
25+
<value id="storage_googleapis" type="host">storage.googleapis.com</value>
26+
</values>
27+
</policy>
28+
<policy id="connect-src">
29+
<values>
30+
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
31+
</values>
32+
</policy>
33+
<policy id="font-src">
34+
<values>
35+
<value id="fonts_gstatic" type="host">fonts.gstatic.com</value>
36+
</values>
37+
</policy>
38+
</policies>
39+
</csp_whitelist>

app/code/Magento/AdminAnalytics/view/adminhtml/layout/default.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<referenceContainer name="header">
1111
<block name="tracking" as="tracking" template="Magento_AdminAnalytics::tracking.phtml" ifconfig="admin/usage/enabled">
1212
<arguments>
13-
<argument name="tracking_url" xsi:type="string">//assets.adobedtm.com/launch-EN30eb7ffa064444f1b8b0368ef38fd3a9.min.js</argument>
13+
<argument name="tracking_url" xsi:type="string">//assets.adobedtm.com/a7d65461e54e/37baabec1b6e/launch-177bc126c8e6.min.js</argument>
1414
<argument name="metadata" xsi:type="object">Magento\AdminAnalytics\ViewModel\Metadata</argument>
1515
</arguments>
1616
</block>

app/code/Magento/AdminAnalytics/view/adminhtml/templates/tracking.phtml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,20 @@
1919
false
2020
) ?>
2121

22-
<?php $scriptString = '
22+
<?php
23+
/** @var \Magento\AdminAnalytics\ViewModel\Metadata $metadata */
24+
$metadata = $block->getMetadata();
25+
$scriptString = '
2326
var adminAnalyticsMetadata = {
24-
"version": "' . $block->escapeJs($block->getMetadata()->getMagentoVersion()) . '",
25-
"user": "' . $block->escapeJs($block->getMetadata()->getCurrentUser()) . '",
26-
"mode": "' . $block->escapeJs($block->getMetadata()->getMode()) . '"
27+
"secure_base_url": "' . $block->escapeJs($metadata->getSecureBaseUrlForScope()) . '",
28+
"version": "' . $block->escapeJs($metadata->getMagentoVersion()) . '",
29+
"product_edition": "' . $block->escapeJs($metadata->getProductEdition()) . '",
30+
"user": "' . $block->escapeJs($metadata->getCurrentUser()) . '",
31+
"mode": "' . $block->escapeJs($metadata->getMode()) . '",
32+
"store_name_default": "' . $block->escapeJs($metadata->getStoreNameForScope()) . '",
33+
"admin_user_created": "' . $block->escapeJs($metadata->getCurrentUserCreatedDate()) . '",
34+
"admin_user_logdate": "' . $block->escapeJs($metadata->getCurrentUserLogDate()) . '",
35+
"admin_user_role_name": "' . $block->escapeJs($metadata->getCurrentUserRoleName()) . '"
2736
};
2837
';
2938
?>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AwsS3StorefrontCaptchaOnCustomerLoginTest" extends="StorefrontCaptchaOnCustomerLoginTest">
12+
<annotations>
13+
<features value="Captcha"/>
14+
<stories value="Login with Customer Account + Captcha"/>
15+
<title value="AWS S3 Captcha customer login page test"/>
16+
<description value="Check CAPTCHA on Storefront Login Page."/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-39491" />
19+
<group value="remote_storage_aws_s3"/>
20+
</annotations>
21+
<before>
22+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage"/>
23+
</before>
24+
<after>
25+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage"/>
26+
</after>
27+
</test>
28+
</tests>

app/code/Magento/AwsS3/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "magento/module-aws-s-3",
2+
"name": "magento/module-aws-s3",
33
"description": "N/A",
44
"config": {
55
"sort-packages": true

app/code/Magento/Bundle/Test/Mftf/Test/AdminAddBundleItemsTest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@
5959
</actionGroup>
6060
<checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectFirstGridRow2"/>
6161
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddSelectedBundleProducts"/>
62+
<!-- Check that Bundle Options initialized with default quantity -->
63+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantity"/>
64+
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantity">
65+
<expectedResult type="string">1</expectedResult>
66+
<actualResult type="string">$grabbedFirstBundleOptionQuantity</actualResult>
67+
</assertEquals>
68+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantity"/>
69+
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantity">
70+
<expectedResult type="string">1</expectedResult>
71+
<actualResult type="string">$grabbedSecondBundleOptionQuantity</actualResult>
72+
</assertEquals>
73+
6274
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty1"/>
6375
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty2"/>
6476

@@ -108,6 +120,17 @@
108120
</actionGroup>
109121
<checkOption selector="{{AdminProductFormBundleSection.firstProductOption}}" stepKey="selectNewFirstGridRow2"/>
110122
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddNewSelectedBundleProducts"/>
123+
<!-- Check that existing Bundle Options do not loose user input quantity values -->
124+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantityAfterUserInput"/>
125+
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantityAfterUserInput">
126+
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
127+
<actualResult type="string">$grabbedFirstBundleOptionQuantityAfterUserInput</actualResult>
128+
</assertEquals>
129+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantityAfterUserInput"/>
130+
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantityAfterUserInput">
131+
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
132+
<actualResult type="string">$grabbedSecondBundleOptionQuantityAfterUserInput</actualResult>
133+
</assertEquals>
111134
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '2')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty1"/>
112135
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '3')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty2"/>
113136

app/code/Magento/Bundle/view/adminhtml/web/js/components/bundle-option-qty.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ define([
1717
}
1818
},
1919

20+
/**
21+
* @inheritdoc
22+
*/
23+
setInitialValue: function () {
24+
this.initialValue = this.getInitialValue();
25+
26+
if (this.initialValue === undefined || this.initialValue === '') {
27+
this.initialValue = 1;
28+
}
29+
30+
if (this.value.peek() !== this.initialValue) {
31+
this.value(this.initialValue);
32+
}
33+
34+
this.on('value', this.onUpdate.bind(this));
35+
this.isUseDefault(this.disabled());
36+
37+
return this;
38+
},
39+
2040
/**
2141
* @inheritdoc
2242
*/
@@ -33,6 +53,5 @@ define([
3353

3454
return !this.visible() ? false : notEqual;
3555
}
36-
3756
});
3857
});

0 commit comments

Comments
 (0)