Skip to content

Commit ab39c95

Browse files
authored
Merge branch '2.4-develop' into mftf-gift-message
2 parents 7502723 + f121ac8 commit ab39c95

File tree

144 files changed

+5179
-3818
lines changed

Some content is hidden

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

144 files changed

+5179
-3818
lines changed

app/code/Magento/Backend/Test/Mftf/Helper/CurlHelpers.php

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ class CurlHelpers extends Helper
2525
* @return void
2626
*
2727
*/
28-
public function assertCurlResponseContainsString($url, $expectedString, $postBody = null, $cookieName = 'admin', $message = ''): void
29-
{
28+
public function assertCurlResponseContainsString(
29+
$url,
30+
$expectedString,
31+
$postBody = null,
32+
$cookieName = 'admin',
33+
$message = ''
34+
): void {
3035
$cookie = $this->getCookie($cookieName);
3136
$curlResponse = $this->getCurlResponse($url, $cookie, $postBody);
3237
$this->assertStringContainsString($expectedString, $curlResponse, $message);
@@ -43,8 +48,13 @@ public function assertCurlResponseContainsString($url, $expectedString, $postBod
4348
* @return void
4449
*
4550
*/
46-
public function assertImageContentIsEqual($url, $expectedString, $postBody = null, $cookieName = null, $message = ''): void
47-
{
51+
public function assertImageContentIsEqual(
52+
$url,
53+
$expectedString,
54+
$postBody = null,
55+
$cookieName = null,
56+
$message = ''
57+
): void {
4858
$cookie = $this->getCookie($cookieName);
4959
$imageContent = $this->getCurlResponse($url, $cookie, $postBody);
5060
// Must make request twice until bug is resolved: B2B-1789
@@ -65,23 +75,57 @@ public function assertImageContentIsEqual($url, $expectedString, $postBody = nul
6575
* @return void
6676
*
6777
*/
68-
public function assertCurlResponseDoesNotContainString($url, $expectedString, $postBody = null, $cookieName = 'admin'): void
69-
{
78+
public function assertCurlResponseDoesNotContainString(
79+
$url,
80+
$expectedString,
81+
$postBody = null,
82+
$cookieName = 'admin'
83+
): void {
7084
$cookie = $this->getCookie($cookieName);
7185
$curlResponse = $this->getCurlResponse($url, $cookie, $postBody);
7286
$this->assertStringNotContainsString($expectedString, $curlResponse);
7387
}
7488

89+
/**
90+
* Assert a that a curl request's response headers contains an expected string
91+
*
92+
* @param string $url
93+
* @param string $expectedString
94+
* @param string $postBody
95+
* @param string $cookieName
96+
* @return void
97+
*
98+
*/
99+
public function assertCurlResponseHeadersContainsString(
100+
$url,
101+
$expectedString,
102+
$postBody = null,
103+
$cookieName = 'admin'
104+
): void {
105+
$cookie = $this->getCookie($cookieName);
106+
$curlResponse = $this->getCurlResponse(
107+
$url,
108+
$cookie,
109+
$postBody,
110+
[
111+
CURLOPT_NOBODY => true,
112+
CURLOPT_HEADER => true,
113+
]
114+
);
115+
$this->assertStringContainsString($expectedString, $curlResponse);
116+
}
117+
75118
/**
76119
* Sends a curl request with the provided URL & cookie. Returns the response
77120
*
78121
* @param string $url
79122
* @param string $cookie
80123
* @param string $postBody
124+
* @param array $options
81125
* @return string
82126
*
83127
*/
84-
private function getCurlResponse($url, $cookie = null, $postBody = null): string
128+
private function getCurlResponse($url, $cookie = null, $postBody = null, array $options = []): string
85129
{
86130
// Start Session
87131
$session = curl_init($url);
@@ -94,6 +138,9 @@ private function getCurlResponse($url, $cookie = null, $postBody = null): string
94138
}
95139
curl_setopt($session, CURLOPT_COOKIE, $cookie);
96140
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
141+
foreach ($options as $option => $value) {
142+
curl_setopt($session, $option, $value);
143+
}
97144

98145
// Execute
99146
$response = curl_exec($session);

app/code/Magento/Backend/view/adminhtml/web/js/store-switcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ define([
7979
}
8080
});
8181

82-
$('#store-change-button').click();
82+
$('#store-change-button').trigger('click');
8383
}
8484
}
8585

app/code/Magento/Catalog/Block/Product/ImageFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function create(Product $product, string $imageId, array $attributes = nu
165165
'image_url' => $imageAsset->getUrl(),
166166
'width' => $imageMiscParams['image_width'],
167167
'height' => $imageMiscParams['image_height'],
168-
'label' => $this->getLabel($product, $imageMiscParams['image_type']),
168+
'label' => $this->getLabel($product, $imageMiscParams['image_type'] ?? ''),
169169
'ratio' => $this->getRatio($imageMiscParams['image_width'] ?? 0, $imageMiscParams['image_height'] ?? 0),
170170
'custom_attributes' => $this->filterCustomAttributes($attributes),
171171
'class' => $this->getClass($attributes),

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAndSwitchProductType/AdminCreateSimpleProductSwitchToVirtualTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<argument name="product" value="_defaultProduct"/>
2828
</actionGroup>
2929
<actionGroup ref="ResetProductGridToDefaultViewActionGroup" stepKey="resetSearch"/>
30-
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
30+
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
3131
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
3232
</after>
3333

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<click selector="{{AdminProductAttributeSetSection.modalOk}}" stepKey="confirmDelete"/>
3636
<waitForPageLoad stepKey="wait3"/>
3737

38-
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
38+
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
3939
</after>
4040

4141
<!-- Create a new attribute set -->

app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@
120120
<reloadPage stepKey="refreshPage"/>
121121
<waitForPageLoad stepKey="waitForReload"/>
122122
<waitForElementVisible selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="waitForFileName"/>
123-
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="grabNameFile"/>
123+
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="getFilename"/>
124+
<actionGroup ref="AdminGetExportFilenameOnServerActionGroup" stepKey="grabNameFile">
125+
<argument name="rowIndex" value="0"/>
126+
</actionGroup>
124127

125128
<!-- Validate Export File on File System: Dynamic Bundle Product -->
126129
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertExportFileExists">
@@ -205,7 +208,7 @@
205208

206209
<!-- Download Export File -->
207210
<actionGroup ref="DownloadFileActionGroup" stepKey="downloadCreatedProducts">
208-
<argument name="fileName" value="{$grabNameFile}"/>
211+
<argument name="fileName" value="{$getFilename}"/>
209212
</actionGroup>
210213

211214
<!-- Validate Downloaded Export File on File System: Dynamic Bundle Product -->
@@ -289,7 +292,7 @@
289292

290293
<!-- Delete Export File -->
291294
<actionGroup ref="DeleteExportedFileActionGroup" stepKey="deleteExportedFile">
292-
<argument name="fileName" value="{$grabNameFile}"/>
295+
<argument name="fileName" value="{$getFilename}"/>
293296
</actionGroup>
294297
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileDoesNotExist" stepKey="assertExportFileDeleted">
295298
<argument name="filePath">var/export/{$grabNameFile}</argument>
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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="AdminExportFilenameTimezoneTest">
12+
<annotations>
13+
<features value="CatalogImportExport"/>
14+
<stories value="Export Products"/>
15+
<title value="Date and time in export file name should be in user timezone"/>
16+
<description value="Date and time in export file name should be in user timezone"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="MC-42286"/>
19+
<useCaseId value="MC-41672"/>
20+
<group value="catalog_import_export"/>
21+
</annotations>
22+
<before>
23+
<!-- Create simple product -->
24+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
25+
<!-- Log in to admin -->
26+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
27+
</before>
28+
<after>
29+
<!-- Delete product -->
30+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
31+
<!-- Log out from admin -->
32+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
33+
</after>
34+
<!--Set timezone for default config-->
35+
<actionGroup ref="AdminOpenGeneralConfigurationPageActionGroup" stepKey="goToGeneralConfig"/>
36+
<conditionalClick selector="{{LocaleOptionsSection.sectionHeader}}"
37+
dependentSelector="{{LocaleOptionsSection.timezone}}"
38+
visible="false"
39+
stepKey="openLocaleSection"/>
40+
<grabValueFrom selector="{{LocaleOptionsSection.timezone}}" stepKey="originalTimezone"/>
41+
<selectOption selector="{{LocaleOptionsSection.timezone}}" userInput="America/Chicago" stepKey="setTimezone"/>
42+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfig"/>
43+
44+
<!-- Navigate to export page -->
45+
<actionGroup ref="AdminNavigateToExportPageActionGroup" stepKey="goToExportIndexPage"/>
46+
<!-- Export all products -->
47+
<actionGroup ref="ExportAllProductsActionGroup" stepKey="exportCreatedProducts"/>
48+
<!-- Start queue consumer for export -->
49+
<actionGroup ref="CliConsumerStartActionGroup" stepKey="startMessageQueue">
50+
<argument name="consumerName" value="{{AdminExportMessageConsumerData.consumerName}}"/>
51+
<argument name="maxMessages" value="{{AdminExportMessageConsumerData.messageLimit}}"/>
52+
</actionGroup>
53+
<!-- Refresh export page -->
54+
<actionGroup ref="ReloadPageActionGroup" stepKey="refreshPage"/>
55+
<!-- Get file display name -->
56+
<waitForElementVisible selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}"
57+
stepKey="waitForFilename"/>
58+
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="getFilename"/>
59+
<!-- Get file name on server -->
60+
<actionGroup ref="AdminGetExportFilenameOnServerActionGroup" stepKey="grabNameFile">
61+
<argument name="rowIndex" value="0"/>
62+
</actionGroup>
63+
<!-- Verify that the file exists on server -->
64+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions"
65+
method="assertFileExists"
66+
stepKey="assertExportFileExists">
67+
<argument name="filePath">var/export/{$grabNameFile}</argument>
68+
</helper>
69+
<executeJS function="var dt = '{$grabNameFile}'.replace(/[^\d]/g, ''),
70+
dy = dt.substring(0, 4),
71+
dm = dt.substring(4, 6),
72+
dd = dt.substring(6, 8),
73+
dh = dt.substring(8, 10),
74+
dmn = dt.substring(10, 12),
75+
ds = dt.substring(12);
76+
return (Date.parse(dy + '-' + dm + '-' + dd + 'T' + dh + ':' + dmn + ':' + ds + '.000Z')/1000);"
77+
stepKey="timestamp"/>
78+
<generateDate date="@{$timestamp}" format="Ymd_His" stepKey="expectedDate" timezone="America/Chicago"/>
79+
<executeJS function="return 'catalog_product_' + '{$expectedDate}' + '.csv'"
80+
stepKey="expectedFilename"/>
81+
<!-- Verify that the date and time in export filename is in user timezone-->
82+
<assertEquals stepKey="assertThatFilenameDisplayedToUserIsInAdminTimezone">
83+
<actualResult type="variable">getFilename</actualResult>
84+
<expectedResult type="variable">expectedFilename</expectedResult>
85+
</assertEquals>
86+
<!-- Verify that the date and time in download filename is in user timezone-->
87+
<grabAttributeFrom userInput="href"
88+
selector="{{AdminExportAttributeSection.download('0')}}"
89+
stepKey="grabExportUrl"/>
90+
<helper class="\Magento\Backend\Test\Mftf\Helper\CurlHelpers"
91+
method="assertCurlResponseHeadersContainsString"
92+
stepKey="assertDownloadFileContainsConfigurableProduct">
93+
<argument name="url">{$grabExportUrl}</argument>
94+
<argument name="expectedString">Content-Disposition: attachment; filename="export/{$expectedFilename}"</argument>
95+
</helper>
96+
<!-- Delete export File -->
97+
<actionGroup ref="DeleteExportedFileActionGroup" stepKey="deleteExportedFile">
98+
<argument name="fileName" value="{$getFilename}"/>
99+
</actionGroup>
100+
<!--Reset timezone-->
101+
<actionGroup ref="AdminOpenGeneralConfigurationPageActionGroup" stepKey="goToGeneralConfigReset"/>
102+
<conditionalClick selector="{{LocaleOptionsSection.sectionHeader}}"
103+
dependentSelector="{{LocaleOptionsSection.timezone}}"
104+
visible="false" stepKey="openLocaleSectionReset"/>
105+
<selectOption selector="{{LocaleOptionsSection.timezone}}"
106+
userInput="$originalTimezone"
107+
stepKey="resetTimezone"/>
108+
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfigReset"/>
109+
</test>
110+
</tests>

app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@
8383
<reloadPage stepKey="refreshPage"/>
8484
<waitForPageLoad stepKey="waitForReload"/>
8585
<waitForElementVisible selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="waitForFileName"/>
86-
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="grabNameFile"/>
86+
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="getFilename"/>
87+
<actionGroup ref="AdminGetExportFilenameOnServerActionGroup" stepKey="grabNameFile">
88+
<argument name="rowIndex" value="0"/>
89+
</actionGroup>
8790

8891
<!-- Validate Export File on File System: Grouped Product with Special Price -->
8992
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertExportFileExists">
@@ -112,7 +115,7 @@
112115

113116
<!-- Download Export File -->
114117
<actionGroup ref="DownloadFileActionGroup" stepKey="downloadCreatedProducts">
115-
<argument name="fileName" value="{$grabNameFile}"/>
118+
<argument name="fileName" value="{$getFilename}"/>
116119
</actionGroup>
117120

118121
<!-- Validate Downloaded Export File: Grouped Product with Special Price -->
@@ -140,7 +143,7 @@
140143

141144
<!-- Delete Export File -->
142145
<actionGroup ref="DeleteExportedFileActionGroup" stepKey="deleteExportedFile">
143-
<argument name="fileName" value="{$grabNameFile}"/>
146+
<argument name="fileName" value="{$getFilename}"/>
144147
</actionGroup>
145148
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileDoesNotExist" stepKey="assertExportFileDeleted">
146149
<argument name="filePath">var/export/{$grabNameFile}</argument>

app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportImportConfigurableProductWithImagesTest.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,14 @@
171171
</actionGroup>
172172
<reloadPage stepKey="refreshPage"/>
173173
<waitForElementVisible selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="waitForFileName"/>
174-
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="grabNameFile"/>
174+
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="getFilename"/>
175+
<actionGroup ref="AdminGetExportFilenameOnServerActionGroup" stepKey="grabNameFile">
176+
<argument name="rowIndex" value="0"/>
177+
</actionGroup>
175178

176179
<!-- Save exported file: file successfully downloaded -->
177180
<actionGroup ref="DownloadFileActionGroup" stepKey="downloadCreatedProducts">
178-
<argument name="fileName" value="{$grabNameFile}"/>
181+
<argument name="fileName" value="{$getFilename}"/>
179182
</actionGroup>
180183

181184
<!-- Go to Catalog > Products. Find ConfProd and delete it -->
@@ -222,7 +225,7 @@
222225

223226
<!-- Delete exported file -->
224227
<actionGroup ref="DeleteExportedFileActionGroup" stepKey="deleteExportedFile">
225-
<argument name="fileName" value="{$grabNameFile}"/>
228+
<argument name="fileName" value="{$getFilename}"/>
226229
</actionGroup>
227230
</test>
228231
</tests>

app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@
114114
<reloadPage stepKey="refreshPage"/>
115115
<waitForPageLoad stepKey="waitForReload"/>
116116
<waitForElementVisible selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="waitForFileName"/>
117-
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="grabNameFile"/>
117+
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="getFilename"/>
118+
<actionGroup ref="AdminGetExportFilenameOnServerActionGroup" stepKey="grabNameFile">
119+
<argument name="rowIndex" value="0"/>
120+
</actionGroup>
118121

119122
<!-- Validate Export File on File System: Product with Custom Options -->
120123
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertExportFileExists">
@@ -143,7 +146,7 @@
143146

144147
<!-- Download Export File -->
145148
<actionGroup ref="DownloadFileActionGroup" stepKey="downloadCreatedProducts">
146-
<argument name="fileName" value="{$grabNameFile}"/>
149+
<argument name="fileName" value="{$getFilename}"/>
147150
</actionGroup>
148151

149152
<!-- Validate Downloaded Export File: Product with Custom Options -->
@@ -171,7 +174,7 @@
171174

172175
<!-- Delete Export File -->
173176
<actionGroup ref="DeleteExportedFileActionGroup" stepKey="deleteExportedFile">
174-
<argument name="fileName" value="{$grabNameFile}"/>
177+
<argument name="fileName" value="{$getFilename}"/>
175178
</actionGroup>
176179
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileDoesNotExist" stepKey="assertExportFileDeleted">
177180
<argument name="filePath">var/export/{$grabNameFile}</argument>

app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@
130130
<reloadPage stepKey="refreshPage"/>
131131
<waitForPageLoad stepKey="waitForReload"/>
132132
<waitForElementVisible selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="waitForFileName"/>
133-
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="grabNameFile"/>
133+
<grabTextFrom selector="{{AdminExportAttributeSection.exportFileNameByPosition('0')}}" stepKey="getFilename"/>
134+
<actionGroup ref="AdminGetExportFilenameOnServerActionGroup" stepKey="grabNameFile">
135+
<argument name="rowIndex" value="0"/>
136+
</actionGroup>
134137

135138
<!-- Validate Export File on File System: Configurable Product -->
136139
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileExists" stepKey="assertExportFileExists">
@@ -163,7 +166,7 @@
163166

164167
<!-- Download Export File -->
165168
<actionGroup ref="DownloadFileActionGroup" stepKey="downloadCreatedProducts">
166-
<argument name="fileName" value="{$grabNameFile}"/>
169+
<argument name="fileName" value="{$getFilename}"/>
167170
</actionGroup>
168171

169172
<!-- Validate Downloaded Export File on File System: Configurable Product -->
@@ -195,7 +198,7 @@
195198

196199
<!-- Delete Export File -->
197200
<actionGroup ref="DeleteExportedFileActionGroup" stepKey="deleteExportedFile">
198-
<argument name="fileName" value="{$grabNameFile}"/>
201+
<argument name="fileName" value="{$getFilename}"/>
199202
</actionGroup>
200203
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="assertFileDoesNotExist" stepKey="assertExportFileDeleted">
201204
<argument name="filePath">var/export/{$grabNameFile}</argument>

0 commit comments

Comments
 (0)