1- import { expect , test } from '@playwright/test'
1+ import { Page , expect , test } from '@playwright/test'
22import { Grid } from '../../../../helper/grid'
33import { Dropdown } from '../../../../helper/dropdown'
44import { login } from '../../../../helper/auth'
55import { navigateTo } from '../../../../helper/menu'
66import { AlertMessage , AlertMessageType } from '../../../../helper/alertMessage'
77import { Switch } from '../../../../helper/switch'
88import { generateTestId , TestId } from "../../../../helper/testIds" ;
9+ import { GallyPackage } from '../../../../helper/gallyPackage'
910
1011const testIds = {
1112 defaultSorting : 'defaultSorting' ,
@@ -46,7 +47,7 @@ const texts = {
4647 stockStatus : 'Stock status'
4748} as const
4849
49- test ( 'Pages > Merchandising > Categories' , { tag : [ '@premium' , '@standard' ] } , async ( { page } ) = > {
50+ async function testCategoriesPage ( page : Page , gallyPackage : GallyPackage ) : Promise < void > {
5051 await test . step ( 'Login and navigate to the Categories page' , async ( ) => {
5152 await login ( page )
5253 await navigateTo ( page , texts . labelMenuPage , '/admin/merchandize/categories' )
@@ -97,7 +98,9 @@ test('Pages > Merchandising > Categories', {tag: ['@premium', '@standard']}, asy
9798 await test . step ( 'Expect configuration fields to be visible' , async ( ) => {
9899 await defaultSortingDropdown . expectToBeVisible ( )
99100 await useNameInProductSearchSwitch . expectToBeVisible ( )
100- await isVirtualSwitch . expectToBeVisible ( )
101+ if ( gallyPackage === GallyPackage . PREMIUM ) {
102+ await isVirtualSwitch . expectToBeVisible ( )
103+ }
101104 await expect ( categoriesProductsSaveButton ) . toBeDisabled ( )
102105 } )
103106
@@ -132,6 +135,14 @@ test('Pages > Merchandising > Categories', {tag: ['@premium', '@standard']}, asy
132135 await defaultSortingDropdown . expectToHaveValue ( texts . brand )
133136 } )
134137
138+ await test . step ( 'Reset default sorting values for "All catalogs"' , async ( ) => {
139+ await catalogDropdown . selectValue ( texts . allCatalog )
140+ await defaultSortingDropdown . selectValue ( texts . position )
141+ await categoriesProductsSaveButton . click ( )
142+ await alertMessage . expectToHaveText ( texts . saveDataMessage , AlertMessageType . SUCCESS )
143+ await catalogDropdown . selectValue ( texts . catalogs [ 0 ] )
144+ } )
145+
135146 const categoryCollapseTreeListButton = await page
136147 . getByTestId ( testIds . categoryCollapseTreeListButton )
137148 . all ( )
@@ -142,24 +153,26 @@ test('Pages > Merchandising > Categories', {tag: ['@premium', '@standard']}, asy
142153 await collapseButton . click ( )
143154 }
144155
145- const categoyBasButton = page
156+ const categoryBasButton = page
146157 . getByTestId ( testIds . treeItemTitleButton )
147158 . filter ( {
148159 hasText : texts . basCategory ,
149160 } )
150161
151- await expect ( categoyBasButton ) . toBeVisible ( )
162+ await expect ( categoryBasButton ) . toBeVisible ( )
152163
153- await categoyBasButton . click ( )
164+ await categoryBasButton . click ( )
154165
155166 await expect ( pageTitle ) . toHaveText ( texts . basCategory )
156167 await defaultSortingDropdown . selectValue ( texts . price )
157- await isVirtualSwitch . enable ( )
158168
159- const combinationRules = page . getByTestId ( testIds . combinationRules )
160- await expect ( combinationRules ) . toBeVisible ( )
161- await isVirtualSwitch . disable ( )
162- await expect ( combinationRules ) . not . toBeVisible ( )
169+ if ( gallyPackage === GallyPackage . PREMIUM ) {
170+ await isVirtualSwitch . enable ( )
171+ const combinationRules = page . getByTestId ( testIds . combinationRules )
172+ await expect ( combinationRules ) . toBeVisible ( )
173+ await isVirtualSwitch . disable ( )
174+ await expect ( combinationRules ) . not . toBeVisible ( )
175+ }
163176
164177 await expect ( categoriesProductsSaveButton ) . not . toBeDisabled ( )
165178 await categoriesProductsSaveButton . click ( )
@@ -188,5 +201,29 @@ test('Pages > Merchandising > Categories', {tag: ['@premium', '@standard']}, asy
188201 await catalogDropdown . selectValue ( texts . allCatalog )
189202 await defaultSortingDropdown . expectToHaveValue ( texts . position )
190203 } )
204+
205+ await test . step ( 'Reset default sorting values for "COM Catalog"' , async ( ) => {
206+ // Reset default sorting on com_fr for FR_fr locale
207+ await catalogDropdown . selectValue ( texts . catalogs [ 0 ] )
208+ await localizedCatalogDropdown . selectValue ( texts . locales [ 0 ] )
209+ await defaultSortingDropdown . selectValue ( texts . position )
210+ await categoriesProductsSaveButton . click ( )
211+ await alertMessage . expectToHaveText ( texts . saveDataMessage , AlertMessageType . SUCCESS )
212+
213+ // Reset default sorting on com_fr for all locales
214+ await catalogDropdown . selectValue ( texts . catalogs [ 0 ] )
215+ await localizedCatalogDropdown . selectValue ( texts . allLocales )
216+ await defaultSortingDropdown . selectValue ( texts . position )
217+ await expect ( categoriesProductsSaveButton ) . not . toBeDisabled ( )
218+ await categoriesProductsSaveButton . click ( )
219+ await alertMessage . expectToHaveText ( texts . saveDataMessage , AlertMessageType . SUCCESS )
220+ } )
221+ }
222+
223+ test ( 'Pages > Merchandising > Standard Categories' , { tag : [ '@standard' ] } , async ( { page} ) => {
224+ await testCategoriesPage ( page , GallyPackage . STANDARD )
191225} )
192226
227+ test ( 'Pages > Merchandising > Premium Categories' , { tag : [ '@premium' ] } , async ( { page} ) => {
228+ await testCategoriesPage ( page , GallyPackage . PREMIUM )
229+ } )
0 commit comments