Skip to content

Commit 6515fc5

Browse files
committed
ACQE-8489: Verify values required setting for text and visual swatch.
- New test case added.
1 parent a3b1abc commit 6515fc5

File tree

2 files changed

+191
-0
lines changed

2 files changed

+191
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AddVisualSwatchNoDefaultActionGroup" extends="AddVisualSwatchActionGroup">
12+
<annotations>
13+
<description>Add visual image swatch property attribute without selecting any default option.</description>
14+
</annotations>
15+
<!-- Do not mark any option as default -->
16+
<remove keyForRemoval="scrollToManageSwatchSection"/>
17+
<remove keyForRemoval="waitForSetSecondOptionAsDefault"/>
18+
<remove keyForRemoval="setSecondOptionAsDefault"/>
19+
</actionGroup>
20+
</actionGroups>
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminSwatchValuesRequiredBehaviorTest">
12+
<annotations>
13+
<features value="Swatches"/>
14+
<stories value="Values required behavior for text and visual swatch attributes"/>
15+
<title value="Values required setting for text and visual Swatch"/>
16+
<description value="Set both text and visual swatch attributes as required, verify product form enforces both; then set both optional and verify save succeeds without selections."/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="AC-5526"/>
19+
<group value="swatches"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
<!-- Step 1: Create a text swatch attribute with two options -->
24+
<actionGroup ref="AddTextSwatchToProductWithTwoOptionsActionGroup" stepKey="createTextSwatch">
25+
<argument name="attributeName" value="{{textSwatchAttribute.default_label}}"/>
26+
<argument name="attributeCode" value="{{textSwatchAttribute.attribute_code}}"/>
27+
<argument name="option1" value="textSwatchOption1"/>
28+
<argument name="option2" value="textSwatchOption2"/>
29+
<argument name="usedInProductListing" value="No"/>
30+
</actionGroup>
31+
<!-- Step 2: Create a visual swatch attribute with two image options -->
32+
<actionGroup ref="AddVisualSwatchNoDefaultActionGroup" stepKey="createVisualSwatch"/>
33+
<!-- Assign both attributes to default attribute Set -->
34+
<actionGroup ref="AdminOpenAttributeSetGridPageActionGroup" stepKey="openAttributeSetPage"/>
35+
<actionGroup ref="AdminOpenAttributeSetByNameActionGroup" stepKey="openDefaultAttributeSet"/>
36+
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignTextSwatchToGroup">
37+
<argument name="group" value="Product Details"/>
38+
<argument name="attribute" value="{{textSwatchAttribute.attribute_code}}"/>
39+
</actionGroup>
40+
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="saveAttributeSet"/>
41+
<actionGroup ref="AdminOpenAttributeSetGridPageActionGroup" stepKey="openAttributeSetPage2"/>
42+
<actionGroup ref="AdminOpenAttributeSetByNameActionGroup" stepKey="openDefaultAttributeSet2"/>
43+
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignVisualSwatchToGroup">
44+
<argument name="group" value="Product Details"/>
45+
<argument name="attribute" value="{{ProductAttributeFrontendLabel.label}}"/>
46+
</actionGroup>
47+
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="saveAttributeSet2"/>
48+
</before>
49+
<after>
50+
<!-- Cleanup attributes -->
51+
<actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openTextSwatchForDelete">
52+
<argument name="productAttributeCode" value="{{textSwatchAttribute.attribute_code}}"/>
53+
</actionGroup>
54+
<actionGroup ref="DeleteProductAttributeByAttributeCodeActionGroup" stepKey="deleteTextSwatch">
55+
<argument name="productAttributeCode" value="{{textSwatchAttribute.attribute_code}}"/>
56+
</actionGroup>
57+
<actionGroup ref="AssertProductAttributeRemovedSuccessfullyActionGroup" stepKey="assertTextSwatchDeleted"/>
58+
<actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openVisualSwatchForDelete">
59+
<argument name="productAttributeCode" value="{{ProductAttributeFrontendLabel.label}}"/>
60+
</actionGroup>
61+
<actionGroup ref="DeleteProductAttributeByAttributeCodeActionGroup" stepKey="deleteVisualSwatch">
62+
<argument name="productAttributeCode" value="{{ProductAttributeFrontendLabel.label}}"/>
63+
</actionGroup>
64+
<actionGroup ref="AssertProductAttributeRemovedSuccessfullyActionGroup" stepKey="assertVisualSwatchDeleted"/>
65+
<!-- Cleanup products -->
66+
<actionGroup ref="AdminProductCatalogPageOpenActionGroup" stepKey="openCatalog"/>
67+
<actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteSuccessProductBySku">
68+
<argument name="sku" value="SwatchSuccSKU"/>
69+
</actionGroup>
70+
<actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteOptionalProductBySku">
71+
<argument name="sku" value="SwatchOptSKU"/>
72+
</actionGroup>
73+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAdmin"/>
74+
</after>
75+
<!-- Step 2: Set both swatch attributes to required (yes) -->
76+
<actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openTextSwatchForEdit">
77+
<argument name="productAttributeCode" value="{{textSwatchAttribute.attribute_code}}"/>
78+
</actionGroup>
79+
<selectOption selector="{{AttributePropertiesSection.ValueRequired}}" userInput="Yes" stepKey="setTextSwatchRequiredYes"/>
80+
<waitForElementClickable selector="{{AttributePropertiesSection.Save}}" stepKey="waitToSaveTextSwatchAttributeYes"/>
81+
<click selector="{{AttributePropertiesSection.Save}}" stepKey="saveTextSwatchAttributeYes"/>
82+
<waitForPageLoad stepKey="waitAfterSaveTextSwatchYes"/>
83+
<actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openVisualSwatchForEdit">
84+
<argument name="productAttributeCode" value="{{ProductAttributeFrontendLabel.label}}"/>
85+
</actionGroup>
86+
<selectOption selector="{{AttributePropertiesSection.ValueRequired}}" userInput="Yes" stepKey="setVisualSwatchRequiredYes"/>
87+
<waitForElementClickable selector="{{AttributePropertiesSection.Save}}" stepKey="waitToSaveVisualSwatchAttributeYes"/>
88+
<click selector="{{AttributePropertiesSection.Save}}" stepKey="saveVisualSwatchAttributeYes"/>
89+
<waitForPageLoad stepKey="waitAfterSaveVisualSwatchYes"/>
90+
<!-- Step 3: Make sure a user is obliged to enter values during creation of the Product based on the attributes. -->
91+
<!-- Save with neither swatch selected → expect required error -->
92+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goProductIndexRequired"/>
93+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goCreateProductRequired">
94+
<argument name="product" value="SimpleProduct"/>
95+
</actionGroup>
96+
<actionGroup ref="FillMainProductFormNoWeightActionGroup" stepKey="fillMainFormRequired">
97+
<argument name="product" value="SimpleProduct"/>
98+
</actionGroup>
99+
<fillField selector="{{AdminProductFormSection.productName}}" userInput="SwatchReqProd" stepKey="updateName"/>
100+
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="SwatchReqSKU" stepKey="updateSku"/>
101+
<actionGroup ref="AdminProductFormSaveButtonClickActionGroup" stepKey="saveWithoutAnySwatch"/>
102+
<waitForElementVisible selector="{{AdminProductFormSection.attributeFieldError}}" stepKey="seeRequiredErrorBothMissing"/>
103+
<!-- Select only visual swatch → expect required error (text missing) -->
104+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goProductIndexRequiredBeforeVisual"/>
105+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goCreateProductRequiredBeforeVisual">
106+
<argument name="product" value="SimpleProduct"/>
107+
</actionGroup>
108+
<actionGroup ref="FillMainProductFormNoWeightActionGroup" stepKey="fillMainFormRequiredBeforeVisual">
109+
<argument name="product" value="SimpleProduct"/>
110+
</actionGroup>
111+
<selectOption selector="{{AdminProductFormSection.attributeRequiredInputField(ProductAttributeFrontendLabel.label)}}"
112+
userInput="visualSwatchOption2" stepKey="selectOnlyVisualSwatch"/>
113+
<actionGroup ref="AdminProductFormSaveButtonClickActionGroup" stepKey="saveWithOnlyVisual"/>
114+
<waitForElementVisible selector="{{AdminProductFormSection.attributeFieldError}}" stepKey="seeRequiredErrorTextMissing"/>
115+
<!-- Select only text swatch → expect required error (visual missing) -->
116+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goProductIndexRequiredBeforeText"/>
117+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goCreateProductRequiredBeforeText">
118+
<argument name="product" value="SimpleProduct"/>
119+
</actionGroup>
120+
<actionGroup ref="FillMainProductFormNoWeightActionGroup" stepKey="fillMainFormRequiredBeforeText">
121+
<argument name="product" value="SimpleProduct"/>
122+
</actionGroup>
123+
<selectOption selector="{{AdminProductFormSection.attributeRequiredInputField(textSwatchAttribute.attribute_code)}}"
124+
userInput="textSwatchOption1" stepKey="selectOnlyTextSwatch"/>
125+
<actionGroup ref="AdminProductFormSaveButtonClickActionGroup" stepKey="saveWithOnlyText"/>
126+
<waitForElementVisible selector="{{AdminProductFormSection.attributeFieldError}}" stepKey="seeRequiredErrorVisualMissing"/>
127+
<!-- Select both swatches → expect success -->
128+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goProductIndexBeforeSuccess"/>
129+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goCreateProductBeforeSuccess">
130+
<argument name="product" value="SimpleProduct"/>
131+
</actionGroup>
132+
<actionGroup ref="FillMainProductFormNoWeightActionGroup" stepKey="fillMainFormBeforeSuccess">
133+
<argument name="product" value="SimpleProduct"/>
134+
</actionGroup>
135+
<fillField selector="{{AdminProductFormSection.productName}}" userInput="SwatchSuccProd" stepKey="updateNameValue"/>
136+
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="SwatchSuccSKU" stepKey="updateSkuValue"/>
137+
<selectOption selector="{{AdminProductFormSection.attributeRequiredInputField(textSwatchAttribute.attribute_code)}}"
138+
userInput="textSwatchOption1" stepKey="selectTextSwatchForSuccess"/>
139+
<selectOption selector="{{AdminProductFormSection.attributeRequiredInputField(ProductAttributeFrontendLabel.label)}}"
140+
userInput="visualSwatchOption2" stepKey="selectVisualSwatchForSuccess"/>
141+
<actionGroup ref="AdminProductFormSaveButtonClickActionGroup" stepKey="saveWithBothSelected"/>
142+
<waitForElementVisible selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSavedProductBothRequired"/>
143+
<!-- Step 4: Set both swatch attributes to not required (no) -->
144+
<actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openTextSwatchToUnrequire">
145+
<argument name="productAttributeCode" value="{{textSwatchAttribute.attribute_code}}"/>
146+
</actionGroup>
147+
<selectOption selector="{{AttributePropertiesSection.ValueRequired}}" userInput="No" stepKey="setTextSwatchRequiredToNo"/>
148+
<waitForElementClickable selector="{{AttributePropertiesSection.Save}}" stepKey="waitToSaveTextSwatchAttributeToNo"/>
149+
<click selector="{{AttributePropertiesSection.Save}}" stepKey="saveTextSwatchAttributeToNo"/>
150+
<waitForPageLoad stepKey="waitAfterSaveTextSwatchToNo"/>
151+
<actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openVisualSwatchToUnrequire">
152+
<argument name="productAttributeCode" value="{{ProductAttributeFrontendLabel.label}}"/>
153+
</actionGroup>
154+
<selectOption selector="{{AttributePropertiesSection.ValueRequired}}" userInput="No" stepKey="setVisualSwatchRequiredToNo"/>
155+
<waitForElementClickable selector="{{AttributePropertiesSection.Save}}" stepKey="waitToSaveVisualSwatchAttributeToNo"/>
156+
<click selector="{{AttributePropertiesSection.Save}}" stepKey="saveVisualSwatchAttributeToNo"/>
157+
<waitForPageLoad stepKey="waitAfterSaveVisualSwatchToNo"/>
158+
<!-- Step 5: Leave both swatches empty and save: expect success -->
159+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goProductIndexOptional"/>
160+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goCreateProductOptional">
161+
<argument name="product" value="SimpleProduct"/>
162+
</actionGroup>
163+
<actionGroup ref="FillMainProductFormNoWeightActionGroup" stepKey="fillMainFormOptional">
164+
<argument name="product" value="SimpleProduct"/>
165+
</actionGroup>
166+
<fillField selector="{{AdminProductFormSection.productName}}" userInput="SwatchOptProd" stepKey="updateTheName"/>
167+
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="SwatchOptSKU" stepKey="updateTheSku"/>
168+
<actionGroup ref="AdminProductFormSaveButtonClickActionGroup" stepKey="saveNoSwatchesOptional"/>
169+
<waitForElementVisible selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSavedProductBothOptional"/>
170+
</test>
171+
</tests>

0 commit comments

Comments
 (0)