|
| 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="StorefrontCategoryNavigationHighlightingTest"> |
| 12 | + <annotations> |
| 13 | + <features value="Catalog"/> |
| 14 | + <stories value="Category Navigation Highlighting without Store Code in URLs"/> |
| 15 | + <title value="Verify category highlighting in navigation without store code in URLs and no URL suffixes"/> |
| 16 | + <description value="Correct category is highlighted in the navigation menu when navigating through categories and products on the storefront based on store code"/> |
| 17 | + <severity value="MAJOR"/> |
| 18 | + <testCaseId value="AC-10851"/> |
| 19 | + <group value="Catalog"/> |
| 20 | + </annotations> |
| 21 | + <before> |
| 22 | + <!-- Login as admin --> |
| 23 | + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> |
| 24 | + <!-- Precondition Step 1: Create root category Cat 0 --> |
| 25 | + <createData entity="SimpleSubCategory" stepKey="createCat0"/> |
| 26 | + <!-- Create main category Cat 1 --> |
| 27 | + <createData entity="_defaultCategory" stepKey="createCat1"/> |
| 28 | + <!-- Create subcategory Cat 1.1 --> |
| 29 | + <createData entity="Two_nested_categories" stepKey="createCat11"> |
| 30 | + <requiredEntity createDataKey="createCat1"/> |
| 31 | + </createData> |
| 32 | + <!-- Create subcategory Cat 1.2 --> |
| 33 | + <createData entity="Two_nested_categories" stepKey="createCat12"> |
| 34 | + <requiredEntity createDataKey="createCat1"/> |
| 35 | + </createData> |
| 36 | + <!-- Create Product 1.1 and assign to Cat 1.1 --> |
| 37 | + <createData entity="SimpleProduct" stepKey="createProduct11"> |
| 38 | + <requiredEntity createDataKey="createCat11"/> |
| 39 | + </createData> |
| 40 | + <!-- Create Product 1.2 and assign to Cat 1.2 --> |
| 41 | + <createData entity="SimpleProduct" stepKey="createProduct12"> |
| 42 | + <requiredEntity createDataKey="createCat12"/> |
| 43 | + </createData> |
| 44 | + <!-- Create Product 1.1-1.2 and assign to both Cat 1.1 and Cat 1.2 --> |
| 45 | + <createData entity="_defaultProduct" stepKey="createProduct1112"> |
| 46 | + <requiredEntity createDataKey="createCat11"/> |
| 47 | + </createData> |
| 48 | + <actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct"> |
| 49 | + <argument name="product" value="$$createProduct1112$$"/> |
| 50 | + </actionGroup> |
| 51 | + <actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct1"> |
| 52 | + <argument name="product" value="$$createProduct1112$$"/> |
| 53 | + </actionGroup> |
| 54 | + <searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[$$createCat12.name$$]" stepKey="fillCategory"/> |
| 55 | + <actionGroup ref="AdminProductFormSaveActionGroup" stepKey="clickSaveButton"/> |
| 56 | + <!-- Set configuration: Use Categories Path for Product URLs: Yes --> |
| 57 | + <magentoCLI command="config:set {{EnableCategoriesPathForProductUrls.path}} {{EnableCategoriesPathForProductUrls.value}}" stepKey="enableUseCategoriesPathForProductUrlsDefault"/> |
| 58 | + </before> |
| 59 | + <after> |
| 60 | + <!-- Reset configuration: Use Categories Path for Product URLs: Yes (default) --> |
| 61 | + <magentoCLI command="config:set {{DisableCategoriesPathForProductUrls.path}} {{DisableCategoriesPathForProductUrls.value}}" stepKey="disableCategoriesPathForProductUrls"/> |
| 62 | + <!-- Delete created products --> |
| 63 | + <deleteData createDataKey="createProduct11" stepKey="deleteProduct11"/> |
| 64 | + <deleteData createDataKey="createProduct12" stepKey="deleteProduct12"/> |
| 65 | + <deleteData createDataKey="createProduct1112" stepKey="deleteProduct1112"/> |
| 66 | + <!-- Delete created categories --> |
| 67 | + <deleteData createDataKey="createCat12" stepKey="deleteCat12"/> |
| 68 | + <deleteData createDataKey="createCat11" stepKey="deleteCat11"/> |
| 69 | + <deleteData createDataKey="createCat1" stepKey="deleteCat1"/> |
| 70 | + <deleteData createDataKey="createCat0" stepKey="deleteCat0"/> |
| 71 | + <!-- Logout from admin --> |
| 72 | + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> |
| 73 | + </after> |
| 74 | + <!-- Step 1: Open home page --> |
| 75 | + <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="openStorefrontHomePage"/> |
| 76 | + <!-- Step 2: Open Cat 1 -> Check that Cat 1 is highlighted (has class 'active') --> |
| 77 | + <actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="selectCategory"> |
| 78 | + <argument name="categoryName" value="$$createCat1.name$$"/> |
| 79 | + </actionGroup> |
| 80 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat1.name$$)}}" userInput="class" stepKey="grabCategory1Class"/> |
| 81 | + <assertStringContainsString stepKey="assertCategory1IsHighlighted"> |
| 82 | + <actualResult type="const">$grabCategory1Class</actualResult> |
| 83 | + <expectedResult type="string">active</expectedResult> |
| 84 | + </assertStringContainsString> |
| 85 | + <!--Check if Category 1 is highlighted --> |
| 86 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedCategoryAmount"/> |
| 87 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.parentCategoryNotHighlighted}}').length" stepKey="highlightedParentCategoryAmount"/> |
| 88 | + <assertEquals stepKey="assertCategoryIsActive"> |
| 89 | + <actualResult type="const">$highlightedCategoryAmount</actualResult> |
| 90 | + <expectedResult type="int">1</expectedResult> |
| 91 | + </assertEquals> |
| 92 | + <assertEquals stepKey="assertParentCategoryHasActiveChild"> |
| 93 | + <actualResult type="const">$highlightedParentCategoryAmount</actualResult> |
| 94 | + <expectedResult type="int">0</expectedResult> |
| 95 | + </assertEquals> |
| 96 | + <!-- Step 3: Open Cat 1.1 > Check that Cat 1.1 is highlighted (has class 'active') & parent Cat 1 is also highlighted (has class 'has-active') --> |
| 97 | + <actionGroup ref="StorefrontGoToSubCategoryPageActionGroup" stepKey="navigateToSubCategoryPage"> |
| 98 | + <argument name="categoryName" value="$$createCat1.name$$"/> |
| 99 | + <argument name="subCategoryName" value="$$createCat11.name$$"/> |
| 100 | + </actionGroup> |
| 101 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat11.name$$)}}" userInput="class" stepKey="grabCat11Class"/> |
| 102 | + <assertStringContainsString stepKey="assertCat11IsHighlighted"> |
| 103 | + <actualResult type="const">$grabCat11Class</actualResult> |
| 104 | + <expectedResult type="string">active</expectedResult> |
| 105 | + </assertStringContainsString> |
| 106 | + <!-- Verify parent Cat 1 has 'has-active' class --> |
| 107 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat1.name$$)}}" userInput="class" stepKey="grabCat1ParentClass"/> |
| 108 | + <assertStringContainsString stepKey="assertCat1HasActiveClass"> |
| 109 | + <actualResult type="const">$grabCat1ParentClass</actualResult> |
| 110 | + <expectedResult type="string">has-active</expectedResult> |
| 111 | + </assertStringContainsString> |
| 112 | + <!-- Verify Cat 1.1 is highlighted with active class --> |
| 113 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedCategoryAmount_Try2"/> |
| 114 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.parentCategoryNotHighlighted}}').length" stepKey="highlightedParentCategoryAmount_Try2"/> |
| 115 | + <assertEquals stepKey="assertCategoryIsActive_Try2"> |
| 116 | + <actualResult type="const">$highlightedCategoryAmount_Try2</actualResult> |
| 117 | + <expectedResult type="int">1</expectedResult> |
| 118 | + </assertEquals> |
| 119 | + <assertEquals stepKey="assertParentCategoryHasActiveChild_Try2"> |
| 120 | + <actualResult type="const">$highlightedParentCategoryAmount_Try2</actualResult> |
| 121 | + <expectedResult type="int">1</expectedResult> |
| 122 | + </assertEquals> |
| 123 | + <!-- Step 4: Open Product 1.1-1.2 from Cat 1.1 page -> check that only categories Cat 1 & Cat 1.1 are highlighted --> |
| 124 | + <actionGroup ref="StorefrontOpenProductFromCategoryPageActionGroup" stepKey="openProduct1112FromCat11"> |
| 125 | + <argument name="productName" value="$$createProduct1112.name$$"/> |
| 126 | + </actionGroup> |
| 127 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat11.name$$)}}" userInput="class" stepKey="grabCat11ClassOnProduct"/> |
| 128 | + <assertStringContainsString stepKey="assertCat11IsHighlightedOnProduct"> |
| 129 | + <actualResult type="const">$grabCat11ClassOnProduct</actualResult> |
| 130 | + <expectedResult type="string">active</expectedResult> |
| 131 | + </assertStringContainsString> |
| 132 | + <!-- Verify parent Cat 1 still has 'has-active' class --> |
| 133 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat1.name$$)}}" userInput="class" stepKey="grabCat1ParentClassOnProduct"/> |
| 134 | + <assertStringContainsString stepKey="assertCat1HasActiveClassOnProduct"> |
| 135 | + <actualResult type="const">$grabCat1ParentClassOnProduct</actualResult> |
| 136 | + <expectedResult type="string">has-active</expectedResult> |
| 137 | + </assertStringContainsString> |
| 138 | + <!-- Verify Cat 1.1 is still highlighted --> |
| 139 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedCategoryAmount_Try3"/> |
| 140 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.parentCategoryNotHighlighted}}').length" stepKey="highlightedParentCategoryAmount_Try3"/> |
| 141 | + <assertEquals stepKey="assertCategoryIsActive_Try3"> |
| 142 | + <actualResult type="const">$highlightedCategoryAmount_Try3</actualResult> |
| 143 | + <expectedResult type="int">1</expectedResult> |
| 144 | + </assertEquals> |
| 145 | + <assertEquals stepKey="assertParentCategoryHasActiveChild_Try3"> |
| 146 | + <actualResult type="const">$highlightedParentCategoryAmount_Try3</actualResult> |
| 147 | + <expectedResult type="int">1</expectedResult> |
| 148 | + </assertEquals> |
| 149 | + <!-- Step 5: Click on home page -> Check that no categories are highlighted --> |
| 150 | + <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="returnToStorefrontHomePage"/> |
| 151 | + <!-- Verify no categories are highlighted after returning to home --> |
| 152 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="getHighlightedCategoriesCountAfterHome"/> |
| 153 | + <assertEquals stepKey="assertNoCategoriesHighlightedAfterHome"> |
| 154 | + <actualResult type="const">$getHighlightedCategoriesCountAfterHome</actualResult> |
| 155 | + <expectedResult type="int">0</expectedResult> |
| 156 | + </assertEquals> |
| 157 | + <!-- Step 6: Open Cat 1.2 -> Check that Cat 1.2 is highlighted (has class 'active') & parent Cat 1 is also highlighted (has class 'has–active') --> |
| 158 | + <actionGroup ref="StorefrontGoToSubCategoryPageActionGroup" stepKey="goToSubCategoryPage"> |
| 159 | + <argument name="categoryName" value="$$createCat1.name$$"/> |
| 160 | + <argument name="subCategoryName" value="$$createCat12.name$$"/> |
| 161 | + </actionGroup> |
| 162 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat12.name$$)}}" userInput="class" stepKey="grabCat12Class"/> |
| 163 | + <assertStringContainsString stepKey="assertCat12IsHighlighted"> |
| 164 | + <actualResult type="const">$grabCat12Class</actualResult> |
| 165 | + <expectedResult type="string">active</expectedResult> |
| 166 | + </assertStringContainsString> |
| 167 | + <!-- Verify parent Cat 1 has 'has-active' class --> |
| 168 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat1.name$$)}}" userInput="class" stepKey="grabCat1ParentClassForCat12"/> |
| 169 | + <assertStringContainsString stepKey="assertCat1HasActiveClassForCat12"> |
| 170 | + <actualResult type="const">$grabCat1ParentClassForCat12</actualResult> |
| 171 | + <expectedResult type="string">has-active</expectedResult> |
| 172 | + </assertStringContainsString> |
| 173 | + <!-- Verify Cat 1.2 is highlighted with active class --> |
| 174 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedCategoryAmount_Try5"/> |
| 175 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.parentCategoryNotHighlighted}}').length" stepKey="highlightedParentCategoryAmount_Try5"/> |
| 176 | + <assertEquals stepKey="assertCategoryIsActive_Try4"> |
| 177 | + <actualResult type="const">$highlightedCategoryAmount_Try5</actualResult> |
| 178 | + <expectedResult type="int">1</expectedResult> |
| 179 | + </assertEquals> |
| 180 | + <assertEquals stepKey="assertParentCategoryHasActiveChild_Try4"> |
| 181 | + <actualResult type="const">$highlightedParentCategoryAmount_Try5</actualResult> |
| 182 | + <expectedResult type="int">1</expectedResult> |
| 183 | + </assertEquals> |
| 184 | + <!-- Step 7: Open direct Category 1.2 url -> Check that Cat 1.2 is highlighted & parent Cat 1 is also highlighted --> |
| 185 | + <actionGroup ref="NavigateToStorefrontForCreatedPageActionGroup" stepKey="navigateToCategoryStorefront"> |
| 186 | + <argument name="page" value="$$createCat1.custom_attributes[url_key]$$/$$createCat12.custom_attributes[url_key]$$.html"/> |
| 187 | + </actionGroup> |
| 188 | + <!-- Verify parent Cat 1 has 'has-active' class after direct navigation --> |
| 189 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat1.name$$)}}" userInput="class" stepKey="grabCat1ParentClassDirectNav"/> |
| 190 | + <assertStringContainsString stepKey="assertCat1HasActiveClassDirectNav"> |
| 191 | + <actualResult type="const">$grabCat1ParentClassDirectNav</actualResult> |
| 192 | + <expectedResult type="string">has-active</expectedResult> |
| 193 | + </assertStringContainsString> |
| 194 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat12.name$$)}}" userInput="class" stepKey="grabCat12ClassDirect"/> |
| 195 | + <assertStringContainsString stepKey="assertCat12IsHighlightedDirect"> |
| 196 | + <actualResult type="const">$grabCat12ClassDirect</actualResult> |
| 197 | + <expectedResult type="string">active</expectedResult> |
| 198 | + </assertStringContainsString> |
| 199 | + <!-- Verify Cat 1.2 is highlighted after direct navigation --> |
| 200 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedCategoryAmount_Try6"/> |
| 201 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.parentCategoryNotHighlighted}}').length" stepKey="highlightedParentCategoryAmount_Try6"/> |
| 202 | + <assertEquals stepKey="assertCategoryIsActive_Try5"> |
| 203 | + <actualResult type="const">$highlightedCategoryAmount_Try6</actualResult> |
| 204 | + <expectedResult type="int">1</expectedResult> |
| 205 | + </assertEquals> |
| 206 | + <assertEquals stepKey="assertParentCategoryHasActiveChild_Try5"> |
| 207 | + <actualResult type="const">$highlightedParentCategoryAmount_Try6</actualResult> |
| 208 | + <expectedResult type="int">1</expectedResult> |
| 209 | + </assertEquals> |
| 210 | + <!-- Step 8: Open Product 1.1-1.2 from Cat 1.2 page -> Check that only categories Cat 1 & Cat 1.2 are highlighted --> |
| 211 | + <actionGroup ref="StorefrontOpenProductFromCategoryPageActionGroup" stepKey="openProduct1112FromCat12"> |
| 212 | + <argument name="productName" value="$$createProduct1112.name$$"/> |
| 213 | + </actionGroup> |
| 214 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat12.name$$)}}" userInput="class" stepKey="grabCat12ClassOnProduct"/> |
| 215 | + <assertStringContainsString stepKey="assertCat12IsHighlightedOnProduct"> |
| 216 | + <actualResult type="const">$grabCat12ClassOnProduct</actualResult> |
| 217 | + <expectedResult type="string">active</expectedResult> |
| 218 | + </assertStringContainsString> |
| 219 | + <!-- Verify parent Cat 1 still has 'has-active' class on product page --> |
| 220 | + <grabAttributeFrom selector="{{AdminCategorySidebarTreeSection.categoryHighlighted($$createCat1.name$$)}}" userInput="class" stepKey="grabCat1ParentClassOnProductFromCat12"/> |
| 221 | + <assertStringContainsString stepKey="assertCat1HasActiveClassOnProductFromCat12"> |
| 222 | + <actualResult type="const">$grabCat1ParentClassOnProductFromCat12</actualResult> |
| 223 | + <expectedResult type="string">has-active</expectedResult> |
| 224 | + </assertStringContainsString> |
| 225 | + <!-- Verify Cat 1.2 is still highlighted on product page --> |
| 226 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedCategoryAmount_Try7"/> |
| 227 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.parentCategoryNotHighlighted}}').length" stepKey="highlightedParentCategoryAmount_Try7"/> |
| 228 | + <assertEquals stepKey="assertCategoryIsActive_Try6"> |
| 229 | + <actualResult type="const">$highlightedCategoryAmount_Try7</actualResult> |
| 230 | + <expectedResult type="int">1</expectedResult> |
| 231 | + </assertEquals> |
| 232 | + <assertEquals stepKey="assertParentCategoryHasActiveChild_Try6"> |
| 233 | + <actualResult type="const">$highlightedParentCategoryAmount_Try7</actualResult> |
| 234 | + <expectedResult type="int">1</expectedResult> |
| 235 | + </assertEquals> |
| 236 | + <!-- Step 9: Open Product 1.1-1.2 direct url with category & store in it -> Check that only categories Cat 1 & Cat 1.2 are highlighted --> |
| 237 | + <actionGroup ref="NavigateToStorefrontForCreatedPageActionGroup" stepKey="navigateToProductStorefront"> |
| 238 | + <argument name="page" value="$$createCat1.custom_attributes[url_key]$$/$$createCat12.custom_attributes[url_key]$$/$$createProduct1112.custom_attributes[url_key]$$.html"/> |
| 239 | + </actionGroup> |
| 240 | + <!-- Verify Cat 1.2 is still highlighted on product page --> |
| 241 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.categoryNotHighlighted}}').length" stepKey="highlightedCategoryAmount_Try8"/> |
| 242 | + <executeJS function="return document.querySelectorAll('{{AdminCategorySidebarTreeSection.parentCategoryNotHighlighted}}').length" stepKey="highlightedParentCategoryAmount_Try8"/> |
| 243 | + <assertEquals stepKey="assertCategoryIsActive_Try8"> |
| 244 | + <actualResult type="const">$highlightedCategoryAmount_Try8</actualResult> |
| 245 | + <expectedResult type="int">1</expectedResult> |
| 246 | + </assertEquals> |
| 247 | + <assertEquals stepKey="assertParentCategoryHasActiveChild_Try8"> |
| 248 | + <actualResult type="const">$highlightedParentCategoryAmount_Try8</actualResult> |
| 249 | + <expectedResult type="int">1</expectedResult> |
| 250 | + </assertEquals> |
| 251 | + </test> |
| 252 | +</tests> |
0 commit comments