|
| 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="StorefrontSimpleProductsDisplayedAfterSwatchFilteringTest"> |
| 12 | + <annotations> |
| 13 | + <features value="LayeredNavigation"/> |
| 14 | + <stories value="Simple products are displayed after search"/> |
| 15 | + <title value="Simple products are displayed after search with visual and text swatch filters"/> |
| 16 | + <description value="Creates visual and text swatch attributes, assigns values to products and verifies storefront filtering and visibility"/> |
| 17 | + <severity value="MAJOR"/> |
| 18 | + <testCaseId value="AC-4386"/> |
| 19 | + <group value="layeredNavigation"/> |
| 20 | + </annotations> |
| 21 | + <before> |
| 22 | + <!-- Create category, products and assign to category--> |
| 23 | + <createData entity="SimpleSubCategory" stepKey="createCategory"/> |
| 24 | + <createData entity="_defaultProduct" stepKey="createProduct1"> |
| 25 | + <requiredEntity createDataKey="createCategory"/> |
| 26 | + </createData> |
| 27 | + <createData entity="_defaultProduct" stepKey="createProduct2"> |
| 28 | + <requiredEntity createDataKey="createCategory" /> |
| 29 | + </createData> |
| 30 | + <!-- Step 1: Create visual swatch attribute --> |
| 31 | + <createData entity="VisualSwatchProductAttributeForm" stepKey="createVisualSwatchAttribute"/> |
| 32 | + <createData entity="SwatchProductAttributeOption1" stepKey="createVisualOption1"> |
| 33 | + <field key="label">visual1</field> |
| 34 | + <requiredEntity createDataKey="createVisualSwatchAttribute"/> |
| 35 | + </createData> |
| 36 | + <createData entity="SwatchProductAttributeOption2" stepKey="createVisualOption2"> |
| 37 | + <field key="label">visual2</field> |
| 38 | + <requiredEntity createDataKey="createVisualSwatchAttribute"/> |
| 39 | + </createData> |
| 40 | + <!-- Read persisted visual swatch option labels --> |
| 41 | + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getVisualOption1"> |
| 42 | + <requiredEntity createDataKey="createVisualSwatchAttribute"/> |
| 43 | + </getData> |
| 44 | + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getVisualOption2"> |
| 45 | + <requiredEntity createDataKey="createVisualSwatchAttribute"/> |
| 46 | + </getData> |
| 47 | + <!-- Step 1:Create text swatch attribute --> |
| 48 | + <createData entity="TextSwatchProductAttributeForm" stepKey="createTextSwatchAttribute"/> |
| 49 | + <createData entity="SwatchProductAttributeOption1" stepKey="createTextOption1"> |
| 50 | + <field key="label">text1</field> |
| 51 | + <requiredEntity createDataKey="createTextSwatchAttribute"/> |
| 52 | + </createData> |
| 53 | + <createData entity="SwatchProductAttributeOption2" stepKey="createTextOption2"> |
| 54 | + <field key="label">text2</field> |
| 55 | + <requiredEntity createDataKey="createTextSwatchAttribute"/> |
| 56 | + </createData> |
| 57 | + <!-- Read persisted text swatch option labels --> |
| 58 | + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getTextOption1"> |
| 59 | + <requiredEntity createDataKey="createTextSwatchAttribute"/> |
| 60 | + </getData> |
| 61 | + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getTextOption2"> |
| 62 | + <requiredEntity createDataKey="createTextSwatchAttribute"/> |
| 63 | + </getData> |
| 64 | + <actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/> |
| 65 | + <!--Step 1: Set use in layered navigation for visual swatch attribute --> |
| 66 | + <actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openVisualAttributeFromGrid"> |
| 67 | + <argument name="productAttributeCode" value="$createVisualSwatchAttribute.attribute_code$"/> |
| 68 | + </actionGroup> |
| 69 | + <actionGroup ref="AdminSetProductAttributeUseInLayeredNavigationOptionActionGroup" stepKey="setVisualUseInLayeredNavigation"> |
| 70 | + <argument name="useInLayeredNavigationValue" value="Filterable (with results)"/> |
| 71 | + </actionGroup> |
| 72 | + <!-- Step 1: Set Use in layered navigation for text swatch attribute --> |
| 73 | + <actionGroup ref="OpenProductAttributeFromSearchResultInGridActionGroup" stepKey="openTextAttributeFromGrid"> |
| 74 | + <argument name="productAttributeCode" value="$createTextSwatchAttribute.attribute_code$"/> |
| 75 | + </actionGroup> |
| 76 | + <actionGroup ref="AdminSetProductAttributeUseInLayeredNavigationOptionActionGroup" stepKey="setTextUseInLayeredNavigation"> |
| 77 | + <argument name="useInLayeredNavigationValue" value="Filterable (with results)"/> |
| 78 | + </actionGroup> |
| 79 | + <!--Step 2: Assign visual swatch option1 to Product 1 --> |
| 80 | + <actionGroup ref="NavigateToCreatedProductEditPageActionGroup" stepKey="openProduct1ForEdit"> |
| 81 | + <argument name="product" value="$$createProduct1$$"/> |
| 82 | + </actionGroup> |
| 83 | + <actionGroup ref="AdminAddCustomAttributeToSelectedProductActionGroup" stepKey="addVisualAttrToProduct1"> |
| 84 | + <argument name="attributeCode" value="$createVisualSwatchAttribute.attribute_code$"/> |
| 85 | + <argument name="adminOption1" value="$getVisualOption1.label$"/> |
| 86 | + </actionGroup> |
| 87 | + <!--Step 3: Assign text swatch option2 to Product 2 --> |
| 88 | + <actionGroup ref="NavigateToCreatedProductEditPageActionGroup" stepKey="openProduct2ForEdit"> |
| 89 | + <argument name="product" value="$$createProduct2$$"/> |
| 90 | + </actionGroup> |
| 91 | + <actionGroup ref="AdminAddCustomAttributeToSelectedProductActionGroup" stepKey="addTextAttrToProduct2"> |
| 92 | + <argument name="attributeCode" value="$createTextSwatchAttribute.attribute_code$"/> |
| 93 | + <argument name="adminOption1" value="$getTextOption2.label$"/> |
| 94 | + </actionGroup> |
| 95 | + </before> |
| 96 | + <after> |
| 97 | + <!-- Delete products, swatch attributes, category and logout from admin--> |
| 98 | + <deleteData createDataKey="createProduct1" stepKey="deleteProduct1"/> |
| 99 | + <deleteData createDataKey="createProduct2" stepKey="deleteProduct2"/> |
| 100 | + <deleteData createDataKey="createVisualSwatchAttribute" stepKey="deleteVisualAttribute"/> |
| 101 | + <deleteData createDataKey="createTextSwatchAttribute" stepKey="deleteTextAttribute"/> |
| 102 | + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> |
| 103 | + <actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/> |
| 104 | + </after> |
| 105 | + <!-- Step 4: Open Frontend application with layered navigation of products--> |
| 106 | + <actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="openCategory"> |
| 107 | + <argument name="category" value="$createCategory$"/> |
| 108 | + </actionGroup> |
| 109 | + <waitForElementClickable selector="{{StorefrontCategorySidebarSection.filterOptionsTitle('$createVisualSwatchAttribute.frontend_label[0]$')}}" stepKey="waitToClickVisualFilter"/> |
| 110 | + <click selector="{{StorefrontCategorySidebarSection.filterOptionsTitle('$createVisualSwatchAttribute.frontend_label[0]$')}}" stepKey="expandVisualFilter"/> |
| 111 | + <!-- Step 5: Search by visual swatch attribute with option1 in layered navigation and verify product1 is displayed--> |
| 112 | + <waitForElementClickable selector="{{StorefrontLayeredNavigationSection.layeredNavigationNthSwatch('$getVisualOption1.label$')}}" stepKey="waitToFilterVisualOption1"/> |
| 113 | + <click selector="{{StorefrontLayeredNavigationSection.layeredNavigationNthSwatch('$getVisualOption1.label$')}}" stepKey="filterVisualOption1"/> |
| 114 | + <waitForPageLoad stepKey="waitAfterSelectingVisualOption"/> |
| 115 | + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="assertProduct1Visible"> |
| 116 | + <argument name="productName" value="$createProduct1.name$"/> |
| 117 | + </actionGroup> |
| 118 | + <!-- Step 6: Verify visual swatch option2 is not visible --> |
| 119 | + <waitForElementNotVisible selector="{{StorefrontLayeredNavigationSection.layeredNavigationNthSwatch('$getVisualOption2.label$')}}" stepKey="verifyVisualOption2IsNotVisible"/> |
| 120 | + <!-- Step 7: Verify text swatch option1 is not visible --> |
| 121 | + <waitForElementClickable selector="{{StorefrontCategorySidebarSection.removeFilter}}" stepKey="waitToRemoveTheFilter"/> |
| 122 | + <click selector="{{StorefrontCategorySidebarSection.removeFilter}}" stepKey="removeTheFilter"/> |
| 123 | + <waitForElementClickable selector="{{StorefrontCategorySidebarSection.filterOptionsTitle('$createTextSwatchAttribute.frontend_label[0]$')}}" stepKey="waitToExpandTextFilter"/> |
| 124 | + <click selector="{{StorefrontCategorySidebarSection.filterOptionsTitle('$createTextSwatchAttribute.frontend_label[0]$')}}" stepKey="expandTextFilter"/> |
| 125 | + <waitForElementNotVisible selector="{{StorefrontLayeredNavigationSection.layeredNavigationNthSwatch('$getTextOption1.label$')}}" stepKey="verifyTextOption1IsNotVisible"/> |
| 126 | + <!-- Step 8: Search by text swatch attribute with option2 in layered navigation and verify product2 is displayed--> |
| 127 | + <waitForElementClickable selector="{{StorefrontLayeredNavigationSection.layeredNavigationNthSwatch('$getTextOption2.label$')}}" stepKey="waitToFilterTextOption2"/> |
| 128 | + <click selector="{{StorefrontLayeredNavigationSection.layeredNavigationNthSwatch('$getTextOption2.label$')}}" stepKey="filterTextOption2"/> |
| 129 | + <waitForPageLoad stepKey="waitAfterTextOptionSelection" /> |
| 130 | + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="assertProduct2Visible"> |
| 131 | + <argument name="productName" value="$createProduct2.name$"/> |
| 132 | + </actionGroup> |
| 133 | + </test> |
| 134 | +</tests> |
0 commit comments