Skip to content

Commit ce47c90

Browse files
committed
MC-42779: Error on page builder when adding products for users not having admin access
1 parent 4a26ae9 commit ce47c90

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,25 @@
8484
<item name="Magento_PageBuilder::templates">Magento_PageBuilder::templates</item>
8585
</array>
8686
</entity>
87+
<entity name="rolePageBuilderProductWidgetEdit" type="user_role">
88+
<data key="name" unique="suffix">Role_Page_Builder_Product_Widget_</data>
89+
<data key="rolename" unique="suffix">Role_Page_Builder_Product_Widget_</data>
90+
<data key="current_password">{{_ENV.MAGENTO_ADMIN_PASSWORD}}</data>
91+
<data key="all">0</data>
92+
<data key="gws_is_all">0</data>
93+
<array key="gws_websites">
94+
<item>1</item>
95+
</array>
96+
<array key="resource">
97+
<item name="Magento_Backend::dashboard">Magento_Backend::dashboard</item>
98+
<item name="Magento_Backend::content">Magento_Backend::content</item>
99+
<item name="Magento_Backend::content_elements">Magento_Backend::content_elements</item>
100+
<item name="Magento_Cms::page">Magento_Cms::page</item>
101+
<item name="Magento_Cms::save">Magento_Cms::save</item>
102+
<item name="Magento_Cms::save_design">Magento_Cms::save_design</item>
103+
<item name="Magento_Widget::widget_instance">Magento_Widget::widget_instance</item>
104+
</array>
105+
</entity>
87106
<entity name="rolePageBuilderSaveTemplates" type="user_role" extends="adminRestrictedProductRole">
88107
<data key="name" unique="suffix">Role_Page_Builder_Save_Templates_</data>
89108
<data key="rolename" unique="suffix">Role_Page_Builder_Save_Templates_</data>

app/code/Magento/PageBuilder/Test/Mftf/Section/PageBuilderEditFormSection/EditPanelFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<element name="panelFieldLabel" type="text" selector="//aside//div[@data-index=&quot;{{arg1}}&quot;]/descendant::div[@data-index=&quot;{{arg2}}&quot;]/descendant::label[not(contains(@style,&quot;display: none;&quot;))] | //aside//div[@data-index=&quot;{{arg3}}&quot;]/descendant::*[@class=&quot;admin__field-label&quot; or @class=&quot;title&quot;]/descendant::span[text()=&quot;{{arg4}}&quot;][not(ancestor::legend)]" parameterized="true"/>
1919
<element name="panelSectionChangedIcon" type="text" selector="[data-index='{{arg1}}'] ._changed .admin__page-nav-item-message-icon" parameterized="true"/>
2020
<element name="panelSectionError" type="text" selector="[data-index='{{arg1}}'] span._error .admin__page-nav-item-message-icon" parameterized="true"/>
21+
<element name="panelSectionGenericError" type="text" selector="div.message.message-error.error"/>
2122
<element name="panelFieldControl" type="input" selector="//aside//div[@data-index=&quot;{{arg1}}&quot;]/descendant::*[@name=&quot;{{arg2}}&quot;]" parameterized="true"/>
2223
<element name="panelFieldControlCheckbox" type="input" selector="//input[@type='checkbox' and @name='{{arg1}}']" parameterized="true"/>
2324
<element name="panelFieldControlCheckboxState" type="input" selector="//input[@type='checkbox' and @name='{{arg1}}' and @value='{{arg2}}']" parameterized="true"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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="AdminPageBuilderProductsCarouselDisplayProductCountForRestrictedAdminTest" extends="AdminPageBuilderProductsGridValidateAppearanceTest">
11+
<annotations>
12+
<features value="PageBuilder"/>
13+
<stories value="Products"/>
14+
<title value="Restricted admin with access to CMS Page Edits and Widgets should be able to add product widget without errors"/>
15+
<description value="Restricted admin with access to CMS Page Edits and Widgets should be able to add product widget on CMS Page using Page Builder without errors"/>
16+
<severity value="CRITICAL"/>
17+
<useCaseId value="MC-42779"/>
18+
<testCaseId value="MC-43007"/>
19+
<group value="pagebuilder"/>
20+
<group value="pagebuilder-products"/>
21+
<group value="pagebuilder-productsCarousel"/>
22+
</annotations>
23+
24+
<before>
25+
<!-- Create a restricted role with access only to CMS and Widgets -->
26+
<createData entity="rolePageBuilderProductWidgetEdit" after="createCMSPage" stepKey="role2"/>
27+
28+
<!-- Create an restricted admin user assigned to role -->
29+
<actionGroup ref="AdminCreateUserWithApiRoleActionGroup" after="loginAsAdmin" stepKey="adminCreateUser">
30+
<argument name="user" value="NewAdminUser"/>
31+
<argument name="role" value="rolePageBuilderProductWidgetEdit"/>
32+
</actionGroup>
33+
34+
<!-- Log out main Admin user -->
35+
<actionGroup ref="AdminLogoutActionGroup" after="adminCreateUser" stepKey="logout"/>
36+
37+
<!-- Log in restricted Admin user -->
38+
<actionGroup ref="AdminLoginActionGroup" after="logout" stepKey="loginAsRestrictedAdmin">
39+
<argument name="username" value="{{NewAdminUser.username}}"/>
40+
<argument name="password" value="{{NewAdminUser.password}}"/>
41+
</actionGroup>
42+
</before>
43+
44+
<after>
45+
<!-- Log in main Admin user after restricted Admin was logged out -->
46+
<actionGroup ref="AdminLoginActionGroup" after="logout" stepKey="loginAsAdmin"/>
47+
48+
<!-- Delete restricted Admin user -->
49+
<actionGroup ref="AdminDeleteCustomUserActionGroup" after="loginAsAdmin" stepKey="deleteUser">
50+
<argument name="user" value="NewAdminUser"/>
51+
</actionGroup>
52+
53+
<!-- Delete restricted role -->
54+
<actionGroup ref="AdminDeleteRoleByRoleNameActionGroup" after="deleteUser" stepKey="deleteRole2">
55+
<argument name="role" value="rolePageBuilderProductWidgetEdit"/>
56+
</actionGroup>
57+
</after>
58+
59+
<!-- Confirm there is no error message on screen -->
60+
<dontSeeElement selector="{{EditPanelForm.panelSectionGenericError}}" after="openEditAfterDrop" stepKey="validateNoErrorMessageVisible"/>
61+
62+
<!-- Validate product total count for product selection conditions shows correct value -->
63+
<actionGroup ref="validateProductTotals" after="selectCategory" stepKey="assertProductCountOnPanel">
64+
<argument name="productsTotals" value="of 6 total"/>
65+
</actionGroup>
66+
</test>
67+
</tests>

0 commit comments

Comments
 (0)