Skip to content

Commit b91279f

Browse files
committed
ACP2E-103: Pagebuilder content gets corrupted, when 4 bytes characters like emojis are used
1 parent c5a6b86 commit b91279f

File tree

4 files changed

+77
-16
lines changed

4 files changed

+77
-16
lines changed

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/ContentTypeHtmlActionGroup/AddTextToHtmlCodeWYSIWYGActionGroup.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1010
<actionGroup name="addTextToHtmlCodeWYSIWYGActionGroup">
1111
<arguments>
12+
<argument name="selector" type="string"/>
1213
<argument name="text" type="string"/>
1314
</arguments>
1415
<waitForPageLoad stepKey="waitForPageLoad"/>
15-
<waitForElement time="2" selector="{{EditPanelForm.panelFieldControl('general', 'html')}}" stepKey="waitForElementVisible"/>
16-
<click selector="{{EditPanelForm.panelFieldControl('general', 'html')}}" stepKey="clickField"/>
16+
<waitForElement time="2" selector="{{selector}}" stepKey="waitForElementVisible"/>
1717
<!-- Workaround to insert UTF8 MB4 characters -->
18-
<executeJS function="document.evaluate('{{EditPanelForm.panelFieldControl('general', 'html')}}', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.value += '{{text}}'; return 1;" stepKey="testVariable"/>
18+
<executeJS function="node=document.evaluate('{{selector}}', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; node.value += '{{text}}'; node.dispatchEvent(new Event('change')); return 1;" stepKey="testVariable"/>
1919
</actionGroup>
2020
</actionGroups>

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/ContentTypeHtmlActionGroup/RemoveTextFromHtmlCodeWYSIWYGActionGroup.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1010
<actionGroup name="removeTextFromHtmlCodeWYSIWYGActionGroup">
1111
<arguments>
12+
<argument name="selector" type="string"/>
1213
<argument name="text" type="string"/>
1314
</arguments>
1415
<waitForPageLoad stepKey="waitForPageLoad"/>
15-
<waitForElement time="2" selector="{{EditPanelForm.panelFieldControl('general', 'html')}}" stepKey="waitForElementVisible"/>
16+
<waitForElement time="2" selector="{{selector}}" stepKey="waitForElementVisible"/>
1617
<!-- Workaround to remove UTF8 MB4 characters -->
17-
<executeJS function="node=document.evaluate('{{EditPanelForm.panelFieldControl('general', 'html')}}', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;node.value = node.value.replace(new RegExp('{{text}}'), ''); node.dispatchEvent(new Event('change')); return 1;" stepKey="testVariable"/>
18+
<executeJS function="node=document.evaluate('{{selector}}', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;node.value = node.value.replace(new RegExp('{{text}}'), ''); node.dispatchEvent(new Event('change')); return 1;" stepKey="testVariable"/>
1819
</actionGroup>
1920
</actionGroups>

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderHtmlTest/HtmlCMSPageValidationTest.xml renamed to app/code/Magento/PageBuilder/Test/Mftf/Test/AdminCMSPagePageBuilderTest/PageBuilderCMSPageContentValidationTest.xml

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10-
<test name="HtmlCMSPageValidationTest">
10+
<test name="PageBuilderCMSPageContentValidationTest">
1111
<annotations>
1212
<features value="PageBuilder"/>
1313
<stories value="HTML Code"/>
@@ -48,6 +48,7 @@
4848
<argument name="property" value="PageBuilderHtmlPropertyButton"/>
4949
</actionGroup>
5050
<actionGroup ref="addTextToHtmlCodeWYSIWYGActionGroup" stepKey="enterWrongHtmlContent">
51+
<argument name="selector" value="{{EditPanelForm.panelFieldControl('general', 'html')}}"/>
5152
<argument name="text" value="\u{1F600}"/>
5253
</actionGroup>
5354
<click selector="{{EditPanelForm.editFormSave}}" stepKey="clickSaveButton"/>
@@ -58,10 +59,26 @@
5859
<actualResult type="variable">grabTextFromErrorLabel</actualResult>
5960
</assertStringContainsString>
6061
<actionGroup ref="removeTextFromHtmlCodeWYSIWYGActionGroup" stepKey="removeWrongHtmlContent">
62+
<argument name="selector" value="{{EditPanelForm.panelFieldControl('general', 'html')}}"/>
6163
<argument name="text" value="\u{1F600}"/>
6264
</actionGroup>
6365
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettings"/>
6466
<waitForElementNotVisible selector="{{HtmlOnStage.baseErrorLabel}}" stepKey="waitForHtmlBaseErrorLabelRemovedStage1"/>
67+
68+
<actionGroup ref="dragContentTypeToStage" stepKey="dragTextOntoStage">
69+
<argument name="contentType" value="PageBuilderTextContentType"/>
70+
</actionGroup>
71+
<actionGroup ref="openPageBuilderEditPanel" stepKey="openTextEditMenuOnStage">
72+
<argument name="contentType" value="PageBuilderTextContentType"/>
73+
</actionGroup>
74+
<fillField selector="{{TextOnConfiguration.textArea}}" userInput="Hello Page From PageBuilder" stepKey="addTextToEditor"/>
75+
<actionGroup ref="addTextToHtmlCodeWYSIWYGActionGroup" stepKey="enterWrongTextContent">
76+
<argument name="selector" value="//textarea[@id=&quot;{{TextOnConfiguration.textAreaId}}&quot;][1]"/>
77+
<argument name="text" value="\u{1F600}"/>
78+
</actionGroup>
79+
80+
<actionGroup ref="saveEditPanelSettingsFullScreen" stepKey="saveTextEditPanelSettings"/>
81+
6582
<!-- Validate Stage -->
6683
<comment userInput="Validate Stage" stepKey="commentValidateStage"/>
6784
<waitForElementVisible selector="{{HtmlOnStage.base('1')}}" stepKey="waitForHtmlBaseStage1"/>
@@ -72,24 +89,42 @@
7289
<actualResult type="variable">actualTextFromHtmlCode</actualResult>
7390
</assertStringContainsString>
7491
<actionGroup ref="exitPageBuilderFullScreen" stepKey="exitPageBuilderFullScreen"/>
92+
93+
<!-- Cannot save invalid text-->
7594
<actionGroup ref="SaveAndContinueEditCmsPageActionGroup" stepKey="saveAndContinueEditCmsPage"/>
76-
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage"/>
77-
<!-- Validate Stage After Save -->
78-
<comment userInput="Validate Stage After Save" stepKey="commentValidateStage2"/>
79-
<waitForElementVisible selector="{{HtmlOnStage.base('1')}}" stepKey="waitForHtmlBaseStage2"/>
80-
<waitForElementVisible selector="{{HtmlOnStage.html('1', PageBuilderHtmlPropertyButton.selector)}}" stepKey="waitForHtmlStage2"/>
81-
<executeJS function="return document.querySelectorAll('{{HtmlOnStage.baseCSS}}')[0].innerText;" stepKey="actualTextFromHtmlCodeAfterSave"/>
82-
<actionGroup ref="openPageBuilderEditPanel" stepKey="openEditMenuOnStage2">
83-
<argument name="contentType" value="PageBuilderHtmlContentType"/>
95+
<waitForElementVisible selector="//div[contains(@class, &quot;field-page-builder&quot;)]//label[@class=&quot;admin__field-error&quot;]" stepKey="waitForErrorLabelVisible"/>
96+
<grabTextFrom selector="//div[contains(@class, &quot;field-page-builder&quot;)]//label[@class=&quot;admin__field-error&quot;]" stepKey="grabTextFromErrorLabel2"/>
97+
<assertStringContainsString stepKey="assertErrorMessage2">
98+
<expectedResult type="string">Please remove invalid characters</expectedResult>
99+
<actualResult type="variable">grabTextFromErrorLabel2</actualResult>
100+
</assertStringContainsString>
101+
102+
<!-- Fix error and save again -->
103+
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStageToFixText"/>
104+
<actionGroup ref="openPageBuilderEditPanel" stepKey="openTextEditMenuOnStageToFixText">
105+
<argument name="contentType" value="PageBuilderTextContentType"/>
84106
</actionGroup>
85-
<!-- Validate Edit Panel After Save -->
86-
<comment userInput="Validate Edit Panel After Save" stepKey="commentValidateEditPanel2"/>
107+
<actionGroup ref="removeTextFromHtmlCodeWYSIWYGActionGroup" stepKey="removeWrongTextContent">
108+
<argument name="selector" value="//textarea[@id=&quot;{{TextOnConfiguration.textAreaId}}&quot;][1]"/>
109+
<argument name="text" value="\u{1F600}"/>
110+
</actionGroup>
111+
<actionGroup ref="saveEditPanelSettingsFullScreen" stepKey="saveTextEditPanelSettings2"/>
112+
<actionGroup ref="exitPageBuilderFullScreen" stepKey="exitPageBuilderFullScreen2"/>
113+
<waitForElementNotVisible selector="//div[contains(@class, &quot;field-page-builder&quot;)]//label[@class=&quot;admin__field-error&quot;]" stepKey="waitForErrorLabelNotVisible"/>
114+
<actionGroup ref="SaveAndContinueEditCmsPageActionGroup" stepKey="saveAndContinueEditCmsPage2"/>
115+
87116
<actionGroup ref="NavigateToStorefrontForCreatedPageActionGroup" stepKey="navigateToCMSPageStorefront">
88117
<argument name="page" value="$$createCMSPage.identifier$$"/>
89118
</actionGroup>
90119
<!-- Validate Storefront -->
91120
<comment userInput="Validate Storefront" stepKey="commentValidateStorefront"/>
92121
<waitForElementVisible selector="{{HtmlOnStorefront.base('1')}}" stepKey="waitForHtmlBaseStorefront"/>
93122
<waitForElementVisible selector="{{HtmlOnStorefront.html('1', PageBuilderHtmlPropertyButton.selectorOnFrontend)}}" stepKey="waitForHtmlStorefront"/>
123+
<waitForElementVisible selector="{{TextOnStorefront.allText}}" stepKey="waitForTextStorefront"/>
124+
<grabTextFrom selector="{{TextOnStorefront.allText}}" stepKey="grabTextFromText"/>
125+
<assertStringContainsString stepKey="assertTextOnStoreFront">
126+
<expectedResult type="string">Hello Page From PageBuilder</expectedResult>
127+
<actualResult type="variable">grabTextFromText</actualResult>
128+
</assertStringContainsString>
94129
</test>
95130
</tests>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
9+
<fieldset name="content">
10+
<field name="content_heading">
11+
<settings>
12+
<validation>
13+
<rule name="validate-no-utf8mb4-characters" xsi:type="boolean">true</rule>
14+
</validation>
15+
</settings>
16+
</field>
17+
<field name="content">
18+
<settings>
19+
<validation>
20+
<rule name="validate-no-utf8mb4-characters" xsi:type="boolean">true</rule>
21+
</validation>
22+
</settings>
23+
</field>
24+
</fieldset>
25+
</form>

0 commit comments

Comments
 (0)