Skip to content

Commit 2dace84

Browse files
committed
Merge remote-tracking branch 'origin/imported-magento-magento2-32251' into 2.4-develop-pr134
2 parents 35ed234 + 9449bd0 commit 2dace84

File tree

5 files changed

+141
-2
lines changed

5 files changed

+141
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontCustomWelcomeMessageActionGroup">
12+
<annotations>
13+
<description>Validates that the custom Welcome message is present on storefront header.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="customMessage" type="string" defaultValue="Welcome to &quot;Food &amp; Drinks&quot; store"/>
17+
</arguments>
18+
19+
<waitForElementVisible selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="waitForWelcomeMessage"/>
20+
<see userInput="{{customMessage}}" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="verifyCustomMessage"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/Theme/view/frontend/templates/html/header.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66

77
/**
88
* @var \Magento\Theme\Block\Html\Header $block
9+
* @var \Magento\Framework\Escaper $escaper
910
*/
1011
$welcomeMessage = $block->getWelcome();
1112
?>
1213
<?php if ($block->getShowPart() == 'welcome') : ?>
1314
<li class="greet welcome" data-bind="scope: 'customer'">
1415
<!-- ko if: customer().fullname -->
1516
<span class="logged-in"
16-
data-bind="text: new String('<?= $block->escapeHtml(__('Welcome, %1!', '%1')) ?>').replace('%1', customer().fullname)">
17+
data-bind="text: new String('<?= $escaper->escapeHtml(__('Welcome, %1!', '%1')) ?>').replace('%1', customer().fullname)">
1718
</span>
1819
<!-- /ko -->
1920
<!-- ko ifnot: customer().fullname -->
2021
<span class="not-logged-in"
21-
data-bind='html:"<?= $block->escapeHtml($welcomeMessage) ?>"'></span>
22+
data-bind="html: '<?= $escaper->escapeHtmlAttr($welcomeMessage) ?>'"></span>
2223
<?= $block->getBlockHtml('header.additional') ?>
2324
<!-- /ko -->
2425
</li>

app/code/Magento/Translation/Test/Mftf/Data/TranslationData.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,11 @@
171171
<data key="original">Shipping Method:</data>
172172
<data key="custom">Shipping Method:</data>
173173
</entity>
174+
<entity name="RevertWelcomeMessageTranslate" extends="CustomTranslationData">
175+
<requiredEntity type="translation_operation_translate">RevertWelcomeMessageTranslateData</requiredEntity>
176+
</entity>
177+
<entity name="RevertWelcomeMessageTranslateData" type="translation_operation_translate">
178+
<data key="original">Default welcome msg!</data>
179+
<data key="custom">Default welcome msg!</data>
180+
</entity>
174181
</entities>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="StorefrontPanelHeaderTranslationSection">
12+
<element name="welcomeMessage" type="text" selector="header>.panel .greet.welcome span" />
13+
</section>
14+
</sections>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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="StorefrontInlineTranslationWithQuoteSymbolsTest">
12+
<annotations>
13+
<features value="Translation"/>
14+
<stories value="Inline Translation"/>
15+
<title value="Inline translation with quote symbols"/>
16+
<description value="As merchant I want to be able to rename text labels using quote symbols in it"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-41175"/>
19+
<useCaseId value="MC-23989"/>
20+
<group value="translation"/>
21+
<group value="developer_mode_only"/>
22+
</annotations>
23+
24+
<before>
25+
<createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomer"/>
26+
<magentoCLI command="config:set {{EnableTranslateInlineForStorefront.path}} {{EnableTranslateInlineForStorefront.value}}" stepKey="enableTranslateInlineStorefront"/>
27+
<createData entity="RevertWelcomeMessageTranslate" stepKey="revertWelcomeMessageTranslation">
28+
<requiredEntity createDataKey="createCustomer"/>
29+
</createData>
30+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
31+
<createData entity="SimpleProduct2" stepKey="createProductSecond"/>
32+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCacheAfterTranslateEnabled">
33+
<argument name="tags" value=""/>
34+
</actionGroup>
35+
</before>
36+
37+
<after>
38+
<magentoCLI command="config:set {{EnableTranslateInlineForStorefront.path}} {{EnableTranslateInlineForStorefront.value}}" stepKey="enableTranslateInlineStorefront"/>
39+
<createData entity="RevertWelcomeMessageTranslate" stepKey="revertWelcomeMessageTranslation">
40+
<requiredEntity createDataKey="createCustomer"/>
41+
</createData>
42+
<magentoCLI command="config:set {{DisableTranslateInlineForStorefront.path}} {{DisableTranslateInlineForStorefront.value}}" stepKey="disableTranslateInlineForStorefront"/>
43+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
44+
<deleteData createDataKey="createProductSecond" stepKey="deleteProductSecond"/>
45+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
46+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCacheAfterTranslateDisabled">
47+
<argument name="tags" value=""/>
48+
</actionGroup>
49+
</after>
50+
51+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
52+
<argument name="productUrl" value="$createProduct.custom_attributes[url_key]$"/>
53+
</actionGroup>
54+
<actionGroup ref="AssertStorefrontDefaultWelcomeMessageActionGroup" stepKey="assertDefaultWelcomeMessage"/>
55+
<actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addProductToCart">
56+
<argument name="productName" value="$createProduct.name$"/>
57+
</actionGroup>
58+
<actionGroup ref="AssertOneProductNameInMiniCartActionGroup" stepKey="seeProductInMiniCart">
59+
<argument name="productName" value="$createProduct.name$"/>
60+
</actionGroup>
61+
62+
<actionGroup ref="AssertElementInTranslateInlineModeActionGroup" stepKey="assertWelcomeMessageInInlineTranslateMode">
63+
<argument name="elementSelector" value="{{StorefrontPanelHeaderTranslationSection.welcomeMessage}}"/>
64+
</actionGroup>
65+
<actionGroup ref="StorefrontOpenInlineTranslationPopupActionGroup" stepKey="openWelcomeMessageInlineTranslatePopup">
66+
<argument name="elementSelector" value="{{StorefrontPanelHeaderTranslationSection.welcomeMessage}}"/>
67+
</actionGroup>
68+
<actionGroup ref="StorefrontFillCustomTranslationFieldActionGroup" stepKey="fillInlineTranslateNewValue">
69+
<argument name="translateText" value="Welcome to &quot;Food &amp; Drinks&quot; store"/>
70+
</actionGroup>
71+
<actionGroup ref="StorefrontSubmitInlineTranslationFormActionGroup" stepKey="saveInlineTranslateNewValue"/>
72+
73+
<magentoCLI command="config:set {{DisableTranslateInlineForStorefront.path}} {{DisableTranslateInlineForStorefront.value}}" stepKey="disableTranslateInlineForStorefront"/>
74+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCacheAfterTranslateDisabled">
75+
<argument name="tags" value=""/>
76+
</actionGroup>
77+
78+
<actionGroup ref="ReloadPageActionGroup" stepKey="reloadPage"/>
79+
<actionGroup ref="AssertStorefrontCustomWelcomeMessageActionGroup" stepKey="verifyTranslatedWelcomeMessage"/>
80+
<actionGroup ref="AssertOneProductNameInMiniCartActionGroup" stepKey="seeProductInMiniCartAgain">
81+
<argument name="productName" value="$createProduct.name$"/>
82+
</actionGroup>
83+
84+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openSecondProductPage">
85+
<argument name="productUrl" value="$createProductSecond.custom_attributes[url_key]$"/>
86+
</actionGroup>
87+
<actionGroup ref="AssertStorefrontCustomWelcomeMessageActionGroup" stepKey="verifyTranslatedWelcomeMessageForSecondProduct"/>
88+
<actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addSecondProductToCart">
89+
<argument name="productName" value="$createProductSecond.name$"/>
90+
</actionGroup>
91+
<actionGroup ref="AssertOneProductNameInMiniCartActionGroup" stepKey="seeSecondProductInMiniCart">
92+
<argument name="productName" value="$createProductSecond.name$"/>
93+
</actionGroup>
94+
</test>
95+
</tests>

0 commit comments

Comments
 (0)