playwright-ag-grid 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +387 -0
- package/package.json +41 -0
- package/playwright.config.js +21 -0
- package/src/index.d.ts +33 -0
- package/src/index.js +393 -0
- package/test-results/.last-run.json +4 -0
- package/tests/ag-grid-animation-wait.v35.spec.js +52 -0
- package/tests/ag-grid-data.v33.spec.js +6 -0
- package/tests/ag-grid-data.v34.spec.js +6 -0
- package/tests/ag-grid-data.v35.spec.js +6 -0
- package/tests/ag-grid-elements.v33.spec.js +6 -0
- package/tests/ag-grid-elements.v34.spec.js +6 -0
- package/tests/ag-grid-elements.v35.spec.js +6 -0
- package/tests/server.mjs +47 -0
- package/tests/shared/fixtures.js +109 -0
- package/tests/shared/run-ag-grid-data-suite.js +598 -0
- package/tests/shared/run-ag-grid-elements-suite.js +49 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
import { expect, test } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
import { createAgGrid, filterOperator, sort } from "../../src/index.js";
|
|
4
|
+
import {
|
|
5
|
+
agGridSelector,
|
|
6
|
+
cardataFixture,
|
|
7
|
+
clone,
|
|
8
|
+
expectRowsSubset,
|
|
9
|
+
expectedFirstPageTableData,
|
|
10
|
+
expectedPaginatedTableData,
|
|
11
|
+
getSortedMileage,
|
|
12
|
+
pageSize,
|
|
13
|
+
removePropertyFromCollection,
|
|
14
|
+
sortedCollectionByProperty,
|
|
15
|
+
} from "./fixtures.js";
|
|
16
|
+
|
|
17
|
+
async function enableMileageNumberFilter(page, floatingFilter = false) {
|
|
18
|
+
await page.evaluate(({ field, filter, floatingFilterValue, hide }) => {
|
|
19
|
+
window.setColumnFilter(field, filter, floatingFilterValue, hide);
|
|
20
|
+
}, {
|
|
21
|
+
field: "mileage",
|
|
22
|
+
filter: "agNumberColumnFilter",
|
|
23
|
+
floatingFilterValue: floatingFilter,
|
|
24
|
+
hide: false,
|
|
25
|
+
});
|
|
26
|
+
await page.locator(".ag-cell").first().waitFor({ state: "visible" });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function validatePaginatedTable(page, grid, expectedPages, options) {
|
|
30
|
+
for (let index = 0; index < expectedPages.length; index += 1) {
|
|
31
|
+
await expect(await grid.getData(options)).toEqual(expectedPages[index]);
|
|
32
|
+
if (index < expectedPages.length - 1) {
|
|
33
|
+
await page.locator(`${agGridSelector} .ag-icon-next`).click();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function sortRowsByMileage(rows) {
|
|
39
|
+
return clone(rows).sort((a, b) => Number(a.Mileage) - Number(b.Mileage));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function runAgGridDataSuite({ pagePath, versionLabel }) {
|
|
43
|
+
test.describe(`playwright ag-grid data scenarios (${versionLabel})`, () => {
|
|
44
|
+
test.beforeEach(async ({ page }) => {
|
|
45
|
+
await page.goto(pagePath);
|
|
46
|
+
await expect(page.locator(".example-version")).toContainText(`AG Grid ${versionLabel}`);
|
|
47
|
+
await page.locator(".ag-cell").first().waitFor({ state: "visible" });
|
|
48
|
+
await page.locator("#floating").click();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("verify paginated table data - any order - include all columns", async ({ page }) => {
|
|
52
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
53
|
+
await validatePaginatedTable(page, grid, expectedPaginatedTableData);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("verify paginated table data - exact order - include all columns", async ({ page }) => {
|
|
57
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
58
|
+
await expect(await grid.getData()).toEqual(expectedPaginatedTableData[0]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("verify exact order table data when columns are not in order - include all columns", async ({ page }) => {
|
|
62
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
63
|
+
await grid.pinColumn("Price", "left");
|
|
64
|
+
await expect(await grid.getData()).toEqual(expectedPaginatedTableData[0]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("verify paginated table data - excluding columns", async ({ page }) => {
|
|
68
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
69
|
+
const expectedSubset = expectedPaginatedTableData.map((pageRows) =>
|
|
70
|
+
pageRows.map(({ Year, Make, Model }) => ({ Year, Make, Model }))
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
await validatePaginatedTable(page, grid, expectedSubset, {
|
|
74
|
+
onlyColumns: ["Year", "Make", "Model"],
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("able to filter by checkbox", async ({ page }) => {
|
|
79
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
80
|
+
await grid.filterTextFloating({
|
|
81
|
+
searchCriteria: {
|
|
82
|
+
columnName: "Model",
|
|
83
|
+
filterValue: "2002",
|
|
84
|
+
},
|
|
85
|
+
selectAllLocaleText: "(Select All)",
|
|
86
|
+
hasApplyButton: true,
|
|
87
|
+
});
|
|
88
|
+
await expect(await grid.getData()).toEqual([
|
|
89
|
+
{ Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("able to filter by checkbox - multiple columns", async ({ page }) => {
|
|
94
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
95
|
+
await page.locator("#nonFloating").click();
|
|
96
|
+
await grid.filterCheckboxMenu({
|
|
97
|
+
searchCriteria: [
|
|
98
|
+
{ columnName: "Model", filterValue: "2002" },
|
|
99
|
+
{ columnName: "Model", filterValue: "3-series" },
|
|
100
|
+
],
|
|
101
|
+
hasApplyButton: true,
|
|
102
|
+
});
|
|
103
|
+
await expect(await grid.getData()).toEqual([
|
|
104
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
|
|
105
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
|
|
106
|
+
{ Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
|
|
107
|
+
]);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("able to filter by text - menu", async ({ page }) => {
|
|
111
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
112
|
+
await grid.sortColumn("Model", sort.ascending);
|
|
113
|
+
await grid.filterTextMenu({
|
|
114
|
+
searchCriteria: {
|
|
115
|
+
columnName: "Price",
|
|
116
|
+
filterValue: "32000",
|
|
117
|
+
operator: filterOperator.equals,
|
|
118
|
+
},
|
|
119
|
+
hasApplyButton: true,
|
|
120
|
+
});
|
|
121
|
+
await expect(await grid.getData()).toEqual([
|
|
122
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
|
|
123
|
+
{ Year: "2020", Make: "Honda", Model: "Accord", Condition: "poor", Price: "32000" },
|
|
124
|
+
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
|
|
125
|
+
]);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("able to filter by text - menu - multiple columns", async ({ page }) => {
|
|
129
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
130
|
+
await page.locator("#nonFloating").click();
|
|
131
|
+
await grid.sortColumn("Model", sort.ascending);
|
|
132
|
+
await grid.filterTextMenu({
|
|
133
|
+
searchCriteria: [
|
|
134
|
+
{
|
|
135
|
+
columnName: "Price",
|
|
136
|
+
filterValue: "32000",
|
|
137
|
+
operator: filterOperator.equals,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
columnName: "Make",
|
|
141
|
+
filterValue: "BMW",
|
|
142
|
+
operator: filterOperator.equals,
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
hasApplyButton: true,
|
|
146
|
+
});
|
|
147
|
+
await expect(await grid.getData()).toEqual([
|
|
148
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
|
|
149
|
+
]);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test("able to filter by text - menu - contains operator", async ({ page }) => {
|
|
153
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
154
|
+
await grid.sortColumn("Model", sort.ascending);
|
|
155
|
+
await grid.filterTextFloating({
|
|
156
|
+
searchCriteria: {
|
|
157
|
+
columnName: "Make",
|
|
158
|
+
filterValue: "ord",
|
|
159
|
+
operator: filterOperator.contains,
|
|
160
|
+
},
|
|
161
|
+
hasApplyButton: true,
|
|
162
|
+
});
|
|
163
|
+
await expect(await grid.getData()).toEqual([
|
|
164
|
+
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
|
|
165
|
+
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "good", Price: "25000" },
|
|
166
|
+
{ Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
|
|
167
|
+
{ Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
|
|
168
|
+
]);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("able to filter by text - menu - does not contain operator", async ({ page }) => {
|
|
172
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
173
|
+
await grid.filterTextFloating({
|
|
174
|
+
searchCriteria: {
|
|
175
|
+
columnName: "Make",
|
|
176
|
+
filterValue: "ord",
|
|
177
|
+
operator: filterOperator.notContains,
|
|
178
|
+
},
|
|
179
|
+
hasApplyButton: true,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const actualTableData = await grid.getData();
|
|
183
|
+
expect(actualTableData.length).toBeGreaterThan(0);
|
|
184
|
+
for (const row of actualTableData) {
|
|
185
|
+
expect(row.Make).not.toContain("ord");
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test("able to filter by text - menu - does not equal operator", async ({ page }) => {
|
|
190
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
191
|
+
await grid.filterTextFloating({
|
|
192
|
+
searchCriteria: {
|
|
193
|
+
columnName: "Make",
|
|
194
|
+
filterValue: "Ford",
|
|
195
|
+
operator: filterOperator.notEquals,
|
|
196
|
+
},
|
|
197
|
+
hasApplyButton: true,
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const actualTableData = await grid.getData();
|
|
201
|
+
expect(actualTableData.length).toBeGreaterThan(0);
|
|
202
|
+
for (const row of actualTableData) {
|
|
203
|
+
expect(row.Make).not.toBe("Ford");
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test("able to filter by text - menu - less than operator", async ({ page }) => {
|
|
208
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
209
|
+
await enableMileageNumberFilter(page);
|
|
210
|
+
await grid.filterTextMenu({
|
|
211
|
+
searchCriteria: {
|
|
212
|
+
columnName: "Mileage",
|
|
213
|
+
filterValue: "5000",
|
|
214
|
+
operator: filterOperator.lessThan,
|
|
215
|
+
},
|
|
216
|
+
hasApplyButton: true,
|
|
217
|
+
});
|
|
218
|
+
expect(getSortedMileage(await grid.getData())).toEqual(["250", "1000", "3500", "4500"]);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test("able to filter by text - menu - less than or equal operator", async ({ page }) => {
|
|
222
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
223
|
+
await enableMileageNumberFilter(page);
|
|
224
|
+
await grid.filterTextMenu({
|
|
225
|
+
searchCriteria: {
|
|
226
|
+
columnName: "Mileage",
|
|
227
|
+
filterValue: "5000",
|
|
228
|
+
operator: filterOperator.lessThanOrEquals,
|
|
229
|
+
},
|
|
230
|
+
hasApplyButton: true,
|
|
231
|
+
});
|
|
232
|
+
expect(getSortedMileage(await grid.getData())).toEqual(["250", "1000", "3500", "4500", "5000"]);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test("able to filter by text - menu - greater than operator", async ({ page }) => {
|
|
236
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
237
|
+
await enableMileageNumberFilter(page);
|
|
238
|
+
await grid.filterTextMenu({
|
|
239
|
+
searchCriteria: {
|
|
240
|
+
columnName: "Mileage",
|
|
241
|
+
filterValue: "50000",
|
|
242
|
+
operator: filterOperator.greaterThan,
|
|
243
|
+
},
|
|
244
|
+
hasApplyButton: true,
|
|
245
|
+
});
|
|
246
|
+
expect(getSortedMileage(await grid.getData())).toEqual(["52000", "60000", "70000", "90000"]);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("able to filter by text - menu - greater than or equal operator", async ({ page }) => {
|
|
250
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
251
|
+
await enableMileageNumberFilter(page);
|
|
252
|
+
await grid.filterTextMenu({
|
|
253
|
+
searchCriteria: {
|
|
254
|
+
columnName: "Mileage",
|
|
255
|
+
filterValue: "50000",
|
|
256
|
+
operator: filterOperator.greaterThanOrEquals,
|
|
257
|
+
},
|
|
258
|
+
hasApplyButton: true,
|
|
259
|
+
});
|
|
260
|
+
expect(getSortedMileage(await grid.getData())).toEqual(["52000", "60000", "70000", "90000"]);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test("able to filter by text - floating filter", async ({ page }) => {
|
|
264
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
265
|
+
await grid.sortColumn("Model", sort.ascending);
|
|
266
|
+
await grid.filterTextFloating({
|
|
267
|
+
searchCriteria: {
|
|
268
|
+
columnName: "Make",
|
|
269
|
+
filterValue: "Ford",
|
|
270
|
+
},
|
|
271
|
+
hasApplyButton: true,
|
|
272
|
+
});
|
|
273
|
+
await expect(await grid.getData()).toEqual([
|
|
274
|
+
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
|
|
275
|
+
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "good", Price: "25000" },
|
|
276
|
+
{ Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
|
|
277
|
+
{ Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
|
|
278
|
+
]);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test("able to filter by text - floating filter - multiple conditions", async ({ page }) => {
|
|
282
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
283
|
+
await grid.sortColumn("Model", sort.ascending);
|
|
284
|
+
await grid.filterTextFloating({
|
|
285
|
+
searchCriteria: {
|
|
286
|
+
columnName: "Make",
|
|
287
|
+
filterValue: "B",
|
|
288
|
+
searchInputIndex: 0,
|
|
289
|
+
},
|
|
290
|
+
hasApplyButton: true,
|
|
291
|
+
});
|
|
292
|
+
await grid.filterTextFloating({
|
|
293
|
+
searchCriteria: {
|
|
294
|
+
columnName: "Make",
|
|
295
|
+
filterValue: "MW",
|
|
296
|
+
searchInputIndex: 1,
|
|
297
|
+
},
|
|
298
|
+
hasApplyButton: true,
|
|
299
|
+
});
|
|
300
|
+
await expect(await grid.getData()).toEqual([
|
|
301
|
+
{ Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
|
|
302
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
|
|
303
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
|
|
304
|
+
]);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test("able to filter by text - floating filter - multiple columns", async ({ page }) => {
|
|
308
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
309
|
+
await grid.sortColumn("Model", sort.ascending);
|
|
310
|
+
await grid.filterTextFloating({
|
|
311
|
+
searchCriteria: [
|
|
312
|
+
{ columnName: "Make", filterValue: "Ford" },
|
|
313
|
+
{ columnName: "Year", filterValue: "1990" },
|
|
314
|
+
],
|
|
315
|
+
hasApplyButton: true,
|
|
316
|
+
});
|
|
317
|
+
await expect(await grid.getData()).toEqual([
|
|
318
|
+
{ Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
|
|
319
|
+
]);
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
test("able to filter by text - floating filter - between operator", async ({ page }) => {
|
|
323
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
324
|
+
await enableMileageNumberFilter(page, true);
|
|
325
|
+
await grid.filterTextFloating({
|
|
326
|
+
searchCriteria: [
|
|
327
|
+
{
|
|
328
|
+
columnName: "Mileage",
|
|
329
|
+
filterValue: "0",
|
|
330
|
+
operator: filterOperator.inRange,
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
columnName: "Mileage",
|
|
334
|
+
filterValue: "5000",
|
|
335
|
+
operator: filterOperator.inRange,
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
hasApplyButton: true,
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const expectedTableData = [
|
|
342
|
+
{ Year: "2023", Make: "Hyundai", Model: "Santa Fe", Condition: "excellent", Mileage: "250", Price: "" },
|
|
343
|
+
{ Year: "2020", Make: "Porsche", Model: "Boxter", Condition: "good", Mileage: "1000", Price: "99000" },
|
|
344
|
+
{ Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "fair", Mileage: "3500", Price: "3000" },
|
|
345
|
+
{ Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Mileage: "4500", Price: "88001" },
|
|
346
|
+
];
|
|
347
|
+
|
|
348
|
+
expect(sortRowsByMileage(await grid.getData())).toEqual(sortRowsByMileage(expectedTableData));
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
test("able to filter by text - floating filter - between operator with explicit indexes", async ({ page }) => {
|
|
352
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
353
|
+
await enableMileageNumberFilter(page, true);
|
|
354
|
+
|
|
355
|
+
if (versionLabel === "v33") {
|
|
356
|
+
await grid.filterTextFloating({
|
|
357
|
+
searchCriteria: [
|
|
358
|
+
{
|
|
359
|
+
columnName: "Mileage",
|
|
360
|
+
filterValue: "0",
|
|
361
|
+
operator: filterOperator.inRange,
|
|
362
|
+
searchInputIndex: 0,
|
|
363
|
+
operatorIndex: 0,
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
columnName: "Mileage",
|
|
367
|
+
filterValue: "5000",
|
|
368
|
+
operator: filterOperator.inRange,
|
|
369
|
+
searchInputIndex: 1,
|
|
370
|
+
operatorIndex: 0,
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
hasApplyButton: true,
|
|
374
|
+
});
|
|
375
|
+
} else {
|
|
376
|
+
await grid.filterTextFloating({
|
|
377
|
+
searchCriteria: {
|
|
378
|
+
columnName: "Mileage",
|
|
379
|
+
filterValue: "0",
|
|
380
|
+
operator: filterOperator.inRange,
|
|
381
|
+
searchInputIndex: 0,
|
|
382
|
+
operatorIndex: 0,
|
|
383
|
+
},
|
|
384
|
+
hasApplyButton: true,
|
|
385
|
+
});
|
|
386
|
+
await grid.filterTextFloating({
|
|
387
|
+
searchCriteria: {
|
|
388
|
+
columnName: "Mileage",
|
|
389
|
+
filterValue: "5000",
|
|
390
|
+
operator: filterOperator.inRange,
|
|
391
|
+
searchInputIndex: 1,
|
|
392
|
+
operatorIndex: 0,
|
|
393
|
+
},
|
|
394
|
+
hasApplyButton: true,
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
expect(getSortedMileage(await grid.getData())).toEqual(["250", "1000", "3500", "4500"]);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
test("able to filter by text - floating filter - between operator with mixed criteria", async ({ page }) => {
|
|
402
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
403
|
+
await enableMileageNumberFilter(page, true);
|
|
404
|
+
await grid.filterTextFloating({
|
|
405
|
+
searchCriteria: [
|
|
406
|
+
{
|
|
407
|
+
columnName: "Mileage",
|
|
408
|
+
filterValue: "0",
|
|
409
|
+
operator: filterOperator.inRange,
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
columnName: "Mileage",
|
|
413
|
+
filterValue: "500",
|
|
414
|
+
operator: filterOperator.inRange,
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
columnName: "Make",
|
|
418
|
+
filterValue: "Ford",
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
hasApplyButton: true,
|
|
422
|
+
});
|
|
423
|
+
await expect(await grid.getData()).toEqual([]);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
test("able to filter by text - floating filter - between operator without apply button", async ({ page }) => {
|
|
427
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
428
|
+
await enableMileageNumberFilter(page, true);
|
|
429
|
+
await grid.filterTextFloating({
|
|
430
|
+
searchCriteria: [
|
|
431
|
+
{
|
|
432
|
+
columnName: "Mileage",
|
|
433
|
+
filterValue: "0",
|
|
434
|
+
operator: filterOperator.inRange,
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
columnName: "Mileage",
|
|
438
|
+
filterValue: "5000",
|
|
439
|
+
operator: filterOperator.inRange,
|
|
440
|
+
},
|
|
441
|
+
],
|
|
442
|
+
hasApplyButton: false,
|
|
443
|
+
noMenuTabs: true,
|
|
444
|
+
});
|
|
445
|
+
expect(getSortedMileage(await grid.getData())).toEqual(["250", "1000", "3500", "4500"]);
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
test("able to filter by text - floating filter - multi filter", async ({ page }) => {
|
|
449
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
450
|
+
await grid.sortColumn("Model", sort.ascending);
|
|
451
|
+
await grid.filterTextFloating({
|
|
452
|
+
searchCriteria: [
|
|
453
|
+
{
|
|
454
|
+
columnName: "Model",
|
|
455
|
+
filterValue: "Taurus",
|
|
456
|
+
isMultiFilter: true,
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
hasApplyButton: true,
|
|
460
|
+
});
|
|
461
|
+
await expect(await grid.getData()).toEqual([
|
|
462
|
+
{ Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
|
|
463
|
+
{ Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
|
|
464
|
+
]);
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
test("able to validate empty table", async ({ page }) => {
|
|
468
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
469
|
+
await grid.filterTextMenu({
|
|
470
|
+
searchCriteria: {
|
|
471
|
+
columnName: "Price",
|
|
472
|
+
filterValue: "0",
|
|
473
|
+
operator: filterOperator.equals,
|
|
474
|
+
},
|
|
475
|
+
hasApplyButton: true,
|
|
476
|
+
});
|
|
477
|
+
await expect(await grid.getData()).toEqual([]);
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
test("able to sort by ascending order", async ({ page }) => {
|
|
481
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
482
|
+
await grid.sortColumn("Make", sort.ascending);
|
|
483
|
+
const expectedDataSortedByAscending = sortedCollectionByProperty(
|
|
484
|
+
removePropertyFromCollection(cardataFixture, ["Mileage"]),
|
|
485
|
+
"Make",
|
|
486
|
+
sort.ascending,
|
|
487
|
+
pageSize
|
|
488
|
+
);
|
|
489
|
+
await expect(await grid.getData()).toEqual(expectedDataSortedByAscending);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
test("able to sort by descending order", async ({ page }) => {
|
|
493
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
494
|
+
await grid.sortColumn("Make", sort.descending);
|
|
495
|
+
const expectedDataSortedByDescending = sortedCollectionByProperty(
|
|
496
|
+
removePropertyFromCollection(cardataFixture, ["Mileage"]),
|
|
497
|
+
"Make",
|
|
498
|
+
sort.descending,
|
|
499
|
+
pageSize
|
|
500
|
+
);
|
|
501
|
+
await expect(await grid.getData()).toEqual(expectedDataSortedByDescending);
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
test("remove column from grid and verify select column data", async ({ page }) => {
|
|
505
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
506
|
+
await grid.toggleColumnFromSideBar("Year", true);
|
|
507
|
+
const expectedData = removePropertyFromCollection(
|
|
508
|
+
removePropertyFromCollection(cardataFixture, ["Mileage"]),
|
|
509
|
+
["Year"]
|
|
510
|
+
).slice(0, pageSize);
|
|
511
|
+
await expect(await grid.getData()).toEqual(expectedData);
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
test("remove single pinned column from grid and verify select column data", async ({ page }) => {
|
|
515
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
516
|
+
await grid.toggleColumnFromSideBar("Price", true);
|
|
517
|
+
const expectedData = removePropertyFromCollection(
|
|
518
|
+
removePropertyFromCollection(cardataFixture, ["Mileage"]),
|
|
519
|
+
["Price"]
|
|
520
|
+
).slice(0, pageSize);
|
|
521
|
+
await expect(await grid.getData()).toEqual(expectedData);
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
test("remove multiple columns from grid and verify select column data", async ({ page }) => {
|
|
525
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
526
|
+
await grid.toggleColumnFromSideBar("Price", true);
|
|
527
|
+
await grid.toggleColumnFromSideBar("Make", true);
|
|
528
|
+
const expectedData = removePropertyFromCollection(
|
|
529
|
+
removePropertyFromCollection(cardataFixture, ["Mileage"]),
|
|
530
|
+
["Price", "Make"]
|
|
531
|
+
).slice(0, pageSize);
|
|
532
|
+
await expect(await grid.getData()).toEqual(expectedData);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
test("only validate select column data", async ({ page }) => {
|
|
536
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
537
|
+
const actualTableData = await grid.getData({ onlyColumns: ["Year", "Make", "Model"] });
|
|
538
|
+
expectRowsSubset(expect, actualTableData, expectedFirstPageTableData.map(({ Year, Make, Model }) => ({ Year, Make, Model })));
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
test("able to filter by 'Blank'", async ({ page }) => {
|
|
542
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
543
|
+
await grid.filterTextMenu({
|
|
544
|
+
searchCriteria: {
|
|
545
|
+
columnName: "Price",
|
|
546
|
+
operator: filterOperator.blank,
|
|
547
|
+
},
|
|
548
|
+
hasApplyButton: true,
|
|
549
|
+
});
|
|
550
|
+
expectRowsSubset(expect, await grid.getData(), [
|
|
551
|
+
{ Year: "2023", Make: "Hyundai", Model: "Santa Fe", Condition: "excellent", Price: "" },
|
|
552
|
+
]);
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
test("able to filter by 'Not blank'", async ({ page }) => {
|
|
556
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
557
|
+
await grid.filterTextMenu({
|
|
558
|
+
searchCriteria: {
|
|
559
|
+
columnName: "Price",
|
|
560
|
+
operator: filterOperator.notBlank,
|
|
561
|
+
},
|
|
562
|
+
hasApplyButton: true,
|
|
563
|
+
});
|
|
564
|
+
const actualTableData = await grid.getData();
|
|
565
|
+
expect(actualTableData.length).toBeGreaterThan(0);
|
|
566
|
+
for (const row of actualTableData) {
|
|
567
|
+
expect(row.Price).not.toBe("");
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
test("able to filter by agTextColumnFilter with join operator", async ({ page }) => {
|
|
572
|
+
const grid = createAgGrid(page.locator(agGridSelector));
|
|
573
|
+
await grid.filterTextFloating({
|
|
574
|
+
searchCriteria: {
|
|
575
|
+
columnName: "Condition",
|
|
576
|
+
operator: filterOperator.startsWith,
|
|
577
|
+
filterValue: "f",
|
|
578
|
+
searchInputIndex: 0,
|
|
579
|
+
},
|
|
580
|
+
hasApplyButton: true,
|
|
581
|
+
});
|
|
582
|
+
await grid.filterTextFloating({
|
|
583
|
+
searchCriteria: {
|
|
584
|
+
columnName: "Condition",
|
|
585
|
+
operator: filterOperator.endsWith,
|
|
586
|
+
filterValue: "ir",
|
|
587
|
+
searchInputIndex: 1,
|
|
588
|
+
},
|
|
589
|
+
hasApplyButton: true,
|
|
590
|
+
});
|
|
591
|
+
expectRowsSubset(expect, await grid.getData(), [
|
|
592
|
+
{ Year: "2020", Make: "Toyota", Model: "Celica", Condition: "fair", Price: "35000" },
|
|
593
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
|
|
594
|
+
{ Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "fair", Price: "3000" },
|
|
595
|
+
]);
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { expect, test } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
import { createAgGrid, filterOperator } from "../../src/index.js";
|
|
4
|
+
import {
|
|
5
|
+
agGridElementsSelector,
|
|
6
|
+
expectedPorscheRowsAfterEditing,
|
|
7
|
+
expectedPorscheRowsBeforeEditing,
|
|
8
|
+
} from "./fixtures.js";
|
|
9
|
+
|
|
10
|
+
function expectRowsSubset(actualRows, expectedRows) {
|
|
11
|
+
for (const expectedRow of expectedRows) {
|
|
12
|
+
expect(actualRows).toContainEqual(expectedRow);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function runAgGridElementsSuite({ pagePath, versionLabel }) {
|
|
17
|
+
test.describe(`playwright ag-grid elements scenarios (${versionLabel})`, () => {
|
|
18
|
+
test.beforeEach(async ({ page }) => {
|
|
19
|
+
await page.goto(pagePath);
|
|
20
|
+
await expect(page.locator(".example-version")).toContainText(`AG Grid ${versionLabel}`);
|
|
21
|
+
await page.locator(".ag-cell").first().waitFor({ state: "visible" });
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("updates a grid cell value", async ({ page }) => {
|
|
25
|
+
const grid = createAgGrid(page.locator(agGridElementsSelector));
|
|
26
|
+
|
|
27
|
+
await grid.filterTextFloating({
|
|
28
|
+
searchCriteria: {
|
|
29
|
+
columnName: "Make",
|
|
30
|
+
filterValue: "Porsche",
|
|
31
|
+
operator: filterOperator.equals,
|
|
32
|
+
},
|
|
33
|
+
hasApplyButton: true,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
expectRowsSubset(await grid.getData(), expectedPorscheRowsBeforeEditing);
|
|
37
|
+
|
|
38
|
+
const priceCell = await grid.getCellLocator(
|
|
39
|
+
{ Make: "Porsche", Price: "72000" },
|
|
40
|
+
"Price"
|
|
41
|
+
);
|
|
42
|
+
await priceCell.dblclick();
|
|
43
|
+
await priceCell.locator("input").fill("66000");
|
|
44
|
+
await priceCell.locator("input").press("Enter");
|
|
45
|
+
|
|
46
|
+
expectRowsSubset(await grid.getData(), expectedPorscheRowsAfterEditing);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|