Skip to content

Commit f22ea52

Browse files
committed
#1340374 draft
1 parent 59e82fe commit f22ea52

File tree

12 files changed

+368
-486
lines changed

12 files changed

+368
-486
lines changed

front/e2e/src/helper/filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export class Filter<TFilters extends Record<string, FilterType>> {
208208
const value = filters[name];
209209

210210
// If it's an array (only for DROPDOWN), iterate
211-
if (Array.isArray(value)) {
211+
if (Array.isArray(value) && this.filters[name] !== FilterType.RANGE) {
212212
for (const item of value) {
213213
await this.removeFilter(name as keyof TFilters & string, item);
214214
}

front/e2e/src/helper/grid.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,29 @@ export class Grid {
9595
}
9696
}
9797

98+
/**
99+
* Assert that the expected rows are present after the filters have been applied.
100+
*
101+
* @param filter - Grid's filter
102+
* @param term - The search term to input
103+
* @param expectedRow - An array of objects containing:
104+
* - columnName: the header of the column to search in
105+
* - value: the expected value in that column
106+
* @param expectedRowCount - Expected row count
107+
*/
108+
public async expectRowsAfterSearchToBe<TFilters extends Record<string, FilterType>>(
109+
filter: Filter<TFilters>,
110+
term: string,
111+
expectedRow: GridCondition[],
112+
expectedRowCount: number = 1,
113+
) {
114+
await filter.searchTerm(term)
115+
await this.pagination.expectToHaveCount(expectedRowCount)
116+
if (expectedRowCount !== 0 || expectedRow.length !== 0) {
117+
await this.expectToFindLineWhere(expectedRow)
118+
}
119+
}
120+
98121
/**
99122
* Assert that All filters have been removed.
100123
*

front/e2e/src/tests/pages/admin/merchandising/boost.spec.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,30 +111,25 @@ test('Pages > Merchandising > Boosts', {tag: ['@premium']}, async ({page}) => {
111111
const newName = randomUUID()
112112

113113
await test.step('Verify grid headers and pagination', async () => {
114-
await grid.expectHeadersToBe(Object.values(texts.gridHeaders))
114+
await grid.expectHeadersAndPaginationTobe(Object.values(texts.gridHeaders))
115115
})
116116

117117
await test.step('Add some filters and remove them', async () => {
118118
const defaultRowCount = await grid.getCountLines()
119+
const applicableFilters = {
120+
[testIds.filter.name]: texts.filtersToApply.name,
121+
[testIds.filter.model]: texts.filtersToApply.model,
122+
[testIds.filter.requestType]: texts.filtersToApply.requestType,
123+
[testIds.filter.isActive]: texts.filtersToApply.isActive,
124+
[testIds.filter.localizedCatalogs]: texts.filtersToApply.localizedCatalogs,
125+
}
119126

120127
await test.step('Apply all filters available', async () => {
121-
await filter.addFilters({
122-
[testIds.filter.name]: texts.filtersToApply.name,
123-
[testIds.filter.model]: texts.filtersToApply.model,
124-
[testIds.filter.requestType]: texts.filtersToApply.requestType,
125-
[testIds.filter.isActive]: true,
126-
[testIds.filter.localizedCatalogs]: texts.filtersToApply.localizedCatalogs,
127-
})
128+
await filter.addFilters(applicableFilters)
128129
})
129130

130131
await test.step('Remove applied filters one by one', async () => {
131-
await filter.removeFilters({
132-
[testIds.filter.name]: texts.filtersToApply.name,
133-
[testIds.filter.model]: texts.filtersToApply.model,
134-
[testIds.filter.requestType]: texts.filtersToApply.requestType,
135-
[testIds.filter.isActive]: texts.filtersToApply.isActive,
136-
[testIds.filter.localizedCatalogs]: texts.filtersToApply.localizedCatalogs,
137-
})
132+
await filter.removeFilters(applicableFilters)
138133
})
139134

140135
await test.step('Apply a filter and compare the grid to see if it works', async () => {

front/e2e/src/tests/pages/admin/merchandising/category.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const texts = {
3535
'COM Catalog', 'FR Catalog', 'UK Catalog'
3636
],
3737
locales: ['French (France)', 'English (United States)'],
38-
paginationOptions: ['10', '25', '50'],
3938
productToSearch: 'Gold Omni Bangle Set',
4039
allCatalog: "All catalog",
4140
allLocales: "All locales",
@@ -103,9 +102,7 @@ async function testCategoriesPage(page: Page, gallyPackage: GallyPackage): Promi
103102
const pageTitle = page.getByTestId(generateTestId(TestId.PAGE_TITLE, 'categoriesProducts')).locator('h1')
104103

105104
await test.step('Verify grid headers, pagination and searchBar', async () => {
106-
await grid.expectHeadersToBe(Object.values(texts.gridHeaders))
107-
await grid.pagination.expectToHaveOptions(texts.paginationOptions)
108-
await grid.pagination.expectToHaveRowsPerPage(50)
105+
await grid.expectHeadersAndPaginationTobe(Object.values(texts.gridHeaders))
109106
await grid.pagination.changeRowsPerPage(10)
110107
const nextPage = await grid.pagination.goToNextPage()
111108
await expect(nextPage).toBe(true)

front/e2e/src/tests/pages/admin/merchandising/recommenders/autoRecommender.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ test('Pages > Merchandising > Boosts', {tag: ['@premium']}, async ({page}) => {
105105
const newName = randomUUID()
106106

107107
await test.step('Verify grid headers and pagination', async () => {
108-
await grid.expectHeadersToBe(Object.values(texts.gridHeaders))
108+
await grid.expectHeadersAndPaginationTobe(Object.values(texts.gridHeaders))
109109
})
110110

111111
await test.step('Add some filters and remove them', async () => {

front/e2e/src/tests/pages/admin/merchandising/recommenders/recommenderType.spec.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ const testIds = {
1414
grid: generateTestId(TestId.TABLE, resourceName),
1515
filter: {
1616
name: 'name',
17+
code: 'code'
1718
},
1819
form: {
1920
... getCommonFormTestIds(resourceName),
2021
name: generateTestId(TestId.INPUT_TEXT, 'name'),
22+
code: generateTestId(TestId.INPUT_TEXT, 'code'),
2123
},
2224
... Grid.getCommonGridTestIds(resourceName)
2325
} as const
@@ -26,27 +28,12 @@ const texts = {
2628
labelMenuPage: 'Recommender types',
2729
gridHeaders: {
2830
name: 'Name',
31+
code: 'Code',
2932
actions: 'Actions'
3033
},
3134
filtersToApply: {
3235
name: 'Default',
33-
},
34-
createValues: {
35-
localizedCatalogs: [
36-
'COM French Catalog',
37-
'COM English Catalog',
38-
'FR French Catalog',
39-
'EN French Catalog',
40-
],
41-
requestType: [
42-
'Category listing',
43-
'Search result',
44-
],
45-
model: 'Constant score'
46-
},
47-
editValues: {
48-
localizedCatalogs: ['COM French Catalog'],
49-
editedLocalizedCatalogDisplay: 'COM Catalog - COM French Catalog',
36+
code: 'default',
5037
},
5138
} as const
5239

@@ -66,16 +53,19 @@ test('Pages > Merchandising > Recommenders > Recommender Types', {tag: ['@premiu
6653
const grid = new Grid(page, resourceName)
6754
const filter = new Filter(page, resourceName, {
6855
[testIds.filter.name]: FilterType.TEXT,
56+
[testIds.filter.code]: FilterType.TEXT,
6957
})
7058
const createButton = page.getByTestId(testIds.createButton)
7159

7260
// Form Locators (Edit / Create):
7361
const nameInput = page.getByTestId(testIds.form.name)
62+
const codeInput = page.getByTestId(testIds.form.code)
7463
const saveButton = page.getByTestId(testIds.form.submitButton)
7564

7665
// Define a name for the new created Entity.
7766
const newName = randomUUID()
7867
const newNameCreation = `${newName}_created`
68+
const newCode = `${newName}_code`
7969

8070
await test.step('Verify grid headers and pagination', async () => {
8171
await grid.expectHeadersToBe(Object.values(texts.gridHeaders))
@@ -87,12 +77,14 @@ test('Pages > Merchandising > Recommenders > Recommender Types', {tag: ['@premiu
8777
await test.step('Apply all filters available', async () => {
8878
await filter.addFilters({
8979
[testIds.filter.name]: texts.filtersToApply.name,
80+
[testIds.filter.code]: texts.filtersToApply.code,
9081
})
9182
})
9283

9384
await test.step('Remove applied filters one by one', async () => {
9485
await filter.removeFilters({
9586
[testIds.filter.name]: texts.filtersToApply.name,
87+
[testIds.filter.code]: texts.filtersToApply.code,
9688
})
9789
})
9890

@@ -113,6 +105,7 @@ test('Pages > Merchandising > Recommenders > Recommender Types', {tag: ['@premiu
113105
await createButton.click()
114106
await expect(page).toHaveURL(urls.create)
115107
await nameInput.fill(newNameCreation)
108+
await codeInput.fill(newCode)
116109
// Create the Entity
117110
await saveButton.click()
118111
await expect(page).toHaveURL(urls.grid)

front/e2e/src/tests/pages/admin/search/configuration/attributes.spec.ts

Lines changed: 48 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const texts = {
3939
isSpannable: 'Use for span queries',
4040
defaultSearchAnalyzer: 'Analyzer',
4141
},
42-
paginationOptions: ['10', '25', '50'],
4342
filtersToApply: {
4443
code: 'sku',
4544
weight: ['10'],
@@ -76,90 +75,66 @@ test('Pages > Search > Configurations > Attributes', {tag: ['@premium', '@standa
7675
await entityDropdown.expectToHaveValue('Product')
7776

7877
await test.step('Verify grid headers and pagination', async () => {
79-
await grid.expectHeadersToBe(Object.values(texts.gridHeaders))
80-
await grid.pagination.expectToHaveOptions(texts.paginationOptions)
81-
await grid.pagination.expectToHaveRowsPerPage(50)
78+
await grid.expectHeadersAndPaginationTobe(Object.values(texts.gridHeaders))
8279
await grid.pagination.changeRowsPerPage(10)
8380
const nextPage = await grid.pagination.goToNextPage()
8481
await expect(nextPage).toBe(true)
8582
})
8683

8784
await test.step('Add some filters and remove them', async () => {
88-
await filter.addFilter(testIds.filter.code, texts.filtersToApply.code)
89-
await filter.addFilter(
90-
testIds.filter.defaultLabel,
91-
texts.filtersToApply.defaultLabel
92-
)
93-
await filter.addFilter(
94-
testIds.filter.isSpellchecked,
95-
texts.filtersToApply.isSpellchecked
96-
)
97-
await filter.addFilter(testIds.filter.isSpannable, texts.filtersToApply.isSpannable)
98-
await filter.addFilter(testIds.filter.weight, texts.filtersToApply.weight)
99-
await filter.addFilter(
100-
testIds.filter.defaultSearchAnalyzer,
101-
texts.filtersToApply.defaultSearchAnalyzer
102-
)
103-
104-
await filter.removeFilter(testIds.filter.code, texts.filtersToApply.code)
105-
await filter.removeFilter(
106-
testIds.filter.defaultLabel,
107-
texts.filtersToApply.defaultLabel
108-
)
109-
await filter.removeFilter(
110-
testIds.filter.isSpellchecked,
111-
texts.filtersToApply.isSpellchecked
112-
)
113-
await filter.removeFilter(
114-
testIds.filter.isSpannable,
115-
texts.filtersToApply.isSpannable
116-
)
117-
for (let i = 0; i < texts.filtersToApply.weight.length; i++) {
118-
await filter.removeFilter(
119-
testIds.filter.weight,
120-
texts.filtersToApply.weight[i]
121-
)
85+
const defaultRowCount = await grid.getCountLines()
86+
87+
const applicableFilters = {
88+
[testIds.filter.code]: texts.filtersToApply.code,
89+
[testIds.filter.defaultLabel]: texts.filtersToApply.defaultLabel,
90+
[testIds.filter.isSpellchecked]: texts.filtersToApply.isSpellchecked,
91+
[testIds.filter.isSpannable]: texts.filtersToApply.isSpannable,
92+
[testIds.filter.weight]: texts.filtersToApply.weight,
93+
[testIds.filter.defaultSearchAnalyzer]: texts.filtersToApply.defaultSearchAnalyzer,
94+
[testIds.filter.weight]: texts.filtersToApply.weight,
12295
}
123-
for (let i = 0; i < texts.filtersToApply.defaultSearchAnalyzer.length; i++) {
124-
await filter.removeFilter(
125-
testIds.filter.defaultSearchAnalyzer,
126-
texts.filtersToApply.defaultSearchAnalyzer[i]
127-
)
128-
}
129-
130-
await filter.addFilter(testIds.filter.code, texts.filtersToApply.code)
131-
await filter.addFilter(
132-
testIds.filter.defaultLabel,
133-
texts.filtersToApply.defaultLabel
134-
)
135-
136-
await grid.pagination.expectToHaveCount(1)
137-
await grid.expectToFindLineWhere([
138-
{columnName: texts.gridHeaders.code, value: texts.filtersToApply.code},
139-
])
14096

141-
await filter.clearFilters()
97+
await test.step('Apply all filters available', async () => {
98+
await filter.addFilters(applicableFilters)
99+
})
142100

143-
await grid.pagination.expectNotToHaveCount(1)
101+
await test.step('Remove applied filters one by one', async () => {
102+
await filter.removeFilters(applicableFilters)
103+
})
144104

145-
await filter.searchTerm(texts.filtersToApply.code)
146-
await grid.pagination.expectToHaveCount(1)
147-
await grid.expectToFindLineWhere([
148-
{columnName: texts.gridHeaders.code, value: texts.filtersToApply.code},
149-
])
150-
151-
await filter.clearFilters()
152-
await grid.pagination.expectNotToHaveCount(1)
105+
await test.step('Apply a filter and compare the grid to see if it works', async () => {
106+
await grid.expectRowsToBe(
107+
filter,
108+
{[testIds.filter.defaultLabel]: texts.filtersToApply.defaultLabel},
109+
[{columnName: texts.gridHeaders.code, value: texts.filtersToApply.code}]
110+
)
111+
})
153112

154-
await filter.searchTerm(texts.filtersToApply.searchTermCategory)
155-
await grid.pagination.expectToHaveCount(1)
113+
await test.step('Clear filter', async () => {
114+
await grid.expectAllFiltersRemoved(filter, defaultRowCount)
115+
})
156116

157-
await grid.expectToFindLineWhere([
158-
{
159-
columnName: texts.gridHeaders.defaultLabel,
160-
value: texts.filtersToApply.searchTermCategory,
161-
},
162-
])
117+
await test.step(`Search in the grid '${texts.filtersToApply.code}'`, async () => {
118+
await grid.expectRowsAfterSearchToBe(
119+
filter,
120+
texts.filtersToApply.code,
121+
[{columnName: texts.gridHeaders.code, value: texts.filtersToApply.code}]
122+
)
123+
await grid.expectAllFiltersRemoved(filter, defaultRowCount)
124+
})
125+
126+
await test.step(`Search in the grid '${texts.filtersToApply.searchTermCategory}'`, async () => {
127+
await grid.expectRowsAfterSearchToBe(
128+
filter,
129+
texts.filtersToApply.searchTermCategory,
130+
[
131+
{
132+
columnName: texts.gridHeaders.defaultLabel,
133+
value: texts.filtersToApply.searchTermCategory,
134+
},
135+
]
136+
)
137+
})
163138
})
164139

165140
await test.step('Verify that fields in the grid are editable', async () => {

0 commit comments

Comments
 (0)