Skip to content

Commit 0bb06ed

Browse files
authored
Merge branch 'magento-commerce:develop' into application-server
2 parents f445b23 + baa197c commit 0bb06ed

File tree

8 files changed

+278
-3
lines changed

8 files changed

+278
-3
lines changed

app/code/Magento/PageBuilder/Component/Form/Element/Wysiwyg.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magento\PageBuilder\Model\Config as PageBuilderConfig;
1919
use Magento\PageBuilder\Model\State as PageBuilderState;
2020
use Magento\PageBuilder\Model\Stage\Config as Config;
21+
use Magento\Framework\AuthorizationInterface;
2122

2223
/**
2324
* Updates wysiwyg element with Page Builder specific config
@@ -26,11 +27,19 @@
2627
*/
2728
class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
2829
{
30+
31+
private const ADMIN_RESOURCE = 'Magento_Backend::content';
32+
2933
/**
3034
* @var Repository
3135
*/
3236
private $assetRepo;
3337

38+
/**
39+
* @var AuthorizationInterface
40+
*/
41+
private $authorization;
42+
3443
/**
3544
* WYSIWYG Constructor
3645
*
@@ -46,6 +55,7 @@ class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
4655
* @param PageBuilderConfig|null $pageBuilderConfig
4756
* @param bool $overrideSnapshot
4857
* @param Repository|null $assetRepo
58+
* @param AuthorizationInterface|null $authorization
4959
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5060
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
5161
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -62,9 +72,11 @@ public function __construct(
6272
array $config = [],
6373
PageBuilderConfig $pageBuilderConfig = null,
6474
bool $overrideSnapshot = false,
65-
Repository $assetRepo = null
75+
Repository $assetRepo = null,
76+
AuthorizationInterface $authorization = null
6677
) {
6778
$this->assetRepo = $assetRepo ?: ObjectManager::getInstance()->get(Repository::class);
79+
$this->authorization = $authorization ?: ObjectManager::getInstance()->get(AuthorizationInterface::class);
6880
$wysiwygConfigData = $config['wysiwygConfigData'] ?? [];
6981

7082
// If a dataType is present we're dealing with an attribute
@@ -79,11 +91,11 @@ public function __construct(
7991
$config['wysiwyg'] = true;
8092
}
8193
}
82-
94+
$isAllowed = $this->authorization->isAllowed(self::ADMIN_RESOURCE);
8395
$isEnablePageBuilder = isset($wysiwygConfigData['is_pagebuilder_enabled'])
8496
&& !$wysiwygConfigData['is_pagebuilder_enabled']
8597
|| false;
86-
if (!$pageBuilderState->isPageBuilderInUse($isEnablePageBuilder)) {
98+
if (!$pageBuilderState->isPageBuilderInUse($isEnablePageBuilder) && $isAllowed) {
8799
// This is not done using definition.xml due to https://github.com/magento/magento2/issues/5647
88100
$data['config']['component'] = 'Magento_PageBuilder/js/form/element/wysiwyg';
89101

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="ValidateFullScreenVideoHasPlaysinlineAttributeActionGroup">
11+
<executeJS function="return document.querySelectorAll('{{VideoOnStorefront.mainCSS}} {{VideoOnStorefront.videoWithPlaysinline}}').length" stepKey="playsinlineAttributesCount"/>
12+
<assertEquals stepKey="assertPlaysinlineAttributePresent">
13+
<expectedResult type="string">1</expectedResult>
14+
<actualResult type="variable">playsinlineAttributesCount</actualResult>
15+
</assertEquals>
16+
</actionGroup>
17+
</actionGroups>

app/code/Magento/PageBuilder/Test/Mftf/Section/PageBuilderVideoSection/VideoOnStorefrontSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1010
<section name="VideoOnStorefront">
1111
<element name="allVideo" type="text" selector="[data-content-type='video']"/>
12+
<element name="videoWithPlaysinline" type="text" selector="video[playsinline=true]"/>
1213
<element name="mainCSS" type="text" selector="[data-content-type=video][data-element=main]"/>
1314
<element name="wrapperCSS" type="text" selector="[data-content-type=video] [data-element=wrapper]"/>
1415
<element name="main" type="text" selector="(//div[@data-content-type=&quot;video&quot;])[{{arg1}}]" parameterized="true"/>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd">
9+
<suite name="PageBuilderDisabledSuite">
10+
<before>
11+
<magentoCLI command="config:set cms/pagebuilder/enabled 0" stepKey="disblePageBuilder"/>
12+
<actionGroup ref="CliEnableTinyMCEActionGroup" stepKey="enableTinyMCE" />
13+
<magentoCLI command="config:set cms/wysiwyg/enabled disabled" stepKey="disableWYSIWYG"/>
14+
<magentoCLI command="cache:clean config" stepKey="flushCache"/>
15+
</before>
16+
<after>
17+
<magentoCLI command="config:set cms/pagebuilder/enabled 1" stepKey="enablePageBuilder"/>
18+
<magentoCLI command="config:set cms/wysiwyg/enabled enabled" stepKey="enableWYSIWYG"/>
19+
<actionGroup ref="CliEnableTinyMCEActionGroup" stepKey="enableTinyMCE" />
20+
<magentoCLI command="cache:clean config" stepKey="flushCache"/>
21+
</after>
22+
<include>
23+
<group name="pagebuilder_disabled"/>
24+
</include>
25+
<exclude>
26+
<group name="pagebuilder"/>
27+
<group name="pagebuilder-requiresValidMapAPIKey"/>
28+
<group name="remote_storage_aws_s3_pagebuilder"/>
29+
</exclude>
30+
</suite>
31+
</suites>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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="CheckDisplayingOfApostrophesInTheTextFieldBoxWhileCreatingPageWidgetTest">
12+
<annotations>
13+
<features value="Widget"/>
14+
<stories value="Checking displaying of apostrophes (') in the text field box while creating page widget"/>
15+
<title value="Checking displaying of apostrophes (') in the text field box while creating page widget"/>
16+
<description value="Checking displaying of apostrophes (') in the text field box while creating page widget"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="AC-4389"/>
19+
<group value="widget"/>
20+
<group value="pagebuilder_disabled"/>
21+
</annotations>
22+
<before>
23+
<!-- Pre-condition 1- Login as Admin -->
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25+
<!-- Pre-condition 3- Verify page in grid-->
26+
<actionGroup ref="AdminOpenCMSPagesGridActionGroup" stepKey="openCMSPagesGridActionGroup"/>
27+
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearGridFilters"/>
28+
<actionGroup ref="SortByIdDescendingActionGroup" stepKey="sortGridByIdDescending"/>
29+
<click selector="{{CmsPagesPageActionsSection.select('home')}}" stepKey="clickSelectCMSPage" />
30+
<!-- Pre-condition 4- Update the page in grid-->
31+
<click selector="{{CmsPagesPageActionsSection.edit('home')}}" stepKey="OpenThePageToBeEdited"/>
32+
<waitForPageLoad stepKey="waitForPageLoadPostSelectingHomePage"/>
33+
<waitForElementVisible selector="{{CmsNewPagePageContentSection.header}}" stepKey="waitForContentTabForPageToBeVisible"/>
34+
<!-- Pre-condition 5- Expand the Content section > Insert Widget -->
35+
<click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickExpandContentTabForPage"/>
36+
<conditionalClick selector="{{CmsNewPagePageActionsSection.showHideEditor}}" dependentSelector="{{CmsNewPagePageActionsSection.showHideEditor}}" visible="true" stepKey="clickOnShowHideEditorLinkIfVisibleForInsertingWidget"/>
37+
<waitForElementVisible selector="{{CmsNewPagePageActionsSection.insertWidget}}" stepKey="waitForTheInsertWidgetButtonToDisplay"/>
38+
<actionGroup ref="AdminInsertWidgetToCmsPageContentActionGroup" stepKey="selectCMSPageLinkFromDropdown"/>
39+
<waitForPageLoad stepKey="waitForPageLoadPostSelectingFromDropDown"/>
40+
<!-- Pre-condition 6 - 11 - Update the Anchor Custom Text -->
41+
<fillField selector="{{WidgetSection.InputAnchorCustomText}}" userInput="Custom texts&apos; for tests" stepKey="InputValuesWithApostrophe"/>
42+
<click selector="{{WidgetSection.SelectPageButton}}" stepKey="clickOnSelectPageButton"/>
43+
<waitForElementVisible selector="{{WidgetSection.URLKeySelectPage}}" stepKey="waitForSelectPageDialogToPopulate"/>
44+
<fillField selector="{{WidgetSection.URLKeySelectPage}}" userInput="home" stepKey="EnterThePageURL"/>
45+
<click selector="{{WidgetSection.SearchButtonSelectPage}}" stepKey="clickOnSearchButton"/>
46+
<waitForPageLoad stepKey="waitForResultsToBeDisplayed"/>
47+
<click selector="{{WidgetSection.SearchResultSelectPage('home')}}" stepKey="clickOnDisplayedResult"/>
48+
<click selector="{{WidgetSection.InsertWidget}}" stepKey="clickOnInsertWidget"/>
49+
<waitForElementVisible selector="{{CmsNewPagePageActionsSection.saveAndContinueEdit}}" stepKey="waitForInsertWidgetDialogToDisappear" time="5"/>
50+
<click selector="{{CmsNewPagePageActionsSection.saveAndContinueEdit}}" stepKey="clickSavePage"/>
51+
<waitForElementVisible selector="{{CmsPagesPageActionsSection.savePageSuccessMessage}}" stepKey="waitForSuccessMessageLoggedOut" time="5"/>
52+
<see userInput="You saved the page." stepKey="seeSuccessMessage"/>
53+
</before>
54+
<after>
55+
<actionGroup ref="AdminOpenCMSPagesGridActionGroup" stepKey="openCMSPagesGridActionGroupToReset"/>
56+
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearGridFiltersToReset"/>
57+
<actionGroup ref="SortByIdDescendingActionGroup" stepKey="sortGridByIdDescendingToReset"/>
58+
<click selector="{{CmsPagesPageActionsSection.select('home')}}" stepKey="clickSelectCMSPageToReset" />
59+
<!-- Pre-condition 4- Update the page in grid To Reset-->
60+
<click selector="{{CmsPagesPageActionsSection.edit('home')}}" stepKey="OpenThePageToBeEditedToReset"/>
61+
<waitForPageLoad stepKey="waitForPageLoadPostSelectingHomePageToReset"/>
62+
<waitForElementVisible selector="{{CmsNewPagePageContentSection.header}}" stepKey="waitForContentTabForPageToBeVisibleToReset"/>
63+
<!-- Pre-condition 5- Expand the Content section > Insert Widget To Reset -->
64+
<click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickExpandContentTabForPageToReset"/>
65+
<conditionalClick selector="{{CmsNewPagePageActionsSection.showHideEditor}}" dependentSelector="{{CmsNewPagePageActionsSection.showHideEditor}}" visible="true" stepKey="clickOnShowHideEditorLinkIfVisibleForInsertingWidgetToOriginal"/>
66+
<waitForElementVisible selector="{{CmsNewPagePageActionsSection.insertWidget}}" stepKey="waitForTheInsertWidgetButtonToDisplayToReset"/>
67+
<clearField selector="{{CmsNewPagePageContentSection.content}}" stepKey="clearWidgetTextFieldToReset"/>
68+
<fillField selector="{{CmsNewPagePageContentSection.content}}" userInput="&lt;p&gt;CMS homepage content goes here.&lt;/p&gt;" stepKey="InputDefaultValuesInWidgetTextFieldToReset"/>
69+
<waitForElementVisible selector="{{CmsNewPagePageActionsSection.saveAndContinueEdit}}" stepKey="waitForInsertWidgetDialogToDisappearToReset" time="5"/>
70+
<click selector="{{CmsNewPagePageActionsSection.saveAndContinueEdit}}" stepKey="clickSavePageToReset"/>
71+
<waitForElementVisible selector="{{CmsPagesPageActionsSection.savePageSuccessMessage}}" stepKey="waitForSuccessMessageLoggedOutToReset" time="5"/>
72+
<see userInput="You saved the page." stepKey="seeSuccessMessageToReset"/>
73+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
74+
</after>
75+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="navigateToHomePage"/>
76+
<waitForPageLoad stepKey="waitToLoadHomePage"/>
77+
<grabTextFrom selector="{{StorefrontCMSPageSection.widgetContentApostrophe('Custom texts')}}" stepKey="grabContentFromWidget"/>
78+
<assertEquals message="Asserts the widget contains apostrophe On storefront" stepKey="assertApostropheOnWidgetText">
79+
<expectedResult type="string">Custom texts' for tests</expectedResult>
80+
<actualResult type="string">{$grabContentFromWidget}</actualResult>
81+
</assertEquals>
82+
</test>
83+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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="VideoValidateAutoplayPlaysinlineMp4Enabled">
11+
<annotations>
12+
<features value="PageBuilder"/>
13+
<stories value="Video"/>
14+
<title value="Validate Video Playsinline Autoplay Attribute"/>
15+
<description value="Validate that setting the autoplay attribute in the General form for Video will also add the playsinline attribute to the video tag in order for autoplay to work on mobile Safari browser"/>
16+
<severity value="AVERAGE"/>
17+
<useCaseId value="ACP2E-1654"/>
18+
<testCaseId value="AC-8149"/>
19+
<group value="pagebuilder"/>
20+
<group value="pagebuilder-video"/>
21+
</annotations>
22+
<before>
23+
<createData entity="_emptyCmsPage" stepKey="createCMSPage"/>
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25+
</before>
26+
<after>
27+
<deleteData createDataKey="createCMSPage" stepKey="deleteCMSPage"/>
28+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
29+
</after>
30+
31+
<!-- Add an autoplay video to the CMS page -->
32+
<actionGroup ref="NavigateToCreatedCMSPageActionGroup" stepKey="navigateToCreatedCMSPage">
33+
<argument name="CMSPage" value="$$createCMSPage$$"/>
34+
</actionGroup>
35+
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage"/>
36+
<actionGroup ref="dragContentTypeToStage" stepKey="dragRowToRootContainer">
37+
<argument name="contentType" value="PageBuilderRowContentType"/>
38+
<argument name="containerTargetType" value="PageBuilderRootContainerContentType"/>
39+
</actionGroup>
40+
<actionGroup ref="addPageBuilderPageTitle" stepKey="enterPageTitle">
41+
<argument name="contentType" value="PageBuilderVideoContentType"/>
42+
</actionGroup>
43+
<actionGroup ref="expandPageBuilderPanelMenuSection" stepKey="expandPageBuilderPanelMenuSection">
44+
<argument name="contentType" value="PageBuilderVideoContentType"/>
45+
</actionGroup>
46+
<actionGroup ref="dragContentTypeToStage" stepKey="dragVideoIntoStage">
47+
<argument name="contentType" value="PageBuilderVideoContentType"/>
48+
</actionGroup>
49+
<actionGroup ref="openPageBuilderEditPanel" stepKey="openEditAfterDrop">
50+
<argument name="contentType" value="PageBuilderVideoContentType"/>
51+
</actionGroup>
52+
<actionGroup ref="fillSlideOutPanelFieldGeneral" stepKey="enterVideoUrlProperty">
53+
<argument name="property" value="PageBuilderVideoUrl_Mp4_URL"/>
54+
</actionGroup>
55+
<actionGroup ref="conditionalClickSlideOutPanelFieldGeneral" stepKey="setAutoplayEnabled">
56+
<argument name="property" value="PageBuilderVideoAutoplay_Enabled"/>
57+
</actionGroup>
58+
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettings"/>
59+
<actionGroup ref="exitPageBuilderFullScreen" stepKey="exitPageBuilderFullScreen"/>
60+
<actionGroup ref="SaveAndContinueEditCmsPageActionGroup" stepKey="saveAndContinueEditCmsPage"/>
61+
62+
<!-- Validate that the added autoplay video will have playsinline tag at the storefront -->
63+
<actionGroup ref="NavigateToStorefrontForCreatedPageActionGroup" stepKey="navigateToCMSPageStorefront">
64+
<argument name="page" value="$$createCMSPage.identifier$$"/>
65+
</actionGroup>
66+
<actionGroup ref="ValidateFullScreenVideoHasPlaysinlineAttributeActionGroup" stepKey="validateVideoPlaysinlineAttribute"/>
67+
</test>
68+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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="SpecificACLAdminUserCheckProductContentEditWithPageBuilderTest">
11+
<annotations>
12+
<features value="PageBuilder"/>
13+
<stories value="Catalog Products"/>
14+
<title value="Specific ACL Admin user verify product content modify with Page Builder"/>
15+
<description value="This test is designed to make sure that a limited admin user can effectively save the basic product content using PageBuilder.."/>
16+
<severity value="MAJOR"/>
17+
<useCaseId value="ACP2E-1646"/>
18+
<testCaseId value="AC-8107"/>
19+
</annotations>
20+
<before>
21+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
22+
<createData entity="_defaultCategory" stepKey="createCategory"/>
23+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
24+
<requiredEntity createDataKey="createCategory"/>
25+
</createData>
26+
</before>
27+
<after>
28+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAsLimitedAdmin"/>
29+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/>
30+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
31+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
32+
<actionGroup ref="AdminDeleteCreatedUserActionGroup" stepKey="deleteAdminUser">
33+
<argument name="user" value="Admin3"/>
34+
</actionGroup>
35+
<actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteRole">
36+
<argument name="roleName" value="{{limitedAccessRole.name}}"/>
37+
</actionGroup>
38+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAsAdmin1"/>
39+
</after>
40+
<!-- Create a restricted role with access only to Catalog -->
41+
<actionGroup ref="AdminCreateRoleWithoutScopeSelectionActionGroup" stepKey="createRestrictedRole">
42+
<argument name="restrictedRole" value="Catalog"/>
43+
<argument name="User" value="limitedAccessRole"/>
44+
</actionGroup>
45+
<actionGroup ref="AdminCreateUserWithRoleActionGroup" stepKey="createRestrictedAdmin">
46+
<argument name="role" value="limitedAccessRole"/>
47+
<argument name="user" value="Admin3"/>
48+
</actionGroup>
49+
<!-- Logout and login with newly created restricted user -->
50+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAsAdmin"/>
51+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsLimitedAdmin">
52+
<argument name="username" value="{{Admin3.username}}"/>
53+
<argument name="password" value="{{Admin3.password}}"/>
54+
</actionGroup>
55+
<actionGroup ref="NavigateToCreatedProductEditPageActionGroup" stepKey="navigateToProductPage" >
56+
<argument name="product" value="$$createSimpleProduct$$"/>
57+
</actionGroup>
58+
<actionGroup ref="AdminOpenContentSectionOnProductPageActionGroup" stepKey="openContentSection"/>
59+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct"/>
60+
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="checkProductSavedMessage"/>
61+
</test>
62+
</tests>

0 commit comments

Comments
 (0)