Skip to content

Commit

Permalink
Merge pull request #176 from magento-pangolin/MC-17552
Browse files Browse the repository at this point in the history
MC-17552 Backport for MC-13641
  • Loading branch information
RyanZolper authored Jun 21, 2019
2 parents 9947885 + 3ff8e76 commit 0043bee
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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">
<!-- Delete a product by filtering grid and using delete action-->
<actionGroup name="AdminDeleteProductBySkuActionGroup">
<arguments>
<argument name="sku" type="string"/>
</arguments>
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/>
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/>
<fillField selector="{{AdminProductGridFilterSection.skuFilter}}" userInput="{{sku}}" stepKey="fillProductSkuFilter"/>
<click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters"/>
<see selector="{{AdminProductGridSection.productGridCell('1', 'SKU')}}" userInput="{{sku}}" stepKey="seeProductSkuInGrid"/>
<click selector="{{AdminProductGridSection.multicheckDropdown}}" stepKey="openMulticheckDropdown"/>
<click selector="{{AdminProductGridSection.multicheckOption('Select All')}}" stepKey="selectAllProductInFilteredGrid"/>
<click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickActionDropdown"/>
<click selector="{{AdminProductGridSection.bulkActionOption('Delete')}}" stepKey="clickDeleteAction"/>
<waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForConfirmModal"/>
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmProductDelete"/>
<see selector="{{AdminMessagesSection.success}}" userInput="record(s) have been deleted." stepKey="seeSuccessMessage"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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="AdminGenerateProductConfigurationsByAttributeCodeActionGroup">
<arguments>
<argument name="attributeCode" type="string" defaultValue="SomeString"/>
</arguments>
<click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}" stepKey="clickCreateConfigurations"/>
<click selector="{{AdminCreateProductConfigurationsPanel.filters}}" stepKey="clickFilters"/>
<fillField selector="{{AdminCreateProductConfigurationsPanel.attributeCode}}" userInput="{{attributeCode}}" stepKey="fillFilterAttributeCodeField"/>
<click selector="{{AdminCreateProductConfigurationsPanel.applyFilters}}" stepKey="clickApplyFiltersButton"/>
<click selector="{{AdminCreateProductConfigurationsPanel.firstCheckbox}}" stepKey="clickOnFirstCheckbox"/>
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton1"/>
<click selector="{{AdminCreateProductConfigurationsPanel.selectAll}}" stepKey="clickOnSelectAll"/>
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton2"/>
<click selector="{{AdminCreateProductConfigurationsPanel.applySingleQuantityToEachSkus}}" stepKey="clickOnApplySingleQuantityToEachSku"/>
<fillField selector="{{AdminCreateProductConfigurationsPanel.quantity}}" userInput="99" stepKey="enterAttributeQuantity"/>
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton3"/>
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton4"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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="AdminOpenAttributeSetByNameActionGroup">
<arguments>
<argument name="attributeSetName" type="string" defaultValue="Default"/>
</arguments>
<click selector="{{AdminProductAttributeSetGridSection.attributeSetName(attributeSetName)}}" stepKey="chooseAttributeSet"/>
<waitForPageLoad stepKey="waitForAttributeSetPageLoad"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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="AdminOpenAttributeSetGridPageActionGroup">
<amOnPage url="{{AdminProductAttributeSetGridPage.url}}" stepKey="goToAttributeSetPage"/>
<waitForPageLoad stepKey="waitForAttributeSetPageLoad"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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="AdminOpenProductIndexPageActionGroup">
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="goToProductIndexPage"/>
<waitForPageLoad stepKey="waitForProductIndexPageLoad"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@
<argument name="attributeType" type="string" defaultValue="select"/>
</arguments>
<amOnPage url="{{AdminProductAttributeNewPage.url}}" stepKey="goToNewProductAttributePage"/>
<waitForPageLoad stepKey="waitForProductAttributeNewPageLoad"/>
<fillField selector="{{AttributePropertiesSection.defaultLabel}}" userInput="{{attributeCode}}" stepKey="fillDefaultLabel"/>
<selectOption selector="{{AttributePropertiesSection.inputType}}" userInput="{{attributeType}}" stepKey="selectInputType"/>
<waitForElementVisible selector="{{AdminNewAttributePanelSection.addOption}}" stepKey="waitForElementVisible"/>
</actionGroup>
<actionGroup name="AdminFillProductAttributePropertiesActionGroup" extends="StartCreateProductAttribute">
<remove keyForRemoval="waitForElementVisible"/>
</actionGroup>
<actionGroup name="AddOptionToProductAttribute">
<arguments>
<argument name="optionName" type="string"/>
Expand Down
21 changes: 21 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,25 @@
<entity name="ProductAttributeText" extends="productAttributeWithTwoOptions">
<data key="frontend_input">text</data>
</entity>
<entity name="productVisualSwatchAttribute" type="ProductAttribute">
<data key="attribute_code" unique="suffix">attribute</data>
<data key="frontend_input">swatch_visual</data>
<data key="scope">global</data>
<data key="is_required">false</data>
<data key="is_unique">false</data>
<data key="is_searchable">true</data>
<data key="is_visible">true</data>
<data key="is_visible_in_advanced_search">true</data>
<data key="is_visible_on_front">true</data>
<data key="is_filterable">true</data>
<data key="is_filterable_in_search">true</data>
<data key="used_in_product_listing">true</data>
<data key="is_used_for_promo_rules">true</data>
<data key="is_comparable">true</data>
<data key="is_used_in_grid">true</data>
<data key="is_visible_in_grid">true</data>
<data key="is_filterable_in_grid">true</data>
<data key="used_for_sort_by">true</data>
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminSaveConfigurableProductWithAttributesImagesAndSwatchesTest">
<annotations>
<features value="Catalog"/>
<stories value="Product attributes"/>
<title value="Saving configurable product with custom product attribute (images as swatches)"/>
<description value="Saving configurable product with custom product attribute (images as swatches)"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-17552"/>
<group value="catalog"/>
</annotations>
<before>
<!-- Login as admin -->
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
</before>
<after>
<!-- Admin logout -->
<actionGroup ref="logout" stepKey="adminLogout"/>
</after>

<!-- Create a new product attribute: set Catalog Input Type for Store Owner: Visual Swatch -->
<actionGroup ref="AdminFillProductAttributePropertiesActionGroup" stepKey="fillAttributeProperties">
<argument name="attributeCode" value="{{productVisualSwatchAttribute.attribute_code}}"/>
<argument name="attributeType" value="{{productVisualSwatchAttribute.frontend_input}}"/>
</actionGroup>

<!-- Add a few Swatches and add images to Manage Swatch (Values of Your Attribute)
1. Set swatch #1 using the color picker -->
<click selector="{{AdminManageSwatchSection.addSwatch}}" stepKey="clickAddFirstSwatch"/>
<actionGroup ref="openSwatchMenuByIndex" stepKey="clickFirstSwatch">
<argument name="index" value="0"/>
</actionGroup>
<click selector="{{AdminManageSwatchSection.chooseColorRow('1')}}" stepKey="clickChooseFirstColor"/>
<actionGroup ref="setColorPickerValueByHex" stepKey="fillFirstHex">
<argument name="nthColorPicker" value="1"/>
<argument name="hexColor" value="e74c3c"/>
</actionGroup>
<fillField selector="{{AdminManageSwatchSection.adminInputByIndex('0')}}" userInput="red" stepKey="fillFirstAdminField"/>

<!-- 2. Set swatch #2 using the color picker -->
<click selector="{{AdminManageSwatchSection.addSwatch}}" stepKey="clickAddSecondSwatch"/>
<actionGroup ref="openSwatchMenuByIndex" stepKey="clickSecondSwatch">
<argument name="index" value="1"/>
</actionGroup>
<click selector="{{AdminManageSwatchSection.chooseColorRow('2')}}" stepKey="clickChooseSecondColor"/>
<actionGroup ref="setColorPickerValueByHex" stepKey="fillSecondHex">
<argument name="nthColorPicker" value="2"/>
<argument name="hexColor" value="3498db"/>
</actionGroup>
<fillField selector="{{AdminManageSwatchSection.adminInputByIndex('1')}}" userInput="blue" stepKey="fillSecondAdminField"/>

<!-- Set Scope: Global in Advanced Attribute Properties -->
<click selector="{{AttributePropertiesSection.AdvancedProperties}}" stepKey="expandAdvancedProperties"/>
<selectOption selector="{{AttributePropertiesSection.scope}}" userInput="1" stepKey="selectGlobalScope"/>

<!-- Click "Save Attribute" button -->
<click selector="{{AttributePropertiesSection.saveAndEdit}}" stepKey="clickSaveAndEdit"/>
<waitForElementVisible selector="{{AdminProductMessagesSection.successMessage}}" stepKey="waitForSuccessMessage"/>

<!-- Add created product attribute to the Default set -->
<actionGroup ref="AdminOpenAttributeSetGridPageActionGroup" stepKey="openAttributeSetPage"/>
<actionGroup ref="AdminOpenAttributeSetByNameActionGroup" stepKey="openDefaultAttributeSet"/>
<actionGroup ref="AssignAttributeToGroup" stepKey="assignAttributeToGroup">
<argument name="group" value="Product Details"/>
<argument name="attribute" value="productVisualSwatchAttribute.attribute_code"/>
</actionGroup>
<actionGroup ref="SaveAttributeSet" stepKey="saveAttributeSet"/>

<!-- Create configurable product -->
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="openOpenProductIndexPage"/>
<actionGroup ref="goToCreateProductPage" stepKey="goToCreateConfigurableProduct">
<argument name="product" value="BaseConfigurableProduct"/>
</actionGroup>

<!-- Select Attribute Set -->
<actionGroup ref="AssignProductToAttributeSet" stepKey="selectAttributeSet">
<argument name="attributeSetName" value="Default"/>
</actionGroup>

<!-- Fill all the necessary information such as weight, name, SKU etc -->
<actionGroup ref="fillMainProductForm" stepKey="fillProductForm">
<argument name="product" value="BaseConfigurableProduct"/>
</actionGroup>

<!-- Click "Create Configurations" button, select created product attribute using the same Quantity for all products. Click "Generate products" button -->
<actionGroup ref="AdminGenerateProductConfigurationsByAttributeCodeActionGroup" stepKey="addAttributeToProduct">
<argument name="attributeCode" value="{{productVisualSwatchAttribute.attribute_code}}"/>
</actionGroup>

<!-- Using this action to concatenate 2 strings to have unique identifier for grid -->
<executeJS function="return '{{productVisualSwatchAttribute.attribute_code}}: red'" stepKey="attributeCodeRed"/>
<executeJS function="return '{{productVisualSwatchAttribute.attribute_code}}: blue'" stepKey="attributeCodeBlue"/>

<!-- Add images for the products -->
<attachFile selector="{{AdminDataGridTableSection.rowTemplate({$attributeCodeRed})}}{{AdminProductFormConfigurationsSection.fileUploaderInput}}" userInput="{{MagentoLogo.file}}" stepKey="uploadImageForFirstProduct"/>
<attachFile selector="{{AdminDataGridTableSection.rowTemplate({$attributeCodeBlue})}}{{AdminProductFormConfigurationsSection.fileUploaderInput}}" userInput="{{ProductImage.file}}" stepKey="uploadImageForSecondProduct"/>

<!-- Click "Save" button -->
<actionGroup ref="saveProductForm" stepKey="clickSaveButton"/>

<!-- Delete all created product -->
<actionGroup ref="AdminDeleteProductBySkuActionGroup" stepKey="deleteCreatedProducts">
<argument name="sku" value="{{BaseConfigurableProduct.sku}}"/>
</actionGroup>

<!-- Delete product attribute -->
<actionGroup ref="deleteProductAttribute" stepKey="deleteProductAttribute">
<argument name="ProductAttribute" value="productVisualSwatchAttribute"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
<element name="skuValidationMessage" type="text" selector="input[name='configurable-matrix[{{index}}][sku]'] + label" parameterized="true"/>
<element name="stepsWizardTitle" type="text" selector="div.content:not([style='display: none;']) .steps-wizard-title"/>
<element name="attributeEntityByName" type="text" selector="//div[@class='attribute-entity']//div[normalize-space(.)='{{attributeLabel}}']" parameterized="true"/>
<element name="fileUploaderInput" type="file" selector="//input[@type='file' and @class='file-uploader-input']"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
<element name="rowEditAction" type="button" selector="[data-role='grid'] tbody tr .action-select-wrap._active [data-action='item-edit']" timeout="30"/>
<element name="dataGridEmpty" type="block" selector=".data-grid-tr-no-data td"/>
<element name="dataGridWrap" type="block" selector=".admin__data-grid-wrap"/>
<element name="rowTemplate" type="block" selector="//tbody/tr[td[*[contains(.,normalize-space('{{text}}'))]]]" parameterized="true" />
</section>
</sections>

0 comments on commit 0043bee

Please sign in to comment.