From 7600c7cf07907695e1600c5e664c8a8d1cb0816c Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii Date: Fri, 20 Mar 2020 09:54:10 +0200 Subject: [PATCH 1/8] product attribute - deny HTML tags for labels --- .../adminhtml/templates/catalog/product/attribute/labels.phtml | 2 +- .../view/adminhtml/ui_component/product_attribute_add_form.xml | 1 + .../Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/labels.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/labels.phtml index 1d5d251f00de9..e5c943d24b519 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/labels.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/labels.phtml @@ -29,7 +29,7 @@ getLabelValues() ?> getStores() as $_store) :?> - true true + true string diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php index be9d2700664c7..adad61417a4f6 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php @@ -130,7 +130,8 @@ protected function _prepareForm() 'label' => __('Default Label'), 'title' => __('Default label'), 'required' => true, - 'value' => is_array($labels) ? $labels[0] : $labels + 'value' => is_array($labels) ? $labels[0] : $labels, + 'class' => 'validate-no-html-tags', ] ); From 6cbfa7754beb020200ba008947b0c2d36595e7f6 Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii Date: Fri, 20 Mar 2020 19:03:46 +0200 Subject: [PATCH 2/8] fix code style failed tests --- .../templates/catalog/product/attribute/labels.phtml | 10 ++++++---- .../Adminhtml/Attribute/Edit/Main/AbstractMain.php | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/labels.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/labels.phtml index e5c943d24b519..85a6b347f2feb 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/labels.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/labels.phtml @@ -19,7 +19,7 @@ - getStores() as $_store) :?> + getStores() as $_store): ?> @@ -27,13 +27,15 @@ getLabelValues() ?> - getStores() as $_store) :?> + getStores() as $_store): ?> diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php index adad61417a4f6..6f2a5b2163fda 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php @@ -283,6 +283,7 @@ protected function _initFormValues() * Adding js block to the end of this block * * @param string $html + * * @return string */ protected function _afterToHtml($html) From b4b22a40e2a153ace29fb9c105d261d12a63f688 Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii Date: Sat, 21 Mar 2020 17:06:33 +0200 Subject: [PATCH 3/8] fix code style failed tests --- .../Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php index 6f2a5b2163fda..fe660f01c8244 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php @@ -284,7 +284,7 @@ protected function _initFormValues() * * @param string $html * - * @return string + * @return string */ protected function _afterToHtml($html) { From 2e3128f56508aeeafb8229fe36241782135408ae Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii Date: Sat, 21 Mar 2020 18:29:18 +0200 Subject: [PATCH 4/8] Added the MFTF test that checks attribute won't save with HTML tags in labels --- ...ctAttributeDefaultStoreViewActionGroup.xml | 16 ++++++ ...ttributeWithHtmlTagsInLabelActionGroup.xml | 29 +++++++++++ .../Test/Mftf/Data/ProductAttributeData.xml | 5 ++ .../AdminCreateProductAttributeSection.xml | 5 ++ ...uctAttributeLabelDontAllowHtmlTagsTest.xml | 50 +++++++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillProductAttributeDefaultStoreViewActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveProductAttributeWithHtmlTagsInLabelActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillProductAttributeDefaultStoreViewActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillProductAttributeDefaultStoreViewActionGroup.xml new file mode 100644 index 0000000000000..92fa687a442ee --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillProductAttributeDefaultStoreViewActionGroup.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveProductAttributeWithHtmlTagsInLabelActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveProductAttributeWithHtmlTagsInLabelActionGroup.xml new file mode 100644 index 0000000000000..26751f9659005 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveProductAttributeWithHtmlTagsInLabelActionGroup.xml @@ -0,0 +1,29 @@ + + + + + + + Clicks on Save. Validates that the HTML tags issue is present. + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml index e4a91902cb79b..d918ad35873ca 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml @@ -406,6 +406,11 @@ Size size_attr + + Attribute Default label <span> + Attribute Store label <span> + text + attribute diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml index 0934e39dcb062..07f9b66966b6c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml @@ -50,6 +50,11 @@ +
+ + + +
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml new file mode 100644 index 0000000000000..1e6add929ffa0 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml @@ -0,0 +1,50 @@ + + + + + + + + + + <description value="Test whenever HTML tags are allowed for a product attribute label"/> + <severity value="CRITICAL"/> + <group value="catalog"/> + </annotations> + <before> + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <!-- Log out --> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + </after> + + <!-- Go to Stores > Attributes > Product , click "Add New Attribute" --> + <actionGroup ref="AdminOpenProductAttributePageActionGroup" stepKey="openProductAttributePage"/> + <click selector="{{AdminProductAttributeGridSection.createNewAttributeBtn}}" stepKey="createNewAttribute"/> + + <!-- Input value for Default Label --> + <actionGroup ref="AdminFillProductAttributePropertiesActionGroup" stepKey="fillAttributeDefaultLabel"> + <argument name="attributeName" value="{{productAttributeWithHtmlTagsInLabel.default_label}}"/> + <argument name="attributeType" value="{{productAttributeWithHtmlTagsInLabel.frontend_input}}" /> + </actionGroup> + + <!-- Click on "Manage Labels" tab on left menu --> + <click selector="{{ManageLabelsSection.ManageLabelsTab}}" stepKey="clickManageLabelsTab"/> + + <!-- Input value for Default Store View --> + <actionGroup ref="AdminFillProductAttributeDefaultStoreViewActionGroup" stepKey="fillAttributeDefaultStoreViewLabel"> + <argument name="value" value="{{productAttributeWithHtmlTagsInLabel.default_store_label}}"/> + </actionGroup> + + <!-- Save Product Attribute --> + <actionGroup ref="SaveProductAttributeWithHtmlTagsInLabelActionGroup" stepKey="saveAttribute"/> + </test> +</tests> From ae2038eb74ad2f084b5b01f05f6215c12f243edf Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii <v.burlacu@atwix.com> Date: Sun, 22 Mar 2020 11:25:26 +0200 Subject: [PATCH 5/8] Refactored the MFTF tests according to the review --- ...ctAttributeDefaultStoreViewActionGroup.xml | 2 +- ...teToNewProductAttributePageActionGroup.xml | 19 ++++++++++++++++++ .../AdminSaveProductAttributeActionGroup.xml | 20 +++++++++++++++++++ ...uteHtmlTagsValidationErrorActionGroup.xml} | 8 ++------ .../AdminCreateProductAttributeSection.xml | 5 ----- ...minProductAttributeManageLabelsSection.xml | 15 ++++++++++++++ ...uctAttributeLabelDontAllowHtmlTagsTest.xml | 20 +++++++------------ 7 files changed, 64 insertions(+), 25 deletions(-) create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminNavigateToNewProductAttributePageActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSaveProductAttributeActionGroup.xml rename app/code/Magento/Catalog/Test/Mftf/ActionGroup/{SaveProductAttributeWithHtmlTagsInLabelActionGroup.xml => AssertSeeProductAttributeHtmlTagsValidationErrorActionGroup.xml} (67%) create mode 100644 app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillProductAttributeDefaultStoreViewActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillProductAttributeDefaultStoreViewActionGroup.xml index 92fa687a442ee..42d205f0fb397 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillProductAttributeDefaultStoreViewActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillProductAttributeDefaultStoreViewActionGroup.xml @@ -11,6 +11,6 @@ <arguments> <argument name="value" type="string"/> </arguments> - <fillField selector="{{ManageLabelsSection.DefaultStoreLabel}}" userInput="{{value}}" stepKey="fillDefaultStoreViewLabel"/> + <fillField selector="{{AdminProductAttributeManageLabelsSection.DefaultStoreLabel}}" userInput="{{value}}" stepKey="fillDefaultStoreViewLabel"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminNavigateToNewProductAttributePageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminNavigateToNewProductAttributePageActionGroup.xml new file mode 100644 index 0000000000000..b7dbcc2c86dc4 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminNavigateToNewProductAttributePageActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminNavigateToNewProductAttributePageActionGroup"> + <annotations> + <description>Go to the create new product attribute page</description> + </annotations> + + <amOnPage url="{{ProductAttributePage.url}}" stepKey="goToNewProductAttributePage"/> + <waitForPageLoad stepKey="waitForAttributePageLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSaveProductAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSaveProductAttributeActionGroup.xml new file mode 100644 index 0000000000000..956dc3bf6fa52 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSaveProductAttributeActionGroup.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminSaveProductAttributeActionGroup"> + <annotations> + <description>Clicks on Save button to save the attribute.</description> + </annotations> + + <waitForElementVisible selector="{{AttributePropertiesSection.Save}}" stepKey="waitForSaveButton"/> + <click selector="{{AttributePropertiesSection.Save}}" stepKey="clickSaveButton"/> + <waitForPageLoad stepKey="waitForAttributeToSave"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveProductAttributeWithHtmlTagsInLabelActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeHtmlTagsValidationErrorActionGroup.xml similarity index 67% rename from app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveProductAttributeWithHtmlTagsInLabelActionGroup.xml rename to app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeHtmlTagsValidationErrorActionGroup.xml index 26751f9659005..df57b4ae2093e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveProductAttributeWithHtmlTagsInLabelActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeHtmlTagsValidationErrorActionGroup.xml @@ -8,15 +8,11 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="SaveProductAttributeWithHtmlTagsInLabelActionGroup"> + <actionGroup name="AssertSeeProductAttributeValidationErrorActionGroup"> <annotations> - <description>Clicks on Save. Validates that the HTML tags issue is present.</description> + <description>Validates that the HTML tags issue is present on the attribute page after save.</description> </annotations> - <waitForElementVisible selector="{{AttributePropertiesSection.Save}}" stepKey="waitForSaveButton"/> - <click selector="{{AttributePropertiesSection.Save}}" stepKey="clickSaveButton"/> - <waitForPageLoad stepKey="waitForAttributeToSave"/> - <!-- See the error message on the "Manage Labels Tab" --> <seeElement selector="#attribute-labels-table .mage-error" stepKey="seeHtmlTagsUsageErrorMessage1"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml index 07f9b66966b6c..0934e39dcb062 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml @@ -50,11 +50,6 @@ <element name="StorefrontPropertiesSectionToggle" type="button" selector="#front_fieldset-wrapper"/> <element name="visibleOnCatalogPagesOnStorefront" type="select" selector="#is_visible_on_front"/> </section> - <section name="ManageLabelsSection"> - <element name="PageTitle" type="text" selector="//span[text()='Manage Titles (Size, Color, etc.)']" /> - <element name="ManageLabelsTab" selector="#product_attribute_tabs_labels" type="button"/> - <element name="DefaultStoreLabel" type="input" selector="#attribute-labels-table [name='frontend_label[1]']"/> - </section> <section name="WYSIWYGProductAttributeSection"> <element name="ShowHideBtn" type="button" selector="#toggledefault_value_texteditor"/> <element name="InsertImageBtn" type="button" selector=".scalable.action-add-image.plugin"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml new file mode 100644 index 0000000000000..048016620c94d --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminProductAttributeManageLabelsSection"> + <element name="ManageLabelsTab" selector="#product_attribute_tabs_labels" type="button"/> + <element name="DefaultStoreLabel" type="input" selector="#attribute-labels-table [name='frontend_label[1]']"/> + </section> +</sections> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml index 1e6add929ffa0..b967403b0eb80 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml @@ -18,33 +18,27 @@ <group value="catalog"/> </annotations> <before> - <!-- Login as admin --> - <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> <after> - <!-- Log out --> - <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAdmin"/> </after> - <!-- Go to Stores > Attributes > Product , click "Add New Attribute" --> - <actionGroup ref="AdminOpenProductAttributePageActionGroup" stepKey="openProductAttributePage"/> - <click selector="{{AdminProductAttributeGridSection.createNewAttributeBtn}}" stepKey="createNewAttribute"/> + <actionGroup ref="AdminNavigateToNewProductAttributePageActionGroup" stepKey="openProductAttributePage"/> - <!-- Input value for Default Label --> <actionGroup ref="AdminFillProductAttributePropertiesActionGroup" stepKey="fillAttributeDefaultLabel"> <argument name="attributeName" value="{{productAttributeWithHtmlTagsInLabel.default_label}}"/> <argument name="attributeType" value="{{productAttributeWithHtmlTagsInLabel.frontend_input}}" /> </actionGroup> - <!-- Click on "Manage Labels" tab on left menu --> - <click selector="{{ManageLabelsSection.ManageLabelsTab}}" stepKey="clickManageLabelsTab"/> + <click selector="{{AdminProductAttributeManageLabelsSection.ManageLabelsTab}}" stepKey="clickManageLabelsTab"/> - <!-- Input value for Default Store View --> <actionGroup ref="AdminFillProductAttributeDefaultStoreViewActionGroup" stepKey="fillAttributeDefaultStoreViewLabel"> <argument name="value" value="{{productAttributeWithHtmlTagsInLabel.default_store_label}}"/> </actionGroup> - <!-- Save Product Attribute --> - <actionGroup ref="SaveProductAttributeWithHtmlTagsInLabelActionGroup" stepKey="saveAttribute"/> + <actionGroup ref="AdminSaveProductAttributeActionGroup" stepKey="saveAttribute"/> + + <actionGroup ref="AssertSeeProductAttributeValidationErrorActionGroup" stepKey="validateAttributeLabelsForHtmlTags"/> </test> </tests> From 32b6ce68c8b5a2b4ef1dee3a8a4ca793162f4355 Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii <v.burlacu@atwix.com> Date: Mon, 23 Mar 2020 11:08:35 +0200 Subject: [PATCH 6/8] improved the MFTF tests --- ...buteHtmlTagsValidationErrorActionGroup.xml | 25 ------------------- ...uctAttributeValidationErrorActionGroup.xml | 24 ++++++++++++++++++ .../Page/AdminProductAttributeFormPage.xml | 1 + ...uctAttributeLabelDontAllowHtmlTagsTest.xml | 12 ++++++++- 4 files changed, 36 insertions(+), 26 deletions(-) delete mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeHtmlTagsValidationErrorActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeHtmlTagsValidationErrorActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeHtmlTagsValidationErrorActionGroup.xml deleted file mode 100644 index df57b4ae2093e..0000000000000 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeHtmlTagsValidationErrorActionGroup.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> - -<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertSeeProductAttributeValidationErrorActionGroup"> - <annotations> - <description>Validates that the HTML tags issue is present on the attribute page after save.</description> - </annotations> - - <!-- See the error message on the "Manage Labels Tab" --> - <seeElement selector="#attribute-labels-table .mage-error" stepKey="seeHtmlTagsUsageErrorMessage1"/> - - <!-- Click on "Properties" tab on left menu --> - <click selector="{{AttributePropertiesSection.propertiesTab}}" stepKey="clickPropertiesTab"/> - - <!-- See the error message on the "Properties" Tab --> - <seeElement selector=".field-attribute_label .mage-error" stepKey="seeHtmlTagsUsageErrorMessage2"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml new file mode 100644 index 0000000000000..590828fca8185 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AssertSeeProductAttributeValidationErrorActionGroup"> + <annotations> + <description>Check whenever the validation is present for the product attribute</description> + </annotations> + + <arguments> + <argument name="selector" type="string"/> + <argument name="message" type="string"/> + </arguments> + + <seeElement selector="{{selector}}" stepKey="seeValidationDomElement"/> + <see userInput="{{message}}" selector="{{selector}}" stepKey="seeValidationMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Page/AdminProductAttributeFormPage.xml b/app/code/Magento/Catalog/Test/Mftf/Page/AdminProductAttributeFormPage.xml index fab87f90f86dd..3acaaf4e1775d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Page/AdminProductAttributeFormPage.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Page/AdminProductAttributeFormPage.xml @@ -9,5 +9,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> <page name="ProductAttributePage" url="catalog/product_attribute/new/" area="admin" module="Catalog"> <section name="AdminCreateProductAttributeSection"/> + <section name="AdminProductAttributeManageLabelsSection"/> </page> </pages> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml index b967403b0eb80..25b314e18e211 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml @@ -39,6 +39,16 @@ <actionGroup ref="AdminSaveProductAttributeActionGroup" stepKey="saveAttribute"/> - <actionGroup ref="AssertSeeProductAttributeValidationErrorActionGroup" stepKey="validateAttributeLabelsForHtmlTags"/> + <actionGroup ref="AssertSeeProductAttributeValidationErrorActionGroup" stepKey="validateAttributeStoreViewLabelForHtmlTags"> + <argument name="selector" value="#attribute-labels-table .mage-error"/> + <argument name="message" value="HTML tags are not allowed"/> + </actionGroup> + + <click selector="{{AttributePropertiesSection.propertiesTab}}" stepKey="clickPropertiesTab"/> + + <actionGroup ref="AssertSeeProductAttributeValidationErrorActionGroup" stepKey="validateAttributeLabelForHtmlTags"> + <argument name="selector" value=".field-attribute_label .mage-error"/> + <argument name="message" value="HTML tags are not allowed"/> + </actionGroup> </test> </tests> From 196e353adbd04e59d8603ca1c03e8ab88cea8d78 Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii <v.burlacu@atwix.com> Date: Mon, 23 Mar 2020 14:24:51 +0200 Subject: [PATCH 7/8] refactored MFTF tests --- ...oductAttributePageSwitchTabActionGroup.xml | 21 ++++++++++++++++ ...uctAttributeValidationErrorActionGroup.xml | 6 ++--- ...ationErrorOnManageLabelsTabActionGroup.xml | 24 +++++++++++++++++++ ...minProductAttributeManageLabelsSection.xml | 1 - ...uctAttributeLabelDontAllowHtmlTagsTest.xml | 14 ++++++----- 5 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributePageSwitchTabActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnManageLabelsTabActionGroup.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributePageSwitchTabActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributePageSwitchTabActionGroup.xml new file mode 100644 index 0000000000000..f3fcab490b3d9 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributePageSwitchTabActionGroup.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminProductAttributePageSwitchTabActionGroup"> + <annotations> + <description>Switches the active tab on the Product Attribute New/Edit Page</description> + </annotations> + <arguments> + <argument name="tabName" type="string"/> + </arguments> + + <click selector="#product_attribute_tabs a[title='{{tabName}}']" stepKey="changeProductAttributeActiveTab"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml index 590828fca8185..b612e49cd05b6 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml @@ -8,13 +8,13 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertSeeProductAttributeValidationErrorActionGroup"> + <actionGroup name="AssertSeeProductAttributeValidationErrorOnPropertiesTabActionGroup"> <annotations> - <description>Check whenever the validation is present for the product attribute</description> + <description>Check whenever the validation error is present for the product attribute in the "Properties" Tab</description> </annotations> <arguments> - <argument name="selector" type="string"/> + <argument name="selector" type="string" defaultValue=".field-attribute_label .mage-error"/> <argument name="message" type="string"/> </arguments> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnManageLabelsTabActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnManageLabelsTabActionGroup.xml new file mode 100644 index 0000000000000..a4fb1e4a4a007 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnManageLabelsTabActionGroup.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AssertSeeProductAttributeValidationErrorOnManageLabelsTabActionGroup"> + <annotations> + <description>Check whenever the validation error is present for the product attribute in the "Manage Labels" Tab</description> + </annotations> + + <arguments> + <argument name="selector" type="string" defaultValue="#attribute-labels-table .mage-error"/> + <argument name="message" type="string"/> + </arguments> + + <seeElement selector="{{selector}}" stepKey="seeValidationDomElement"/> + <see userInput="{{message}}" selector="{{selector}}" stepKey="seeValidationMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml index 048016620c94d..c5e91854468e2 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml @@ -9,7 +9,6 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminProductAttributeManageLabelsSection"> - <element name="ManageLabelsTab" selector="#product_attribute_tabs_labels" type="button"/> <element name="DefaultStoreLabel" type="input" selector="#attribute-labels-table [name='frontend_label[1]']"/> </section> </sections> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml index 25b314e18e211..f3981e7b8f76a 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductAttributeLabelDontAllowHtmlTagsTest.xml @@ -31,7 +31,9 @@ <argument name="attributeType" value="{{productAttributeWithHtmlTagsInLabel.frontend_input}}" /> </actionGroup> - <click selector="{{AdminProductAttributeManageLabelsSection.ManageLabelsTab}}" stepKey="clickManageLabelsTab"/> + <actionGroup ref="AdminProductAttributePageSwitchTabActionGroup" stepKey="makeManageLabelsTabActive"> + <argument name="tabName" value="Manage Labels"/> + </actionGroup> <actionGroup ref="AdminFillProductAttributeDefaultStoreViewActionGroup" stepKey="fillAttributeDefaultStoreViewLabel"> <argument name="value" value="{{productAttributeWithHtmlTagsInLabel.default_store_label}}"/> @@ -39,15 +41,15 @@ <actionGroup ref="AdminSaveProductAttributeActionGroup" stepKey="saveAttribute"/> - <actionGroup ref="AssertSeeProductAttributeValidationErrorActionGroup" stepKey="validateAttributeStoreViewLabelForHtmlTags"> - <argument name="selector" value="#attribute-labels-table .mage-error"/> + <actionGroup ref="AssertSeeProductAttributeValidationErrorOnManageLabelsTabActionGroup" stepKey="validateAttributeStoreViewLabelForHtmlTags"> <argument name="message" value="HTML tags are not allowed"/> </actionGroup> - <click selector="{{AttributePropertiesSection.propertiesTab}}" stepKey="clickPropertiesTab"/> + <actionGroup ref="AdminProductAttributePageSwitchTabActionGroup" stepKey="makePropertiesTabActive"> + <argument name="tabName" value="Properties"/> + </actionGroup> - <actionGroup ref="AssertSeeProductAttributeValidationErrorActionGroup" stepKey="validateAttributeLabelForHtmlTags"> - <argument name="selector" value=".field-attribute_label .mage-error"/> + <actionGroup ref="AssertSeeProductAttributeValidationErrorOnPropertiesTabActionGroup" stepKey="validateAttributeLabelForHtmlTags"> <argument name="message" value="HTML tags are not allowed"/> </actionGroup> </test> From 6b6a2f7dee40b5bf6daada05e6e52020fe015d1a Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii <v.burlacu@atwix.com> Date: Mon, 23 Mar 2020 15:14:12 +0200 Subject: [PATCH 8/8] refactored MFTF tests --- .../AdminProductAttributePageSwitchTabActionGroup.xml | 2 +- ...ctAttributeValidationErrorOnManageLabelsTabActionGroup.xml | 4 +--- ...uctAttributeValidationErrorOnPropertiesTabActionGroup.xml} | 4 +--- .../Test/Mftf/Section/AdminCreateProductAttributeSection.xml | 1 + .../Test/Mftf/Section/AdminEditProductAttributesSection.xml | 1 + .../Mftf/Section/AdminProductAttributeManageLabelsSection.xml | 1 + 6 files changed, 6 insertions(+), 7 deletions(-) rename app/code/Magento/Catalog/Test/Mftf/ActionGroup/{AssertSeeProductAttributeValidationErrorActionGroup.xml => AssertSeeProductAttributeValidationErrorOnPropertiesTabActionGroup.xml} (72%) diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributePageSwitchTabActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributePageSwitchTabActionGroup.xml index f3fcab490b3d9..cbef1b61fe44c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributePageSwitchTabActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributePageSwitchTabActionGroup.xml @@ -16,6 +16,6 @@ <argument name="tabName" type="string"/> </arguments> - <click selector="#product_attribute_tabs a[title='{{tabName}}']" stepKey="changeProductAttributeActiveTab"/> + <click selector="{{AdminEditProductAttributesSection.tabButton(tabName)}}" stepKey="changeProductAttributeActiveTab"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnManageLabelsTabActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnManageLabelsTabActionGroup.xml index a4fb1e4a4a007..370d30003baf8 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnManageLabelsTabActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnManageLabelsTabActionGroup.xml @@ -14,11 +14,9 @@ </annotations> <arguments> - <argument name="selector" type="string" defaultValue="#attribute-labels-table .mage-error"/> <argument name="message" type="string"/> </arguments> - <seeElement selector="{{selector}}" stepKey="seeValidationDomElement"/> - <see userInput="{{message}}" selector="{{selector}}" stepKey="seeValidationMessage"/> + <see userInput="{{message}}" selector="{{AdminProductAttributeManageLabelsSection.attributeStoreLabelValidationError}}" stepKey="seeValidationMessage"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnPropertiesTabActionGroup.xml similarity index 72% rename from app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml rename to app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnPropertiesTabActionGroup.xml index b612e49cd05b6..5e0da379bdccb 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertSeeProductAttributeValidationErrorOnPropertiesTabActionGroup.xml @@ -14,11 +14,9 @@ </annotations> <arguments> - <argument name="selector" type="string" defaultValue=".field-attribute_label .mage-error"/> <argument name="message" type="string"/> </arguments> - <seeElement selector="{{selector}}" stepKey="seeValidationDomElement"/> - <see userInput="{{message}}" selector="{{selector}}" stepKey="seeValidationMessage"/> + <see userInput="{{message}}" selector="{{AttributePropertiesSection.attributeLabelValidationError}}" stepKey="seeValidationMessage"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml index 0934e39dcb062..671133d560576 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml @@ -30,6 +30,7 @@ <element name="dropdownNthOptionAdmin" type="textarea" selector="tbody[data-role='options-container'] tr:nth-child({{var}}) td:nth-child(3) input" parameterized="true"/> <element name="dropdownNthOptionDefaultStoreView" type="textarea" selector="tbody[data-role='options-container'] tr:nth-child({{var}}) td:nth-child(4) input" parameterized="true"/> <element name="dropdownNthOptionDelete" type="button" selector="tbody[data-role='options-container'] tr:nth-child({{var}}) button[title='Delete']" parameterized="true"/> + <element name="attributeLabelValidationError" type="text" selector=".field-attribute_label .mage-error"/> </section> <section name="AttributeDeleteModalSection"> <element name="confirm" type="button" selector=".modal-popup.confirm .action-accept"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminEditProductAttributesSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminEditProductAttributesSection.xml index b243fbfd6034a..ad4ab57f8de2c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminEditProductAttributesSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminEditProductAttributesSection.xml @@ -22,5 +22,6 @@ <element name="ProductDataMayBeLostConfirmButton" type="button" selector="//aside[contains(@class,'_show')]//button[.='Change Input Type']"/> <element name="defaultLabel" type="text" selector="//td[contains(text(), '{{attributeName}}')]/following-sibling::td[contains(@class, 'col-frontend_label')]" parameterized="true"/> <element name="formByStoreId" type="block" selector="//form[contains(@action,'store/{{store_id}}')]" parameterized="true"/> + <element name="tabButton" type="text" selector="#product_attribute_tabs a[title='{{tabName}}']" parameterized="true"/> </section> </sections> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml index c5e91854468e2..e1863576b8ecf 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeManageLabelsSection.xml @@ -10,5 +10,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminProductAttributeManageLabelsSection"> <element name="DefaultStoreLabel" type="input" selector="#attribute-labels-table [name='frontend_label[1]']"/> + <element name="attributeStoreLabelValidationError" type="text" selector="#attribute-labels-table .mage-error"/> </section> </sections>
escapeHtml($_store->getName()) ?>
- getId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID; ?> + + getReadOnly()) :?> + getReadOnly()): ?> disabled="disabled" />