Skip to content

Commit e3a61b5

Browse files
committed
#419: Nested Links If User Adds Link Attribute & Link Widget to Banner/Slide, Banner MFTF test.
1 parent 7d99620 commit e3a61b5

File tree

2 files changed

+175
-0
lines changed

2 files changed

+175
-0
lines changed

app/code/Magento/PageBuilder/Test/Mftf/Data/BannerData.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
<data key="errorMessage">Adding link in both content and outer element is not allowed.</data>
3939
<data key="stageErrorMessage">We are unable to support links within the content field whilst having a link set on the content type. Please remove the content type link if you'd like to set a link within the content. We will automatically remove the links within the content field.</data>
4040
</entity>
41+
<entity name="PageBuilderBannerMessageInvalidWidgetProperty" type="pagebuilder_banner_message_property">
42+
<data key="name">Message Text</data>
43+
<data key="section">contents</data>
44+
<data key="fieldName">message</data>
45+
<data key="errorMessage">Adding widget in content and link in outer element is not allowed.</data>
46+
<data key="stageErrorMessage">We are unable to support widget within the content field whilst having a link set on the content type. Please remove the content type link if you'd like to set a widget within the content. We will automatically remove the widget within the content field.</data>
47+
</entity>
4148
<!-- Background Color -->
4249
<entity name="PageBuilderBannerBackgroundColor_Empty" type="pagebuilder_banner_background_color_property">
4350
<data key="name">Background Color</data>
@@ -82,6 +89,12 @@
8289
<data key="fieldName">link_url</data>
8390
<data key="errorMessage">Adding link in both content and outer element is not allowed.</data>
8491
</entity>
92+
<entity name="PageBuilderBannerLinkUrlInvalidWidgetProperty" type="pagebuilder_banner_linkUrl_property">
93+
<data key="name">Link</data>
94+
<data key="section">contents</data>
95+
<data key="fieldName">link_url</data>
96+
<data key="errorMessage">Adding link in outer element and widget in content is not allowed.</data>
97+
</entity>
8598
<!-- Show Button -->
8699
<entity name="PageBuilderBannerShowButtonDefaultProperty" type="pagebuilder_banner_show_button_property">
87100
<data key="name">Show Button</data>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="BannerCannotHaveInlineWysiwygWidgetAndLinkUrlTest">
11+
<annotations>
12+
<features value="PageBuilder"/>
13+
<stories value="Banner"/>
14+
<title value="Banner inline WYSIWYG editor will notify user that they cannot add TinyMCE Widget and Link URL at the same time"/>
15+
<description value="Banner edit form and inline editor validate banner TinyMCE Widget and Link URL could not be added at the same time."/>
16+
<severity value="MAJOR"/>
17+
<useCaseId value="MC-419"/>
18+
<testCaseId value="MC-542"/>
19+
<group value="pagebuilder"/>
20+
<group value="pagebuilder-banner"/>
21+
<group value="pagebuilder-bannerCommon"/>
22+
</annotations>
23+
<before>
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25+
<actionGroup ref="navigateToAPageWithPageBuilder" stepKey="navigateToAPageWithPageBuilder"/>
26+
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage"/>
27+
<createData entity="_defaultCmsPage" stepKey="createCMSPageA"/>
28+
</before>
29+
<after>
30+
<deleteData createDataKey="createCMSPageA" stepKey="deletePreReqCMSPageA"/>
31+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
32+
</after>
33+
<actionGroup ref="addPageBuilderPageTitle" stepKey="enterPageTitle">
34+
<argument name="contentType" value="PageBuilderBannerContentType"/>
35+
</actionGroup>
36+
<actionGroup ref="expandPageBuilderPanelMenuSection" stepKey="expandPageBuilderPanelMenuSection">
37+
<argument name="contentType" value="PageBuilderBannerContentType"/>
38+
</actionGroup>
39+
<actionGroup ref="dragContentTypeToStage" stepKey="dragBannerIntoStage">
40+
<argument name="contentType" value="PageBuilderBannerContentType"/>
41+
</actionGroup>
42+
<actionGroup ref="openPageBuilderEditPanel" stepKey="openEditMenuOnStage">
43+
<argument name="contentType" value="PageBuilderBannerContentType"/>
44+
</actionGroup>
45+
<!-- Fill Out Edit Panel Link Url property -->
46+
<actionGroup ref="fillSlideOutPanelLinkUrlField" stepKey="enterLink">
47+
<argument name="property" value="PageBuilderBannerLinkUrlProperty"/>
48+
<argument name="selection" value="{{ExternalLink.url}}"/>
49+
<argument name="newTab" value="PageBuilderBannerNewTabProperty"/>
50+
</actionGroup>
51+
<!-- Check Invalid Link Url and Message Text Widget -->
52+
<comment userInput="Check Invalid Link Url and Message Text Widget" stepKey="commentCheckInvalidLinkUrlAndMessageTextWidget"/>
53+
<!-- Add Widget to WYSIWYG -->
54+
<comment userInput="Add Widget to WYSIWYG" stepKey="commentAddPageLinkWidgetToTinyMCE"/>
55+
<actionGroup ref="addPageLinkWidgetToTinyMCE" stepKey="addPageLinkWidgetToTinyMCE">
56+
<argument name="widget" value="TinyMCEWidgetCMSPageLink"/>
57+
<argument name="page" value="$$createCMSPageA.identifier$$"/>
58+
</actionGroup>
59+
<actionGroup ref="saveEditPanelAndValidateFieldError" stepKey="validateInvalidLinkUrlAndWidget">
60+
<argument name="property" value="PageBuilderBannerLinkUrlInvalidWidgetProperty"/>
61+
</actionGroup>
62+
<actionGroup ref="saveEditPanelAndValidateFieldError" stepKey="validateInvalidMessageWithWidget">
63+
<argument name="property" value="PageBuilderBannerMessageInvalidWidgetProperty"/>
64+
</actionGroup>
65+
<!-- Check Invalid Link Url and Message Text Link -->
66+
<comment userInput="Check Invalid Link Url and Message Text Link" stepKey="commentCheckInvalidLinkUrlAndMessageTextLink"/>
67+
<!-- Add Link to WYSIWYG -->
68+
<comment userInput="Add Link to WYSIWYG" stepKey="commentAddLink"/>
69+
<actionGroup ref="insertLinkInWYSIWYG" stepKey="insertLinkInWYSIWYG">
70+
<argument name="url" value="{{ExternalLink.googleUrl}}"/>
71+
<argument name="textToDisplay" value="{{ExternalLink.googleUrl}}"/>
72+
</actionGroup>
73+
<actionGroup ref="saveEditPanelAndValidateFieldError" stepKey="validateInvalidLinkUrl">
74+
<argument name="property" value="PageBuilderBannerLinkUrlInvalidProperty"/>
75+
</actionGroup>
76+
<actionGroup ref="saveEditPanelAndValidateFieldError" stepKey="validateInvalidMessageWithUrl">
77+
<argument name="property" value="PageBuilderBannerMessageInvalidProperty"/>
78+
</actionGroup>
79+
<!-- Correcting invalid fields -->
80+
<comment userInput="Correcting invalid fields" stepKey="commentCorrectingInvalidFields"/>
81+
<actionGroup ref="replaceTextToTinyMCE" stepKey="replaceMessageText">
82+
<argument name="property" value="PageBuilderBannerMessageProperty"/>
83+
<argument name="section" value="BannerOnConfigurationPanel"/>
84+
</actionGroup>
85+
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettings"/>
86+
<!-- Check inline editor will validate for not allowing TinyMCE Widget and Link URL at the same time -->
87+
<comment userInput="Check inline editor will validate for not allowing TinyMCE Widget and Link URL at the same time" stepKey="commentCheckInlineEditorPreventAddingWidgetAndLinkUrl"/>
88+
<click selector="{{PageBuilderStage.inlineWYSIWYGEditor(PageBuilderBannerContentType.role, '1')}}" stepKey="focusOnEditorArea"/>
89+
<waitForElementVisible selector="{{PageBuilderStage.inlineWYSIWYGEditorPanel(PageBuilderBannerContentType.role, '1')}}" stepKey="waitForEditorPanel"/>
90+
<!-- Add Widget to WYSIWYG in Stage Inline Editor -->
91+
<comment userInput="Add Widget to WYSIWYG in Stage Inline Editor" stepKey="commentaddPageLinkWidgetToTinyMCEInline"/>
92+
<actionGroup ref="addPageLinkWidgetToTinyMCEInline" stepKey="addPageLinkWidgetToTinyMCEInline">
93+
<argument name="widget" value="TinyMCEWidgetCMSPageLink"/>
94+
<argument name="page" value="$$createCMSPageA.identifier$$"/>
95+
</actionGroup>
96+
<seeElement selector="{{PageBuilderStage.modal(PageBuilderBannerMessageInvalidWidgetProperty.stageErrorMessage)}}" stepKey="seeCorrectErrorModal"/>
97+
<actionGroup ref="confirmRemovalModal" stepKey="confirmNestingLinkModal"/>
98+
<!-- Checks for Widget Placeholder within the tinyMCE with regex -->
99+
<executeJS function="return (/&lt;span.*(class=)(&quot;|\').*((magento-placeholder).*(magento-widget)|(magento-widget).*(magento-placeholder)).*&lt;\/span&gt;/igm).test(tinymce.activeEditor.getContent());" stepKey="grabIfWidgetInWysiwygBoolean"/>
100+
<assertFalse stepKey="assertMessageHasNoWidgets">
101+
<actualResult type="variable">grabIfWidgetInWysiwygBoolean</actualResult>
102+
</assertFalse>
103+
<!-- Check inline editor will validate for not allowing TinyMCE Link and Link URL at the same time -->
104+
<comment userInput="Check inline editor will validate for not allowing TinyMCE Link and Link URL at the same time" stepKey="commentCheckInlineEditorPreventAddingBothUrls"/>
105+
<click selector="{{PageBuilderStage.inlineWYSIWYGEditor(PageBuilderBannerContentType.role, '1')}}" stepKey="focusOnEditorArea2"/>
106+
<waitForElementVisible selector="{{PageBuilderStage.inlineWYSIWYGEditorPanel(PageBuilderBannerContentType.role, '1')}}" stepKey="waitForEditorPanel2"/>
107+
<!-- Add Link to WYSIWYG in Stage Inline Editor -->
108+
<comment userInput="Add Link to WYSIWYG in Stage Inline Editor" stepKey="commentInsertLinkInStageInlineEditor"/>
109+
<actionGroup ref="insertLinkInWYSIWYG" stepKey="insertLinkInStageInlineEditor">
110+
<argument name="url" value="{{ExternalLink.googleUrl}}"/>
111+
<argument name="textToDisplay" value="{{ExternalLink.googleUrl}}"/>
112+
<argument name="wysiwygArea" value=""/>
113+
</actionGroup>
114+
<seeElement selector="{{PageBuilderStage.modal(PageBuilderBannerMessageInvalidProperty.stageErrorMessage)}}" stepKey="seeCorrectErrorModal2"/>
115+
<actionGroup ref="confirmRemovalModal" stepKey="confirmNestingLinkModal2"/>
116+
<!-- Checks for a tags within the tinyMCE with regex -->
117+
<executeJS function="return (/&lt;a[\s]+([^&gt;]+)&gt;|&lt;a&gt;|&lt;\/a&gt;/igm).test(tinymce.activeEditor.getContent());" stepKey="grabIfAnchorInWysiwygBoolean"/>
118+
<assertFalse stepKey="assertMessageHasNoAnchorTags">
119+
<actualResult type="variable">grabIfAnchorInWysiwygBoolean</actualResult>
120+
</assertFalse>
121+
<!-- Check slide out editor will validate for not allowing TinyMCE Widget and Link URL at the same time -->
122+
<comment userInput="Check slide out editor will validate for not allowing TinyMCE Widget and Link URL at the same time" stepKey="commentCheckSlideOutEditorPreventAddingWidgetAndLinkUrl"/>
123+
<click selector="{{PageBuilderPanel.searchPanel}}" stepKey="unFocusEditor"/>
124+
<actionGroup ref="openPageBuilderEditPanel" stepKey="openEditMenuOnStageAfterInlineValidation">
125+
<argument name="contentType" value="PageBuilderBannerContentType"/>
126+
</actionGroup>
127+
<!-- Checks for a tags within the tinyMCE with regex -->
128+
<executeJS function="return (/&lt;span.*(class=)(&quot;|\').*((magento-placeholder).*(magento-widget)|(magento-widget).*(magento-placeholder)).*&lt;\/span&gt;/igm).test(tinymce.activeEditor.getContent());" stepKey="grabIfWidgetInSlideOutWysiwygBoolean"/>
129+
<assertFalse stepKey="assertMessageHasNoWidgets2">
130+
<actualResult type="variable">grabIfWidgetInSlideOutWysiwygBoolean</actualResult>
131+
</assertFalse>
132+
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettings2"/>
133+
<!-- Check slide out editor will validate for not allowing TinyMCE Link and Link URL at the same time -->
134+
<comment userInput="Check slide out editor will validate for not allowing TinyMCE Link and Link URL at the same time" stepKey="commentCheckSlideOutEditorPreventAddingBothUrls"/>
135+
<click selector="{{PageBuilderPanel.searchPanel}}" stepKey="unFocusEditor2"/>
136+
<actionGroup ref="openPageBuilderEditPanel" stepKey="openEditMenuOnStageAfterInlineValidation2">
137+
<argument name="contentType" value="PageBuilderBannerContentType"/>
138+
</actionGroup>
139+
<!-- Checks for a tags within the tinyMCE with regex -->
140+
<executeJS function="return (/&lt;a[\s]+([^&gt;]+)&gt;|&lt;a&gt;|&lt;\/a&gt;/igm).test(tinymce.activeEditor.getContent());" stepKey="grabIfAnchorInSlideOutWysiwygBoolean"/>
141+
<assertFalse stepKey="assertMessageHasNoAnchorTags2">
142+
<actualResult type="variable">grabIfAnchorInSlideOutWysiwygBoolean</actualResult>
143+
</assertFalse>
144+
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettings3"/>
145+
<actionGroup ref="SaveAndContinueEditCmsPageActionGroup" stepKey="saveAndContinueEditCmsPage"/>
146+
<!-- Storefront: Validate No Widgets And No Link in Banner Content -->
147+
<comment userInput="Storefront: Validate No Link in Banner Content" stepKey="CommentValidateNoLinkInBannerContent"/>
148+
<actionGroup ref="navigateToStoreFront" stepKey="navigateToStoreFront">
149+
<argument name="contentType" value="PageBuilderBannerContentType"/>
150+
</actionGroup>
151+
<!-- Checks for Widget Block within the message with regex -->
152+
<executeJS function="return (/&lt;div.*(class=)(&quot;|\').*((widget).*(block)|(block).*(widget)).*&lt;\/div&gt;/igm).test({{BannerOnFrontend.contentJS('1')}}.innerHTML);" stepKey="grabIfFrontendWidgetBlockInContentBoolean"/>
153+
<assertFalse stepKey="assertFrontendMessageHasNoWidgetBlock">
154+
<actualResult type="variable">grabIfFrontendWidgetBlockInContentBoolean</actualResult>
155+
</assertFalse>
156+
<!-- Checks for a tags within the message with regex -->
157+
<executeJS function="return (/&lt;a[\s]+([^&gt;]+)&gt;|&lt;a&gt;|&lt;\/a&gt;/igm).test({{BannerOnFrontend.contentJS('1')}}.innerHTML);" stepKey="grabIfFrontendAnchorInContentBoolean"/>
158+
<assertFalse stepKey="assertFrontendMessageHasNoAnchorTags">
159+
<actualResult type="variable">grabIfFrontendAnchorInContentBoolean</actualResult>
160+
</assertFalse>
161+
</test>
162+
</tests>

0 commit comments

Comments
 (0)