Skip to content

Commit bc65cde

Browse files
author
Hwashiang Yu
committed
MC-15297: Selecting "Conditions Combination" For Product List Condition Will Throw 500 Error & Redirect User To Broken Page
- Added test, action group, and section to test the fix
1 parent 0a0ebd3 commit bc65cde

File tree

3 files changed

+86
-20
lines changed

3 files changed

+86
-20
lines changed

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/ContentTypeProductsActionGroup.xml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,42 @@
8787
<click selector="{{page.conditionsListConditionPlaceholder}}" stepKey="revealCategoryInput"/>
8888
<fillField selector="{{page.conditionsListConditionInput}}" userInput="{{category}}" stepKey="fillCategoryField"/>
8989
</actionGroup>
90+
<actionGroup name="addSKUConditionToProductsBlock">
91+
<arguments>
92+
<argument name="page" defaultValue=""/>
93+
<argument name="SKU" defaultValue="" type="string"/>
94+
<argument name="conditionIndex" defaultValue="1" type="string"/>
95+
</arguments>
96+
<waitForElementVisible selector="{{page.conditionsList}}" stepKey="waitForConditionsToLoad"/>
97+
<click selector="{{page.conditionsListAddButton}}" stepKey="addCondition"/>
98+
<selectOption selector="{{page.conditionsListAddTypeSelect}}" userInput="Magento\CatalogWidget\Model\Rule\Condition\Product|sku" stepKey="selectSKUOption"/>
99+
<waitForLoadingMaskToDisappear stepKey="waitForCategoriesToLoad"/>
100+
<click selector="{{page.conditionsListConditionPlaceholder}}" stepKey="revealSKUInput"/>
101+
<fillField selector="{{page.conditionsListConditionInput}}" userInput="{{SKU}}" stepKey="fillSKUField"/>
102+
</actionGroup>
90103
<actionGroup name="addCategoryConditionViaConditionsCombinationToProducts">
91104
<arguments>
92105
<argument name="page" defaultValue="ProductsContentTypeForm"/>
93106
<argument name="category" defaultValue="" type="string"/>
94-
<argument name="aggregatorType" defaultValue="ALL" type="string"/>
95-
<argument name="booleanValueForAggregator" defaultValue="TRUE" type="string"/>
107+
<argument name="aggregatorType" defaultValue="all" type="string"/>
108+
<argument name="booleanValueForAggregator" defaultValue="1" type="string"/>
109+
<argument name="depth" defaultValue="2" type="string"/>
96110
</arguments>
97111
<waitForElementVisible selector="{{page.conditionsList}}" stepKey="waitForConditionsToLoad"/>
98112
<click selector="{{page.conditionsListAddButton}}" stepKey="addCondition"/>
99113
<selectOption selector="{{page.conditionsListAddTypeSelect}}" userInput="Magento\CatalogWidget\Model\Rule\Condition\Combine" stepKey="selectCombineOption"/>
100114
<waitForLoadingMaskToDisappear stepKey="waitForConditionsCombinationTemplateToLoad"/>
115+
<click selector="{{page.conditionsCombinationAggregateSelector(depth)}}" stepKey="addAggregateType"/>
116+
<selectOption selector="{{page.conditionsCombinationAggregateSelectorSelect(depth)}}" userInput="{{aggregatorType}}" stepKey="selectAggregateType"/>
117+
<waitForLoadingMaskToDisappear stepKey="waitForAggregateTypeToLoad"/>
118+
<click selector="{{page.conditionsListText}}" stepKey="clearOptions"/>
119+
<click selector="{{page.conditionsCombinationAggregateBooleanSelector(depth)}}" stepKey="addBooleanAggregateType"/>
120+
<selectOption selector="{{page.conditionsCombinationAggregateBooleanSelectorSelect(depth)}}" userInput="{{booleanValueForAggregator}}" stepKey="selectBooleanAggregateType"/>
121+
<waitForLoadingMaskToDisappear stepKey="waitForBooleanAggregateTypeToLoad"/>
122+
<click selector="{{page.conditionsListText}}" stepKey="clearOptions2"/>
123+
<click selector="{{page.conditionsListAddButton}}" stepKey="addCategoryCondition"/>
124+
<selectOption selector="{{page.conditionsListAddTypeSelect}}" userInput="Magento\CatalogWidget\Model\Rule\Condition\Product|category_ids" stepKey="selectCategoryOption"/>
125+
<waitForLoadingMaskToDisappear stepKey="waitForCategoriesToLoad"/>
101126
<click selector="{{page.conditionsListConditionPlaceholder}}" stepKey="revealCategoryInput"/>
102127
<fillField selector="{{page.conditionsListConditionInput}}" userInput="{{category}}" stepKey="fillCategoryField"/>
103128
</actionGroup>

app/code/Magento/PageBuilder/Test/Mftf/Section/PageBuilderProductsSection.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<element name="padding" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][contains(@style,'padding: {{arg2}}px;')]" parameterized="true"/>
3939
</section>
4040
<section name="ProductsContentTypeForm">
41+
<element name="conditionsListText" type="text" selector="//label[contains(@class,'admin__field-label')]//span[text()='Condition']"/>
4142
<element name="conditionsList" type="text" selector=".rule-param-children"/>
4243
<element name="conditionsListAddButton" type="button" selector=".rule-param-new-child img"/>
4344
<element name="conditionsListAddTypeSelect" type="select" selector=".rule-param-new-child select"/>
@@ -46,6 +47,10 @@
4647
<element name="conditionsListConditionApply" type="button" selector=".rule-param-apply img"/>
4748
<element name="conditionsListSavedValue" type="text" selector="//ul[contains(@class,'rule-param-children')]//li[{{arg1}}]//span[@class='rule-param'][{{arg2}}]/a" parameterized="true"/>
4849
<element name="productsCountInput" type="input" selector="input[name='products_count']"/>
50+
<element name="conditionsCombinationAggregateSelector" type="button" selector="//ul[contains(@class,'rule-param-children')]//span[contains(@class,'rule-param')]//select[contains(@id,'1--{{arg1}}__aggregator')]/ancestor::span[contains(@class,'rule-param')]//a" parameterized="true"/>
51+
<element name="conditionsCombinationAggregateBooleanSelector" type="button" selector="//ul[contains(@class,'rule-param-children')]//span[contains(@class,'rule-param')]//select[contains(@id,'1--{{arg1}}__value')]/ancestor::span[contains(@class,'rule-param')]//a" parameterized="true"/>
52+
<element name="conditionsCombinationAggregateSelectorSelect" type="button" selector="//ul[contains(@class,'rule-param-children')]//span[contains(@class,'rule-param')]//select[contains(@id,'1--{{arg1}}__aggregator')]" parameterized="true"/>
53+
<element name="conditionsCombinationAggregateBooleanSelectorSelect" type="button" selector="//ul[contains(@class,'rule-param-children')]//span[contains(@class,'rule-param')]//select[contains(@id,'1--{{arg1}}__value')]" parameterized="true"/>
4954
</section>
5055
<section name="ProductsOnStorefront">
5156
<element name="base" type="text" selector="(//div[contains(@data-content-type,'products')])[{{arg1}}]" parameterized="true"/>

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderProductsTest.xml

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,7 @@
15411541
<before>
15421542
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
15431543
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
1544+
<createData entity="_emptyCmsPage" stepKey="createCMSPage"/>
15441545
</before>
15451546
<after>
15461547
<actionGroup ref="DeleteCategory" stepKey="deleteCategory">
@@ -1549,8 +1550,10 @@
15491550
<actionGroup ref="deleteProductBySku" stepKey="deleteProduct">
15501551
<argument name="sku" value="{{SimpleProduct.sku}}"/>
15511552
</actionGroup>
1553+
<deleteData createDataKey="createCMSPage" stepKey="deleteCMSPage" />
15521554
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
15531555
</after>
1556+
<!-- Create Simple Product -->
15541557
<actionGroup ref="FillAdminSimpleProductForm" stepKey="createProduct">
15551558
<argument name="category" value="SimpleSubCategory"/>
15561559
<argument name="simpleProduct" value="SimpleProduct"/>
@@ -1560,9 +1563,8 @@
15601563
<see userInput="You saved the product." stepKey="seeSuccessfulProductSaveMessage"/>
15611564
<!-- Create CMS Page with product content types -->
15621565
<comment userInput="Create CMS Page with product content types" stepKey="createCMSPageWithProduct"/>
1563-
<actionGroup ref="navigateToAPageWithPageBuilder" stepKey="navigateToAPageWithPageBuilder"/>
1564-
<actionGroup ref="addPageBuilderPageTitle" stepKey="enterPageTitle">
1565-
<argument name="contentType" value="PageBuilderProductsContentType"/>
1566+
<actionGroup ref="navigateToCreatedCMSPage" stepKey="navigateToCreatedCMSPage">
1567+
<argument name="CMSPage" value="$$createCMSPage$$"/>
15661568
</actionGroup>
15671569
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage"/>
15681570
<actionGroup ref="expandPageBuilderPanelMenuSection" stepKey="expandPageBuilderPanelGroup">
@@ -1574,23 +1576,48 @@
15741576
<actionGroup ref="openPageBuilderEditPanel" stepKey="openEditAfterDrop">
15751577
<argument name="contentType" value="PageBuilderProductsContentType"/>
15761578
</actionGroup>
1577-
1579+
<!-- Add SKU of product to ensure the correct item shows up -->
1580+
<comment userInput="Add SKU of product and limit 1 to ensure the correct item shows up" stepKey="commentLimitProductToCorrectItem"/>
1581+
<actionGroup ref="addSKUConditionToProductsBlock" stepKey="addSKU">
1582+
<argument name="page" value="ProductsContentTypeForm"/>
1583+
<argument name="SKU" value="{{SimpleProduct.sku}}"/>
1584+
</actionGroup>
1585+
<!-- Add Conditions Combination -->
1586+
<comment userInput="Add Conditions Combination" stepKey="commentAddConditionsCombination"/>
15781587
<actionGroup ref="addCategoryConditionViaConditionsCombinationToProducts" stepKey="addCategoryWrappedInConditionalCombineWithTrueValue">
15791588
<argument name="page" value="ProductsContentTypeForm"/>
15801589
<argument name="category" value="$$createCategory.id$$"/>
15811590
</actionGroup>
1582-
15831591
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettings"/>
1584-
15851592
<!-- Validate Stage -->
15861593
<comment userInput="Validate Stage" stepKey="commentValidateStage"/>
15871594
<actionGroup ref="validateProductCountInProducts" stepKey="validateProductsCountStage1">
15881595
<argument name="page" value="ProductsOnStage"/>
15891596
<argument name="count" value="1"/>
15901597
</actionGroup>
1591-
<actionGroup ref="saveAndContinueEditCmsPage" stepKey="saveAndContinueEditCmsPage2"/>
1598+
<actionGroup ref="validateProductInProducts" stepKey="validateProductsStage1">
1599+
<argument name="page" value="ProductsOnStorefront"/>
1600+
<argument name="product" value="SimpleProduct"/>
1601+
</actionGroup>
1602+
<actionGroup ref="saveAndContinueEditCmsPage" stepKey="saveAndContinueEditCmsPage"/>
1603+
<actionGroup ref="navigateToStorefrontForCreatedPage" stepKey="navigateToStorefront">
1604+
<argument name="page" value="$$createCMSPage.identifier$$"/>
1605+
</actionGroup>
1606+
<!-- Validate Storefront -->
1607+
<comment userInput="Validate Storefront" stepKey="commentValidateStorefront"/>
1608+
<actionGroup ref="validateProductCountInProducts" stepKey="validateProductCountStorefront">
1609+
<argument name="page" value="ProductsOnStorefront"/>
1610+
<argument name="count" value="1"/>
1611+
</actionGroup>
1612+
<!-- Changing Category Condition to False -->
1613+
<comment userInput="Changing Category Condition to False" stepKey="commentChangingCategoryConditionToFalse"/>
1614+
<actionGroup ref="navigateToCreatedCMSPage" stepKey="navigateToCreatedCMSPage2">
1615+
<argument name="CMSPage" value="$$createCMSPage$$"/>
1616+
</actionGroup>
15921617
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage2"/>
1593-
1618+
<actionGroup ref="removeContentTypeFromStage" stepKey="removeProducts">
1619+
<argument name="contentType" value="PageBuilderProductsContentType"/>
1620+
</actionGroup>
15941621
<actionGroup ref="expandPageBuilderPanelMenuSection" stepKey="expandPageBuilderPanelGroup2">
15951622
<argument name="contentType" value="PageBuilderProductsContentType"/>
15961623
</actionGroup>
@@ -1600,20 +1627,29 @@
16001627
<actionGroup ref="openPageBuilderEditPanel" stepKey="openEditAfterDrop2">
16011628
<argument name="contentType" value="PageBuilderProductsContentType"/>
16021629
</actionGroup>
1603-
1630+
<!-- Add SKU of product to ensure the correct item shows up -->
1631+
<comment userInput="Add SKU of product to ensure the correct item shows up" stepKey="commentLimitProductToCorrectItem2"/>
1632+
<actionGroup ref="addSKUConditionToProductsBlock" stepKey="addSKU2">
1633+
<argument name="page" value="ProductsContentTypeForm"/>
1634+
<argument name="SKU" value="{{SimpleProduct.sku}}"/>
1635+
</actionGroup>
1636+
<!-- Add Conditions Combination -->
1637+
<comment userInput="Add Conditions Combination" stepKey="commentAddConditionsCombination2"/>
16041638
<actionGroup ref="addCategoryConditionViaConditionsCombinationToProducts" stepKey="addCategoryWrappedInConditionalCombineWithFalseValue">
16051639
<argument name="page" value="ProductsContentTypeForm"/>
16061640
<argument name="category" value="$$createCategory.id$$"/>
1607-
<argument name="aggregatorType" value="ALL"/>
1608-
<argument name="booleanValueForAggregator" value="FALSE"/>
1641+
<argument name="booleanValueForAggregator" value="0"/>
16091642
</actionGroup>
1610-
1611-
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettings2"/>
1612-
<!-- Validate Stage -->
1613-
<comment userInput="Validate Stage" stepKey="commentValidateStage"/>
1614-
<actionGroup ref="validateProductCountInProducts" stepKey="validateProductsCountStage1">
1615-
<argument name="page" value="ProductsOnStage"/>
1616-
<argument name="count" value="1"/>
1643+
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettingsAfterChangingToFalse"/>
1644+
<!-- Validate Stage After Changing to False -->
1645+
<comment userInput="Validate Stage Changing to False" stepKey="commentValidateStageAfterChangingToFalse"/>
1646+
<seeElement selector="{{ProductsOnStage.emptyProductsPlaceholder('1')}}" stepKey="validateProductCountStageAfterChangingToFalse"/>
1647+
<actionGroup ref="saveAndContinueEditCmsPage" stepKey="saveAndContinueEditCmsPage2"/>
1648+
<actionGroup ref="navigateToStorefrontForCreatedPage" stepKey="navigateToStorefrontAfterChangingToFalse">
1649+
<argument name="page" value="$$createCMSPage.identifier$$"/>
16171650
</actionGroup>
1651+
<!-- Validate Storefront -->
1652+
<comment userInput="Validate Storefront" stepKey="commentValidateStorefrontAfterChangingToFalse"/>
1653+
<dontSeeElementInDOM selector="{{ProductsOnStorefront.product('1')}}" stepKey="validateProductCountStorefrontAfterChangingToFalse"/>
16181654
</test>
16191655
</tests>

0 commit comments

Comments
 (0)