|
| 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="StorefrontSearchToolbarTest"> |
| 12 | + <annotations> |
| 13 | + <features value="Search"/> |
| 14 | + <stories value="Search Result Toolbar"/> |
| 15 | + <title value="Verify sorting toolbar changes on search results work as expected and don't cause form resubmission dialog"/> |
| 16 | + <description value="Test that sorting toolbar changes apply properly and redirect properly to prevent 'Confirm Form Resubmission' dialog when using back button, and toolbar settings are preserved"/> |
| 17 | + <severity value="MAJOR"/> |
| 18 | + <testCaseId value="AC-15666,AC-8905"/> |
| 19 | + <useCaseId value="ACP2E-4208"/> |
| 20 | + <group value="CatalogSearch"/> |
| 21 | + </annotations> |
| 22 | + |
| 23 | + <before> |
| 24 | + <!-- Create several products to have enough for pagination/sorting --> |
| 25 | + <createData entity="SimpleProduct" stepKey="createProduct1"> |
| 26 | + <field key="name">StorefrontSearchToolbarTestProduct C</field> |
| 27 | + <field key="price">30.00</field> |
| 28 | + </createData> |
| 29 | + <createData entity="SimpleProduct" stepKey="createProduct2"> |
| 30 | + <field key="name">StorefrontSearchToolbarTestProduct B</field> |
| 31 | + <field key="price">10.00</field> |
| 32 | + </createData> |
| 33 | + <createData entity="SimpleProduct" stepKey="createProduct3"> |
| 34 | + <field key="name">StorefrontSearchToolbarTestProduct A</field> |
| 35 | + <field key="price">20.00</field> |
| 36 | + </createData> |
| 37 | + |
| 38 | + <!-- Enable remember pagination --> |
| 39 | + <createData entity="RememberPaginationCatalogStorefrontConfig" stepKey="setRememberPaginationCatalogStorefrontConfig"/> |
| 40 | + </before> |
| 41 | + |
| 42 | + <after> |
| 43 | + <!-- Reset display settings to default --> |
| 44 | + <actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="searchForProductsCleanup"> |
| 45 | + <argument name="phrase" value="StorefrontSearchToolbarTestProduct"/> |
| 46 | + </actionGroup> |
| 47 | + <actionGroup ref="StorefrontSearchSetDefaultDisplaySettingsActionGroup" stepKey="resetDisplaySettingsToDefault"/> |
| 48 | + |
| 49 | + <!-- Clean up products and category --> |
| 50 | + <deleteData createDataKey="createProduct1" stepKey="deleteProduct1"/> |
| 51 | + <deleteData createDataKey="createProduct2" stepKey="deleteProduct2"/> |
| 52 | + <deleteData createDataKey="createProduct3" stepKey="deleteProduct3"/> |
| 53 | + |
| 54 | + <!-- Reset configuration --> |
| 55 | + <createData entity="DefaultCatalogStorefrontConfiguration" stepKey="setDefaultCatalogStorefrontConfiguration"/> |
| 56 | + </after> |
| 57 | + |
| 58 | + <!-- Step 1: Navigate to storefront and perform initial search --> |
| 59 | + <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToStorefront"/> |
| 60 | + <actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="searchForProducts"> |
| 61 | + <argument name="phrase" value="StorefrontSearchToolbarTestProduct"/> |
| 62 | + </actionGroup> |
| 63 | + |
| 64 | + <!-- Set default search display settings once at the beginning --> |
| 65 | + <actionGroup ref="StorefrontSearchSetDefaultDisplaySettingsActionGroup" stepKey="setSearchDisplayDefaultSettings"/> |
| 66 | + |
| 67 | + <!-- Step 2: Change sort order to price, then to name --> |
| 68 | + <selectOption selector="{{StorefrontSearchTopToolbarSection.sortByDropdown}}" userInput="price" stepKey="selectSortByPrice"/> |
| 69 | + <waitForPageLoad stepKey="waitForPriceSortingApplied"/> |
| 70 | + |
| 71 | + <!-- Change to ascending price order --> |
| 72 | + <click selector="{{StorefrontSearchTopToolbarSection.sortDirectionDesc}}" stepKey="changePriceToAscending"/> |
| 73 | + <waitForPageLoad stepKey="waitForAscendingPriceApplied"/> |
| 74 | + |
| 75 | + <!-- Verify Product B is displayed first (lowest price $10.00) --> |
| 76 | + <see userInput="StorefrontSearchToolbarTestProduct B" selector="{{StorefrontCategoryMainSection.productNameByPosition('1')}}" stepKey="seeProductBFirstByPrice"/> |
| 77 | + |
| 78 | + <!-- Now change sort to name --> |
| 79 | + <selectOption selector="{{StorefrontSearchTopToolbarSection.sortByDropdown}}" userInput="name" stepKey="selectSortByName"/> |
| 80 | + <waitForPageLoad stepKey="waitForNameSortingApplied"/> |
| 81 | + |
| 82 | + <!-- Verify Product A is displayed first (alphabetically first in ascending order) --> |
| 83 | + <see userInput="StorefrontSearchToolbarTestProduct A" selector="{{StorefrontCategoryMainSection.productNameByPosition('1')}}" stepKey="seeProductAFirstByName"/> |
| 84 | + |
| 85 | + <!-- Step 3: Change sort direction to descending --> |
| 86 | + <click selector="{{StorefrontSearchTopToolbarSection.sortDirectionAsc}}" stepKey="changeSortToDescending"/> |
| 87 | + <waitForPageLoad stepKey="waitForDescendingSortingApplied"/> |
| 88 | + |
| 89 | + <!-- Verify Product C is displayed first (alphabetically last in descending order) --> |
| 90 | + <see userInput="StorefrontSearchToolbarTestProduct C" selector="{{StorefrontCategoryMainSection.productNameByPosition('1')}}" stepKey="seeProductCFirstByNameDesc"/> |
| 91 | + |
| 92 | + <!-- Change items per page --> |
| 93 | + <selectOption selector="{{StorefrontSearchTopToolbarSection.showDropdown}}" userInput="24" stepKey="selectItemsPerPage"/> |
| 94 | + <waitForPageLoad stepKey="waitForLimitApplied"/> |
| 95 | + |
| 96 | + <!-- Step 4: Navigate to a product page --> |
| 97 | + <comment userInput="Navigate to product page to test back button behavior" stepKey="commentNavigateToProduct"/> |
| 98 | + <click selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo('StorefrontSearchToolbarTestProduct C')}}" stepKey="clickOnFirstProduct"/> |
| 99 | + <waitForPageLoad stepKey="waitForProductPage"/> |
| 100 | + |
| 101 | + <!-- Verify we're on Product C page --> |
| 102 | + <see userInput="StorefrontSearchToolbarTestProduct C" selector="{{StorefrontProductInfoMainSection.productName}}" stepKey="seeProductCName"/> |
| 103 | + <seeInCurrentUrl url=".html" stepKey="seeProductUrl"/> |
| 104 | + |
| 105 | + <!-- Step 5: Use back button to return to search results --> |
| 106 | + <moveBack stepKey="clickBackButton"/> |
| 107 | + <waitForPageLoad stepKey="waitForBackNavigation"/> |
| 108 | + |
| 109 | + <!-- Step 6: Verify we're back on search page --> |
| 110 | + <comment userInput="Verify search results page is displayed and toolbar settings are preserved" stepKey="commentVerifySearchPage"/> |
| 111 | + <see userInput="Search results for: 'StorefrontSearchToolbarTestProduct'" stepKey="seeSearchResultsTitleAfterBack"/> |
| 112 | + <seeInCurrentUrl url="catalogsearch/result" stepKey="seeSearchUrlAfterBack"/> |
| 113 | + |
| 114 | + <!-- Step 7: "Verify all display settings are preserved --> |
| 115 | + <comment userInput="Verify all display settings are preserved: grid mode, name sort descending, 24 items per page" stepKey="commentVerifyAllSettings"/> |
| 116 | + <seeElement selector="{{StorefrontSearchTopToolbarSection.gridMode}}" stepKey="verifyGridModePreserved"/> |
| 117 | + <seeOptionIsSelected selector="{{StorefrontSearchTopToolbarSection.sortByDropdown}}" userInput="name" stepKey="verifyNameSortPreserved"/> |
| 118 | + <seeElement selector="{{StorefrontSearchTopToolbarSection.sortDirectionDesc}}" stepKey="verifyDescendingSortPreserved"/> |
| 119 | + <seeOptionIsSelected selector="{{StorefrontSearchTopToolbarSection.showDropdown}}" userInput="24" stepKey="verify24ItemsPerPagePreserved"/> |
| 120 | + |
| 121 | + <!-- Product order matches expectations (C-B-A descending by name) --> |
| 122 | + <see userInput="StorefrontSearchToolbarTestProduct C" selector="{{StorefrontCategoryMainSection.productNameByPosition('1')}}" stepKey="finalVerifyProductCFirst"/> |
| 123 | + <see userInput="StorefrontSearchToolbarTestProduct B" selector="{{StorefrontCategoryMainSection.productNameByPosition('2')}}" stepKey="finalVerifyProductBSecond"/> |
| 124 | + <see userInput="StorefrontSearchToolbarTestProduct A" selector="{{StorefrontCategoryMainSection.productNameByPosition('3')}}" stepKey="finalVerifyProductAThird"/> |
| 125 | + |
| 126 | + <!-- Step 8: Verify sorting functionality still works after back button navigation --> |
| 127 | + <comment userInput="Test that sorting functionality is still operational after back button navigation" stepKey="commentTestSortingStillWorks"/> |
| 128 | + |
| 129 | + <!-- Change sort direction to ascending to test sorting still works --> |
| 130 | + <click selector="{{StorefrontSearchTopToolbarSection.sortDirectionDesc}}" stepKey="changeSortToAscendingAfterBack"/> |
| 131 | + <waitForPageLoad stepKey="waitForAscendingSortingAfterBack"/> |
| 132 | + |
| 133 | + <!-- Verify Product A is now first (alphabetically first in ascending order) --> |
| 134 | + <see userInput="StorefrontSearchToolbarTestProduct A" selector="{{StorefrontCategoryMainSection.productNameByPosition('1')}}" stepKey="verifyProductAFirstAfterSortChange"/> |
| 135 | + |
| 136 | + <!-- Change sort back to price to test different sorting option --> |
| 137 | + <selectOption selector="{{StorefrontSearchTopToolbarSection.sortByDropdown}}" userInput="price" stepKey="selectSortByPriceAfterBack"/> |
| 138 | + <waitForPageLoad stepKey="waitForPriceSortingAfterBack"/> |
| 139 | + |
| 140 | + <!-- Verify Product B is first (lowest price $10.00) --> |
| 141 | + <see userInput="StorefrontSearchToolbarTestProduct B" selector="{{StorefrontCategoryMainSection.productNameByPosition('1')}}" stepKey="verifyProductBFirstByPriceAfterBack"/> |
| 142 | + </test> |
| 143 | +</tests> |
0 commit comments