Skip to content

Commit 7806da7

Browse files
committed
ACQE:8577: Validate price changes for configurable product with dropdown and text swatch attributes displayed in widget
- Removed ag to delete products used helper class and used api to create attributes
1 parent 99c4882 commit 7806da7

File tree

3 files changed

+113
-67
lines changed

3 files changed

+113
-67
lines changed

app/code/Magento/Catalog/Test/Mftf/Data/FrontendLabelData.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@
2424
<data key="store_id">0</data>
2525
<data key="label">attributeExportImport</data>
2626
</entity>
27+
<entity name="DropdownSizeFrontendLabel" type="FrontendLabel">
28+
<data key="store_id">0</data>
29+
<data key="label">my size</data>
30+
</entity>
31+
<entity name="TextSwatchColorFrontendLabel" type="FrontendLabel">
32+
<data key="store_id">0</data>
33+
<data key="label">color1</data>
34+
</entity>
2735
</entities>

app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -493,38 +493,90 @@
493493
<data key="option3">3</data>
494494
</entity>
495495
<!-- Dropdown Size Attribute -->
496-
<entity name="DropdownSizeAttributeData" type="attribute">
497-
<data key="frontend_label">my size</data>
496+
<entity name="DropdownSizeAttributeData" type="ProductAttribute">
498497
<data key="attribute_code">my_size</data>
499498
<data key="attribute_type">Dropdown</data>
500-
<data key="scope">Global</data>
499+
<data key="frontend_input">select</data>
500+
<data key="scope">global</data>
501+
<data key="is_required">false</data>
502+
<data key="is_unique">false</data>
503+
<data key="is_searchable">true</data>
504+
<data key="is_visible">true</data>
505+
<data key="is_visible_in_advanced_search">true</data>
506+
<data key="is_visible_on_front">true</data>
507+
<data key="is_filterable">true</data>
508+
<data key="is_filterable_in_search">true</data>
509+
<data key="used_in_product_listing">true</data>
510+
<data key="is_used_for_promo_rules">true</data>
511+
<data key="is_comparable">true</data>
512+
<data key="is_used_in_grid">true</data>
513+
<data key="is_visible_in_grid">true</data>
514+
<data key="is_filterable_in_grid">true</data>
515+
<data key="used_for_sort_by">true</data>
516+
<requiredEntity type="FrontendLabel">DropdownSizeFrontendLabel</requiredEntity>
501517
</entity>
502518
<!-- Text Swatch Color Attribute -->
503-
<entity name="TextSwatchColorAttributeData" type="attribute">
504-
<data key="frontend_label">color1</data>
519+
<entity name="TextSwatchColorAttributeData" type="ProductAttribute">
505520
<data key="attribute_code">color_swatch</data>
506521
<data key="attribute_type">swatch_text</data>
507-
<data key="scope">Global</data>
522+
<data key="frontend_input">swatch_text</data>
523+
<data key="scope">global</data>
524+
<data key="is_required">false</data>
525+
<data key="is_unique">false</data>
526+
<data key="is_searchable">true</data>
527+
<data key="is_visible">true</data>
528+
<data key="is_visible_in_advanced_search">true</data>
529+
<data key="is_visible_on_front">true</data>
530+
<data key="is_filterable">true</data>
531+
<data key="is_filterable_in_search">true</data>
532+
<data key="used_in_product_listing">true</data>
533+
<data key="is_used_for_promo_rules">true</data>
534+
<data key="is_comparable">true</data>
535+
<data key="is_used_in_grid">true</data>
536+
<data key="is_visible_in_grid">true</data>
537+
<data key="is_filterable_in_grid">true</data>
538+
<data key="used_for_sort_by">true</data>
539+
<requiredEntity type="FrontendLabel">TextSwatchColorFrontendLabel</requiredEntity>
508540
</entity>
509541
<!-- Size Options -->
510542
<entity name="AttributeOptionSmall" type="option">
511543
<data key="value">Small</data>
512544
</entity>
513-
<entity name="AttributeOptionMedium" type="option">
514-
<data key="value">Medium</data>
515-
</entity>
516545
<entity name="AttributeOptionLarge" type="option">
517546
<data key="value">Large</data>
518547
</entity>
548+
<!-- Size Product Attribute Options for API -->
549+
<entity name="DropdownSizeOptionSmall" type="ProductAttributeOption">
550+
<var key="attribute_code" entityKey="attribute_code" entityType="ProductAttribute"/>
551+
<data key="label">Small</data>
552+
<data key="is_default">false</data>
553+
<data key="sort_order">0</data>
554+
</entity>
555+
<entity name="DropdownSizeOptionLarge" type="ProductAttributeOption">
556+
<var key="attribute_code" entityKey="attribute_code" entityType="ProductAttribute"/>
557+
<data key="label">Large</data>
558+
<data key="is_default">false</data>
559+
<data key="sort_order">1</data>
560+
</entity>
519561
<!-- Color Options -->
520562
<entity name="AttributeOptionBlack" type="option">
521563
<data key="value">Black</data>
522564
</entity>
523565
<entity name="AttributeOptionWhite" type="option">
524566
<data key="value">White</data>
525567
</entity>
526-
<entity name="AttributeOptionBlue" type="option">
527-
<data key="value">Blue</data>
568+
<!-- Color Product Attribute Options for API -->
569+
<entity name="TextSwatchOptionBlack" type="ProductAttributeOption">
570+
<var key="attribute_code" entityKey="attribute_code" entityType="ProductAttribute"/>
571+
<data key="label">Black</data>
572+
<data key="is_default">false</data>
573+
<data key="sort_order">0</data>
574+
</entity>
575+
<entity name="TextSwatchOptionWhite" type="ProductAttributeOption">
576+
<var key="attribute_code" entityKey="attribute_code" entityType="ProductAttribute"/>
577+
<data key="label">White</data>
578+
<data key="is_default">false</data>
579+
<data key="sort_order">1</data>
528580
</entity>
529581
<!-- Attribute Display Values for product configuration -->
530582
<entity name="SizeAttributeDisplay" type="display">
@@ -535,5 +587,15 @@
535587
<data key="small_white">my size: Small, color1: White</data>
536588
<data key="large_white">my size: Large, color1: White</data>
537589
</entity>
590+
<entity name="ConfigurableProduct1" type="product">
591+
<data key="name">Conf 1</data>
592+
<data key="sku">conf-1</data>
593+
<data key="price">100</data>
594+
</entity>
595+
<entity name="ConfigurableProduct2" type="product">
596+
<data key="name">Conf 2</data>
597+
<data key="sku">conf-2</data>
598+
<data key="price">200</data>
599+
</entity>
538600
</entities>
539601

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontValidatePriceChangesForConfigurableProductWithMultipleAttributesInWidgetTest.xml

Lines changed: 32 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -16,79 +16,55 @@
1616
<testCaseId value="AC-8423"/>
1717
<severity value="MAJOR"/>
1818
<group value="Catalog"/>
19-
<group value="ConfigurableProduct"/>
2019
</annotations>
2120
<before>
2221
<!-- Step-1: Login to admin -->
2322
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
2423
<!-- Create category for products -->
2524
<createData entity="_defaultCategory" stepKey="createCategory"/>
26-
<!-- Step-2: Create a dropdown product attribute with three options -->
27-
<actionGroup ref="AdminNavigateToNewProductAttributePageActionGroup" stepKey="goToNewProductAttributePage"/>
28-
<actionGroup ref="AdminFillProductAttributePropertiesActionGroup" stepKey="fillAttributeProperties">
29-
<argument name="attributeName" value="{{DropdownSizeAttributeData.frontend_label}}"/>
30-
<argument name="attributeType" value="{{DropdownSizeAttributeData.attribute_type}}"/>
31-
</actionGroup>
32-
<click selector="{{AttributePropertiesSection.AdvancedProperties}}" stepKey="clickAdvancedProperties"/>
33-
<fillField selector="{{AttributePropertiesSection.AttributeCode}}" userInput="{{DropdownSizeAttributeData.attribute_code}}" stepKey="fillAttributeCode"/>
34-
<selectOption selector="{{AttributePropertiesSection.Scope}}" userInput="{{DropdownSizeAttributeData.scope}}" stepKey="selectGlobalScope"/>
35-
<click selector="{{AttributePropertiesSection.dropdownAddOptions}}" stepKey="clickAddOption1"/>
36-
<fillField selector="{{AttributePropertiesSection.dropdownNthOptionAdmin('1')}}" userInput="{{AttributeOptionSmall.value}}" stepKey="fillOption1Admin"/>
37-
<click selector="{{AttributePropertiesSection.dropdownAddOptions}}" stepKey="clickAddOption2"/>
38-
<fillField selector="{{AttributePropertiesSection.dropdownNthOptionAdmin('2')}}" userInput="{{AttributeOptionMedium.value}}" stepKey="fillOption2Admin"/>
39-
<click selector="{{AttributePropertiesSection.dropdownAddOptions}}" stepKey="clickAddOption3"/>
40-
<fillField selector="{{AttributePropertiesSection.dropdownNthOptionAdmin('3')}}" userInput="{{AttributeOptionLarge.value}}" stepKey="fillOption3Admin"/>
41-
<actionGroup ref="AdminProductAttributeSaveActionGroup" stepKey="saveDropdownAttribute"/>
42-
<!-- Step-3: Create a text swatch product attribute with three options -->
43-
<actionGroup ref="AdminNavigateToNewProductAttributePageActionGroup" stepKey="goToNewProductAttributePageForSwatch"/>
44-
<actionGroup ref="AdminFillProductAttributePropertiesActionGroup" stepKey="fillSwatchAttributeProperties">
45-
<argument name="attributeName" value="{{TextSwatchColorAttributeData.frontend_label}}"/>
46-
<argument name="attributeType" value="{{TextSwatchColorAttributeData.attribute_type}}"/>
47-
</actionGroup>
48-
<click selector="{{AttributePropertiesSection.AdvancedProperties}}" stepKey="clickAdvancedPropertiesForSwatch"/>
49-
<fillField selector="{{AttributePropertiesSection.AttributeCode}}" userInput="{{TextSwatchColorAttributeData.attribute_code}}" stepKey="fillSwatchAttributeCode"/>
50-
<selectOption selector="{{AttributePropertiesSection.Scope}}" userInput="{{TextSwatchColorAttributeData.scope}}" stepKey="selectGlobalScopeForSwatch"/>
51-
<click selector="{{AdminManageSwatchSection.addSwatchText}}" stepKey="clickAddSwatchOption1"/>
52-
<fillField selector="{{AdminManageSwatchSection.swatchTextByIndex('0')}}" userInput="{{AttributeOptionBlack.value}}" stepKey="fillSwatchOption1"/>
53-
<fillField selector="{{AdminManageSwatchSection.swatchAdminDescriptionByIndex('0')}}" userInput="{{AttributeOptionBlack.value}}" stepKey="fillSwatchOption1Description"/>
54-
<click selector="{{AdminManageSwatchSection.addSwatchText}}" stepKey="clickAddSwatchOption2"/>
55-
<fillField selector="{{AdminManageSwatchSection.swatchTextByIndex('1')}}" userInput="{{AttributeOptionWhite.value}}" stepKey="fillSwatchOption2"/>
56-
<fillField selector="{{AdminManageSwatchSection.swatchAdminDescriptionByIndex('1')}}" userInput="{{AttributeOptionWhite.value}}" stepKey="fillSwatchOption2Description"/>
57-
<click selector="{{AdminManageSwatchSection.addSwatchText}}" stepKey="clickAddSwatchOption3"/>
58-
<fillField selector="{{AdminManageSwatchSection.swatchTextByIndex('2')}}" userInput="{{AttributeOptionBlue.value}}" stepKey="fillSwatchOption3"/>
59-
<fillField selector="{{AdminManageSwatchSection.swatchAdminDescriptionByIndex('2')}}" userInput="{{AttributeOptionBlue.value}}" stepKey="fillSwatchOption3Description"/>
60-
<actionGroup ref="AdminProductAttributeSaveActionGroup" stepKey="saveTextSwatchAttribute"/>
61-
<!-- Create configurable products via API -->
25+
<!-- Step-2: Create a dropdown product attribute with two options -->
26+
<createData entity="DropdownSizeAttributeData" stepKey="createDropdownAttribute"/>
27+
<createData entity="DropdownSizeOptionSmall" stepKey="createAttributeOptionSmall">
28+
<requiredEntity createDataKey="createDropdownAttribute"/>
29+
</createData>
30+
<createData entity="DropdownSizeOptionLarge" stepKey="createAttributeOptionLarge">
31+
<requiredEntity createDataKey="createDropdownAttribute"/>
32+
</createData>
33+
<!-- Step-3: Create a text swatch product attribute with two options -->
34+
<createData entity="TextSwatchColorAttributeData" stepKey="createTextSwatchAttribute"/>
35+
<createData entity="TextSwatchOptionBlack" stepKey="createAttributeOptionBlack">
36+
<requiredEntity createDataKey="createTextSwatchAttribute"/>
37+
</createData>
38+
<createData entity="TextSwatchOptionWhite" stepKey="createAttributeOptionWhite">
39+
<requiredEntity createDataKey="createTextSwatchAttribute"/>
40+
</createData>
41+
<!-- Create configurable products -->
6242
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct1">
6343
<requiredEntity createDataKey="createCategory"/>
64-
<field key="name">Conf 1</field>
65-
<field key="sku">conf-1</field>
66-
<field key="price">100</field>
44+
<field key="name">{{ConfigurableProduct1.name}}</field>
45+
<field key="sku">{{ConfigurableProduct1.sku}}</field>
46+
<field key="price">{{ConfigurableProduct1.price}}</field>
6747
</createData>
6848
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct2">
6949
<requiredEntity createDataKey="createCategory"/>
70-
<field key="name">Conf 2</field>
71-
<field key="sku">conf-2</field>
72-
<field key="price">200</field>
50+
<field key="name">{{ConfigurableProduct2.name}}</field>
51+
<field key="sku">{{ConfigurableProduct2.sku}}</field>
52+
<field key="price">{{ConfigurableProduct2.price}}</field>
7353
</createData>
7454
</before>
7555
<after>
7656
<!-- Delete category -->
7757
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
78-
<!-- Delete created products -->
79-
<actionGroup ref="DeleteAllProductsUsingProductGridActionGroup" stepKey="deleteAllProducts"/>
58+
<!-- Delete configurable product & its variants via API using ProductApiHelper -->
59+
<helper class="Magento\Catalog\Test\Mftf\Helper\ProductApiHelper" method="deleteAllProductsApi" stepKey="deleteAllProductsViaApi"/>
8060
<!-- Delete widget -->
8161
<actionGroup ref="AdminDeleteWidgetActionGroup" stepKey="deleteWidget">
8262
<argument name="widget" value="SampleCatalogProductsListWidget"/>
8363
</actionGroup>
8464
<!-- Delete dropdown attribute -->
85-
<actionGroup ref="DeleteProductAttributeByCodeActionGroup" stepKey="deleteDropdownAttribute">
86-
<argument name="attribute_code" value="{{DropdownSizeAttributeData.attribute_code}}"/>
87-
</actionGroup>
65+
<deleteData createDataKey="createDropdownAttribute" stepKey="deleteDropdownAttribute"/>
8866
<!-- Delete text swatch attribute -->
89-
<actionGroup ref="DeleteProductAttributeByCodeActionGroup" stepKey="deleteSwatchAttribute">
90-
<argument name="attribute_code" value="{{TextSwatchColorAttributeData.attribute_code}}"/>
91-
</actionGroup>
67+
<deleteData createDataKey="createTextSwatchAttribute" stepKey="deleteSwatchAttribute"/>
9268
<!-- Logout -->
9369
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
9470
</after>
@@ -99,7 +75,7 @@
9975
<waitForPageLoad stepKey="waitForConfigProduct1PageLoad"/>
10076
<!-- Create configurations for Conf 1 with my_size attribute -->
10177
<actionGroup ref="GenerateConfigurationsByAttributeCodeActionGroup" stepKey="createConfigurationsForConf1">
102-
<argument name="attributeCode" value="{{DropdownSizeAttributeData.attribute_code}}"/>
78+
<argument name="attributeCode" value="$createDropdownAttribute.attribute_code$"/>
10379
</actionGroup>
10480
<!-- Set custom prices for Small and Large variants -->
10581
<actionGroup ref="ChangeConfigurableProductChildProductPriceActionGroup" stepKey="changePriceForSmall">
@@ -121,8 +97,8 @@
12197
<click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}" stepKey="clickCreateConfigurationsForConf2"/>
12298
<waitForElementVisible selector="{{AdminCreateProductConfigurationsPanel.createNewAttribute}}" stepKey="waitForConfigurationModalOpen"/>
12399
<!-- Select both my_size and color_swatch attributes -->
124-
<click selector="{{AdminCreateProductConfigurationsPanel.attributeCheckbox(DropdownSizeAttributeData.attribute_code)}}" stepKey="selectSizeAttribute"/>
125-
<click selector="{{AdminCreateProductConfigurationsPanel.attributeCheckbox(TextSwatchColorAttributeData.attribute_code)}}" stepKey="selectColorAttribute"/>
100+
<click selector="{{AdminCreateProductConfigurationsPanel.attributeCheckbox($createDropdownAttribute.attribute_code$)}}" stepKey="selectSizeAttribute"/>
101+
<click selector="{{AdminCreateProductConfigurationsPanel.attributeCheckbox($createTextSwatchAttribute.attribute_code$)}}" stepKey="selectColorAttribute"/>
126102
<click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton1ForConf2"/>
127103
<!-- Select only Small and Large for my_size, and Black and White for color_swatch -->
128104
<waitForElementVisible selector="{{AdminCreateProductConfigurationsPanel.attributeCheckboxByName(AttributeOptionSmall.value)}}" stepKey="waitForOptionsForConf2"/>
@@ -164,10 +140,10 @@
164140
<actionGroup ref="AdminSaveAndContinueWidgetActionGroup" stepKey="saveWidget"/>
165141
<!-- Step-7: Open Conf 1 product page on storefront and validate price changes -->
166142
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openConf1ProductPage">
167-
<argument name="productUrl" value="conf-1"/>
143+
<argument name="productUrl" value="{{ConfigurableProduct1.sku}}"/>
168144
</actionGroup>
169145
<waitForElementVisible selector="{{StorefrontProductInfoMainSection.productName}}" stepKey="waitForProductName"/>
170-
<waitForText selector="{{StorefrontProductInfoMainSection.productName}}" userInput="Conf 1" stepKey="verifyProductName"/>
146+
<waitForText selector="{{StorefrontProductInfoMainSection.productName}}" userInput="{{ConfigurableProduct1.name}}" stepKey="verifyProductName"/>
171147
<!-- Verify default price before selection -->
172148
<waitForElementVisible selector="{{StorefrontProductInfoMainSection.productPrice}}" stepKey="waitForDefaultPrice"/>
173149
<!-- Select Small option and verify price -->

0 commit comments

Comments
 (0)