|
| 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="This test case verifies values required setting for text and visual swatch."/> |
| 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="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openVisualSwatchForDelete"> |
| 58 | + <argument name="productAttributeCode" value="{{ProductAttributeFrontendLabel.label}}"/> |
| 59 | + </actionGroup> |
| 60 | + <actionGroup ref="DeleteProductAttributeByAttributeCodeActionGroup" stepKey="deleteVisualSwatch"> |
| 61 | + <argument name="productAttributeCode" value="{{ProductAttributeFrontendLabel.label}}"/> |
| 62 | + </actionGroup> |
| 63 | + <!-- Cleanup products --> |
| 64 | + <actionGroup ref="AdminProductCatalogPageOpenActionGroup" stepKey="openCatalog"/> |
| 65 | + <actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteSuccessProductBySku"> |
| 66 | + <argument name="sku" value="{{SimpleProduct.sku}}"/> |
| 67 | + </actionGroup> |
| 68 | + <actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteOptionalProductBySku"> |
| 69 | + <argument name="sku" value="{{SimpleProduct3.sku}}"/> |
| 70 | + </actionGroup> |
| 71 | + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAdmin"/> |
| 72 | + </after> |
| 73 | + <!-- Step 2: Set both swatch attributes to required (yes) --> |
| 74 | + <actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openTextSwatchForEdit"> |
| 75 | + <argument name="productAttributeCode" value="{{textSwatchAttribute.attribute_code}}"/> |
| 76 | + </actionGroup> |
| 77 | + <selectOption selector="{{AttributePropertiesSection.ValueRequired}}" userInput="Yes" stepKey="setTextSwatchRequiredYes"/> |
| 78 | + <actionGroup ref="AdminProductAttributeSaveActionGroup" stepKey="saveTextSwatchAttributeYes"/> |
| 79 | + <actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openVisualSwatchForEdit"> |
| 80 | + <argument name="productAttributeCode" value="{{ProductAttributeFrontendLabel.label}}"/> |
| 81 | + </actionGroup> |
| 82 | + <selectOption selector="{{AttributePropertiesSection.ValueRequired}}" userInput="Yes" stepKey="setVisualSwatchRequiredYes"/> |
| 83 | + <actionGroup ref="AdminProductAttributeSaveActionGroup" stepKey="saveVisualSwatchAttributeYes"/> |
| 84 | + <!-- Step 3: Make sure a user is obliged to enter values during creation of the Product based on the attributes. --> |
| 85 | + <!-- Save with neither swatch selected → expect required error --> |
| 86 | + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goProductIndexRequired"/> |
| 87 | + <actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goCreateProductRequired"> |
| 88 | + <argument name="product" value="SimpleProduct"/> |
| 89 | + </actionGroup> |
| 90 | + <actionGroup ref="FillMainProductFormNoWeightActionGroup" stepKey="fillMainFormRequired"> |
| 91 | + <argument name="product" value="SimpleProduct"/> |
| 92 | + </actionGroup> |
| 93 | + <actionGroup ref="AdminProductFormSaveButtonClickActionGroup" stepKey="saveWithoutAnySwatch"/> |
| 94 | + <waitForElementVisible selector="{{AdminProductFormSection.attributeFieldError}}" stepKey="seeRequiredErrorBothMissing"/> |
| 95 | + <!-- Select only visual swatch → expect required error (text missing) --> |
| 96 | + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goProductIndexRequiredBeforeVisual"/> |
| 97 | + <actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goCreateProductRequiredBeforeVisual"> |
| 98 | + <argument name="product" value="SimpleProduct"/> |
| 99 | + </actionGroup> |
| 100 | + <actionGroup ref="FillMainProductFormNoWeightActionGroup" stepKey="fillMainFormRequiredBeforeVisual"> |
| 101 | + <argument name="product" value="SimpleProduct"/> |
| 102 | + </actionGroup> |
| 103 | + <selectOption selector="{{AdminProductFormSection.attributeRequiredInputField(ProductAttributeFrontendLabel.label)}}" userInput="visualSwatchOption2" stepKey="selectOnlyVisualSwatch"/> |
| 104 | + <actionGroup ref="AdminProductFormSaveButtonClickActionGroup" stepKey="saveWithOnlyVisual"/> |
| 105 | + <waitForElementVisible selector="{{AdminProductFormSection.attributeFieldError}}" stepKey="seeRequiredErrorTextMissing"/> |
| 106 | + <!-- Select only text swatch → expect required error (visual missing) --> |
| 107 | + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goProductIndexRequiredBeforeText"/> |
| 108 | + <actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goCreateProductRequiredBeforeText"> |
| 109 | + <argument name="product" value="SimpleProduct"/> |
| 110 | + </actionGroup> |
| 111 | + <actionGroup ref="FillMainProductFormNoWeightActionGroup" stepKey="fillMainFormRequiredBeforeText"> |
| 112 | + <argument name="product" value="SimpleProduct"/> |
| 113 | + </actionGroup> |
| 114 | + <selectOption selector="{{AdminProductFormSection.attributeRequiredInputField(textSwatchAttribute.attribute_code)}}" userInput="textSwatchOption1" stepKey="selectOnlyTextSwatch"/> |
| 115 | + <actionGroup ref="AdminProductFormSaveButtonClickActionGroup" stepKey="saveWithOnlyText"/> |
| 116 | + <waitForElementVisible selector="{{AdminProductFormSection.attributeFieldError}}" stepKey="seeRequiredErrorVisualMissing"/> |
| 117 | + <!-- Select both swatches → expect success --> |
| 118 | + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goProductIndexBeforeSuccess"/> |
| 119 | + <actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goCreateProductBeforeSuccess"> |
| 120 | + <argument name="product" value="SimpleProduct"/> |
| 121 | + </actionGroup> |
| 122 | + <actionGroup ref="FillMainProductFormNoWeightActionGroup" stepKey="fillMainFormBeforeSuccess"> |
| 123 | + <argument name="product" value="SimpleProduct"/> |
| 124 | + </actionGroup> |
| 125 | + <selectOption selector="{{AdminProductFormSection.attributeRequiredInputField(textSwatchAttribute.attribute_code)}}" userInput="textSwatchOption1" stepKey="selectTextSwatchForSuccess"/> |
| 126 | + <selectOption selector="{{AdminProductFormSection.attributeRequiredInputField(ProductAttributeFrontendLabel.label)}}" userInput="visualSwatchOption2" stepKey="selectVisualSwatchForSuccess"/> |
| 127 | + <actionGroup ref="AdminProductFormSaveButtonClickActionGroup" stepKey="saveWithBothSelected"/> |
| 128 | + <waitForElementVisible selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSavedProductBothRequired"/> |
| 129 | + <!-- Step 4: Set both swatch attributes to not required (no) --> |
| 130 | + <actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openTextSwatchToUnrequire"> |
| 131 | + <argument name="productAttributeCode" value="{{textSwatchAttribute.attribute_code}}"/> |
| 132 | + </actionGroup> |
| 133 | + <selectOption selector="{{AttributePropertiesSection.ValueRequired}}" userInput="No" stepKey="setTextSwatchRequiredToNo"/> |
| 134 | + <actionGroup ref="AdminProductAttributeSaveActionGroup" stepKey="saveTextSwatchAttributeToNo"/> |
| 135 | + <actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openVisualSwatchToUnrequire"> |
| 136 | + <argument name="productAttributeCode" value="{{ProductAttributeFrontendLabel.label}}"/> |
| 137 | + </actionGroup> |
| 138 | + <selectOption selector="{{AttributePropertiesSection.ValueRequired}}" userInput="No" stepKey="setVisualSwatchRequiredToNo"/> |
| 139 | + <actionGroup ref="AdminProductAttributeSaveActionGroup" stepKey="saveVisualSwatchAttributeToNo"/> |
| 140 | + <!-- Step 5: Leave both swatches empty and save: expect success --> |
| 141 | + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goProductIndexOptional"/> |
| 142 | + <actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goCreateProductOptional"> |
| 143 | + <argument name="product" value="SimpleProduct"/> |
| 144 | + </actionGroup> |
| 145 | + <actionGroup ref="FillMainProductFormNoWeightActionGroup" stepKey="fillMainFormOptional"> |
| 146 | + <argument name="product" value="SimpleProduct3"/> |
| 147 | + </actionGroup> |
| 148 | + <actionGroup ref="AdminProductFormSaveButtonClickActionGroup" stepKey="saveNoSwatchesOptional"/> |
| 149 | + <waitForElementVisible selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSavedProductBothOptional"/> |
| 150 | + </test> |
| 151 | +</tests> |
0 commit comments