@rickcedwhat/playwright-smart-table 6.23.1-next.a231fb3 → 6.23.1-next.b64b66c
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/dist/engine/rowFinder.js +9 -12
- package/dist/engine/tableMapper.js +1 -2
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/plugins/index.d.ts +52 -48
- package/dist/presets/glide/index.d.ts +12 -11
- package/dist/presets/glide/viewport.js +1 -2
- package/dist/presets/rdg.d.ts +11 -14
- package/dist/smartRow.js +14 -18
- package/dist/strategies/index.d.ts +4 -4
- package/dist/strategies/pagination.d.ts +3 -3
- package/dist/strategies/sorting.js +1 -1
- package/dist/strategies/stabilization.d.ts +1 -1
- package/dist/strategies/viewport.d.ts +1 -33
- package/dist/useTable.js +10 -12
- package/dist/utils/debugUtils.js +2 -4
- package/dist/utils/loadingWait.js +1 -2
- package/dist/utils/mergeTableConfig.js +5 -6
- package/dist/utils/resolveCellLocator.js +3 -4
- package/package.json +2 -2
package/dist/engine/rowFinder.js
CHANGED
|
@@ -135,13 +135,12 @@ class RowFinder {
|
|
|
135
135
|
await (0, loadingWait_1.waitWhileTableLoading)(this.config, context, this.rootLocator.page(), 'waitForTableReady');
|
|
136
136
|
}
|
|
137
137
|
async findRows(filters = {}, options) {
|
|
138
|
-
var _a;
|
|
139
|
-
var _b, _c;
|
|
138
|
+
var _a, _b, _c;
|
|
140
139
|
const filtersRecord = filters;
|
|
141
140
|
const map = await this.tableMapper.getMap();
|
|
142
141
|
const allRows = [];
|
|
143
|
-
const effectiveMaxPages = (
|
|
144
|
-
const useBulk = (options === null || options === void 0 ? void 0 : options.useBulkPagination) === true && !!((
|
|
142
|
+
const effectiveMaxPages = (_b = (_a = options === null || options === void 0 ? void 0 : options.maxPages) !== null && _a !== void 0 ? _a : this.config.maxPages) !== null && _b !== void 0 ? _b : Infinity;
|
|
143
|
+
const useBulk = (options === null || options === void 0 ? void 0 : options.useBulkPagination) === true && !!((_c = this.config.strategies.pagination) === null || _c === void 0 ? void 0 : _c.goNextBulk);
|
|
145
144
|
const hasPagination = !!this.config.strategies.pagination;
|
|
146
145
|
(0, debugUtils_1.logDebug)(this.config, 'verbose', `findRows: starting (maxPages=${effectiveMaxPages}, filters=${JSON.stringify(filtersRecord)})`);
|
|
147
146
|
const tracker = new elementTracker_1.ElementTracker('findRows');
|
|
@@ -155,11 +154,10 @@ class RowFinder {
|
|
|
155
154
|
config: this.config,
|
|
156
155
|
waitForReady: () => this.waitForTableReady(),
|
|
157
156
|
}, async () => {
|
|
158
|
-
var _a;
|
|
159
|
-
var _b, _c, _d;
|
|
157
|
+
var _a, _b, _c, _d;
|
|
160
158
|
let rowLocators = this.resolve(this.config.rowSelector, this.rootLocator);
|
|
161
159
|
if (Object.keys(domFilters).length > 0) {
|
|
162
|
-
rowLocators = this.filterEngine.applyFilters(rowLocators, domFilters, map, (
|
|
160
|
+
rowLocators = this.filterEngine.applyFilters(rowLocators, domFilters, map, (_a = options === null || options === void 0 ? void 0 : options.exact) !== null && _a !== void 0 ? _a : false, this.rootLocator.page(), this.rootLocator);
|
|
163
161
|
}
|
|
164
162
|
const newIndices = await tracker.getUnseenIndices(rowLocators);
|
|
165
163
|
const currentRows = await rowLocators.all();
|
|
@@ -173,7 +171,7 @@ class RowFinder {
|
|
|
173
171
|
if (loadingOutcome !== 'process') {
|
|
174
172
|
barrier === null || barrier === void 0 ? void 0 : barrier.markFinished();
|
|
175
173
|
if (loadingOutcome === 'throw') {
|
|
176
|
-
throw new Error(`[SmartTable] Row ${allRows.length} did not finish loading within ${(
|
|
174
|
+
throw new Error(`[SmartTable] Row ${allRows.length} did not finish loading within ${(_b = this.config.strategies.loading) === null || _b === void 0 ? void 0 : _b.rowLoadingTimeout}ms`);
|
|
177
175
|
}
|
|
178
176
|
continue;
|
|
179
177
|
}
|
|
@@ -204,11 +202,10 @@ class RowFinder {
|
|
|
204
202
|
return (0, smartRowArray_1.createSmartRowArray)(allRows);
|
|
205
203
|
}
|
|
206
204
|
async findRowLocator(filters, options = {}) {
|
|
207
|
-
var _a;
|
|
208
|
-
var _b;
|
|
205
|
+
var _a, _b;
|
|
209
206
|
const map = await this.tableMapper.getMap();
|
|
210
|
-
const effectiveMaxPages = (
|
|
211
|
-
const useBulk = options.useBulkPagination === true && !!((
|
|
207
|
+
const effectiveMaxPages = (_a = options.maxPages) !== null && _a !== void 0 ? _a : this.config.maxPages;
|
|
208
|
+
const useBulk = options.useBulkPagination === true && !!((_b = this.config.strategies.pagination) === null || _b === void 0 ? void 0 : _b.goNextBulk);
|
|
212
209
|
let found = null;
|
|
213
210
|
(0, debugUtils_1.logDebug)(this.config, 'verbose', `Looking for row: ${JSON.stringify(filters)} (MaxPages: ${effectiveMaxPages})`);
|
|
214
211
|
await (0, scanPages_1.scanPages)({
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Generated by scripts/embed-version.mjs from package.json
|
|
4
4
|
*/
|
|
5
5
|
/** Semver of this package. Use in logs or diagnostics to confirm the installed build. */
|
|
6
|
-
export declare const PLAYWRIGHT_SMART_TABLE_VERSION: "6.23.1-next.
|
|
6
|
+
export declare const PLAYWRIGHT_SMART_TABLE_VERSION: "6.23.1-next.b64b66c";
|
package/dist/packageVersion.js
CHANGED
|
@@ -6,4 +6,4 @@ exports.PLAYWRIGHT_SMART_TABLE_VERSION = void 0;
|
|
|
6
6
|
* Generated by scripts/embed-version.mjs from package.json
|
|
7
7
|
*/
|
|
8
8
|
/** Semver of this package. Use in logs or diagnostics to confirm the installed build. */
|
|
9
|
-
exports.PLAYWRIGHT_SMART_TABLE_VERSION = "6.23.1-next.
|
|
9
|
+
exports.PLAYWRIGHT_SMART_TABLE_VERSION = "6.23.1-next.b64b66c";
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -12,24 +12,6 @@
|
|
|
12
12
|
export declare const Plugins: {
|
|
13
13
|
/** @deprecated Use `presets.rdg` */
|
|
14
14
|
RDG: {
|
|
15
|
-
headerSelector?: import("..").TableSelector;
|
|
16
|
-
rowSelector?: import("..").TableSelector;
|
|
17
|
-
cellSelector?: import("..").TableSelector;
|
|
18
|
-
maxPages?: number;
|
|
19
|
-
concurrency?: import("../types").RowIterationMode;
|
|
20
|
-
headerTransformer?: (args: {
|
|
21
|
-
text: string;
|
|
22
|
-
index: number;
|
|
23
|
-
locator: import("@playwright/test").Locator;
|
|
24
|
-
seenHeaders: Set<string>;
|
|
25
|
-
}) => string | Promise<string>;
|
|
26
|
-
autoScroll?: boolean;
|
|
27
|
-
debug?: import("..").DebugConfig;
|
|
28
|
-
onReset?: (context: import("..").TableContext) => Promise<void>;
|
|
29
|
-
strategies?: import("..").TableStrategies;
|
|
30
|
-
columnOverrides?: Partial<Record<string | number | symbol, import("..").ColumnOverride<any>>> | undefined;
|
|
31
|
-
syntheticColumns?: Record<string, import("..").SyntheticColumnDef<any>> | undefined;
|
|
32
|
-
emptyState?: import("@playwright/test").Locator;
|
|
33
15
|
Strategies: {
|
|
34
16
|
header: (context: import("..").TableContext) => Promise<string[]>;
|
|
35
17
|
getCellLocator: ({ row, columnIndex }: {
|
|
@@ -45,31 +27,36 @@ export declare const Plugins: {
|
|
|
45
27
|
};
|
|
46
28
|
pagination: import("..").PaginationPrimitives;
|
|
47
29
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
maxPages?: number;
|
|
55
|
-
concurrency?: import("../types").RowIterationMode;
|
|
56
|
-
headerTransformer?: (args: {
|
|
30
|
+
headerSelector?: import("..").TableSelector | undefined;
|
|
31
|
+
rowSelector?: import("..").TableSelector | undefined;
|
|
32
|
+
cellSelector?: import("..").TableSelector | undefined;
|
|
33
|
+
maxPages?: number | undefined;
|
|
34
|
+
concurrency?: import("../types").RowIterationMode | undefined;
|
|
35
|
+
headerTransformer?: ((args: {
|
|
57
36
|
text: string;
|
|
58
37
|
index: number;
|
|
59
38
|
locator: import("@playwright/test").Locator;
|
|
60
39
|
seenHeaders: Set<string>;
|
|
61
|
-
}) => string | Promise<string
|
|
62
|
-
autoScroll?: boolean;
|
|
63
|
-
debug?: import("..").DebugConfig;
|
|
64
|
-
onReset?: (context: import("..").TableContext) => Promise<void
|
|
65
|
-
strategies?: import("..").TableStrategies;
|
|
40
|
+
}) => string | Promise<string>) | undefined;
|
|
41
|
+
autoScroll?: boolean | undefined;
|
|
42
|
+
debug?: import("..").DebugConfig | undefined;
|
|
43
|
+
onReset?: ((context: import("..").TableContext) => Promise<void>) | undefined;
|
|
44
|
+
strategies?: import("..").TableStrategies | undefined;
|
|
66
45
|
columnOverrides?: Partial<Record<string | number | symbol, import("..").ColumnOverride<any>>> | undefined;
|
|
67
46
|
syntheticColumns?: Record<string, import("..").SyntheticColumnDef<any>> | undefined;
|
|
68
|
-
emptyState?: import("@playwright/test").Locator;
|
|
47
|
+
emptyState?: import("@playwright/test").Locator | undefined;
|
|
48
|
+
};
|
|
49
|
+
/** @deprecated Use `presets.glide` */
|
|
50
|
+
Glide: {
|
|
69
51
|
Strategies: {
|
|
52
|
+
fillSimple: import("..").FillStrategy;
|
|
70
53
|
fill: import("..").FillStrategy;
|
|
71
54
|
pagination: import("..").PaginationPrimitives;
|
|
72
|
-
header:
|
|
55
|
+
header: (context: import("..").StrategyContext, options?: {
|
|
56
|
+
limit?: number;
|
|
57
|
+
selector?: string;
|
|
58
|
+
scrollAmount?: number;
|
|
59
|
+
}) => Promise<string[]>;
|
|
73
60
|
viewport: import("..").ViewportStrategy;
|
|
74
61
|
loading: {
|
|
75
62
|
isHeaderLoading: () => Promise<boolean>;
|
|
@@ -80,32 +67,49 @@ export declare const Plugins: {
|
|
|
80
67
|
columnIndex: number;
|
|
81
68
|
locator: any;
|
|
82
69
|
} | null>;
|
|
83
|
-
fillSimple: import("..").FillStrategy;
|
|
84
70
|
};
|
|
71
|
+
headerSelector?: import("..").TableSelector | undefined;
|
|
72
|
+
rowSelector?: import("..").TableSelector | undefined;
|
|
73
|
+
cellSelector?: import("..").TableSelector | undefined;
|
|
74
|
+
maxPages?: number | undefined;
|
|
75
|
+
concurrency?: import("../types").RowIterationMode | undefined;
|
|
76
|
+
headerTransformer?: ((args: {
|
|
77
|
+
text: string;
|
|
78
|
+
index: number;
|
|
79
|
+
locator: import("@playwright/test").Locator;
|
|
80
|
+
seenHeaders: Set<string>;
|
|
81
|
+
}) => string | Promise<string>) | undefined;
|
|
82
|
+
autoScroll?: boolean | undefined;
|
|
83
|
+
debug?: import("..").DebugConfig | undefined;
|
|
84
|
+
onReset?: ((context: import("..").TableContext) => Promise<void>) | undefined;
|
|
85
|
+
strategies?: import("..").TableStrategies | undefined;
|
|
86
|
+
columnOverrides?: Partial<Record<string | number | symbol, import("..").ColumnOverride<any>>> | undefined;
|
|
87
|
+
syntheticColumns?: Record<string, import("..").SyntheticColumnDef<any>> | undefined;
|
|
88
|
+
emptyState?: import("@playwright/test").Locator | undefined;
|
|
85
89
|
};
|
|
86
90
|
/**
|
|
87
91
|
* @deprecated Use `presets.muiDataGrid`.
|
|
88
92
|
* DataGrid only — for MUI `<Table>` use `presets.muiTable`.
|
|
89
93
|
*/
|
|
90
94
|
MUI: {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
Strategies: import("..").TableStrategies | undefined;
|
|
96
|
+
headerSelector?: import("..").TableSelector | undefined;
|
|
97
|
+
rowSelector?: import("..").TableSelector | undefined;
|
|
98
|
+
cellSelector?: import("..").TableSelector | undefined;
|
|
99
|
+
maxPages?: number | undefined;
|
|
100
|
+
concurrency?: import("../types").RowIterationMode | undefined;
|
|
101
|
+
headerTransformer?: ((args: {
|
|
97
102
|
text: string;
|
|
98
103
|
index: number;
|
|
99
104
|
locator: import("@playwright/test").Locator;
|
|
100
105
|
seenHeaders: Set<string>;
|
|
101
|
-
}) => string | Promise<string
|
|
102
|
-
autoScroll?: boolean;
|
|
103
|
-
debug?: import("..").DebugConfig;
|
|
104
|
-
onReset?: (context: import("..").TableContext) => Promise<void
|
|
105
|
-
strategies?: import("..").TableStrategies;
|
|
106
|
+
}) => string | Promise<string>) | undefined;
|
|
107
|
+
autoScroll?: boolean | undefined;
|
|
108
|
+
debug?: import("..").DebugConfig | undefined;
|
|
109
|
+
onReset?: ((context: import("..").TableContext) => Promise<void>) | undefined;
|
|
110
|
+
strategies?: import("..").TableStrategies | undefined;
|
|
106
111
|
columnOverrides?: Partial<Record<string | number | symbol, import("..").ColumnOverride<any>>> | undefined;
|
|
107
112
|
syntheticColumns?: Record<string, import("..").SyntheticColumnDef<any>> | undefined;
|
|
108
|
-
emptyState?: import("@playwright/test").Locator;
|
|
109
|
-
Strategies: import("..").TableStrategies | undefined;
|
|
113
|
+
emptyState?: import("@playwright/test").Locator | undefined;
|
|
110
114
|
};
|
|
111
115
|
};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { FillStrategy, TableConfig } from '../../types';
|
|
2
|
-
import { scrollRightHeader } from './headers';
|
|
3
2
|
export { createGlideViewport } from './viewport';
|
|
4
3
|
export type { GlideViewportOptions } from './viewport';
|
|
5
4
|
import { GlideViewportOptions } from './viewport';
|
|
6
|
-
declare const glideGetCellLocator: ({ row, columnIndex }: any) => any;
|
|
7
|
-
declare const glideGetActiveCell: ({ page }: any) => Promise<{
|
|
8
|
-
rowIndex: number;
|
|
9
|
-
columnIndex: number;
|
|
10
|
-
locator: any;
|
|
11
|
-
} | null>;
|
|
12
5
|
/** Strategies only for Glide Data Grid. Includes fillSimple; use when you want to supply your own selectors or override fill. */
|
|
13
6
|
export declare const GlideStrategies: {
|
|
7
|
+
fillSimple: FillStrategy;
|
|
14
8
|
fill: FillStrategy;
|
|
15
9
|
pagination: import("../..").PaginationPrimitives;
|
|
16
|
-
header:
|
|
10
|
+
header: (context: import("../..").StrategyContext, options?: {
|
|
11
|
+
limit?: number;
|
|
12
|
+
selector?: string;
|
|
13
|
+
scrollAmount?: number;
|
|
14
|
+
}) => Promise<string[]>;
|
|
17
15
|
viewport: import("../..").ViewportStrategy;
|
|
18
16
|
loading: {
|
|
19
17
|
isHeaderLoading: () => Promise<boolean>;
|
|
20
18
|
};
|
|
21
|
-
getCellLocator:
|
|
22
|
-
getActiveCell:
|
|
23
|
-
|
|
19
|
+
getCellLocator: ({ row, columnIndex }: any) => any;
|
|
20
|
+
getActiveCell: ({ page }: any) => Promise<{
|
|
21
|
+
rowIndex: number;
|
|
22
|
+
columnIndex: number;
|
|
23
|
+
locator: any;
|
|
24
|
+
} | null>;
|
|
24
25
|
};
|
|
25
26
|
/** Alias of {@link GlideViewportOptions}. All fields are forwarded to the viewport strategy. */
|
|
26
27
|
export type GlideOptions = GlideViewportOptions;
|
|
@@ -41,8 +41,7 @@ const createGlideViewport = (options = {}) => {
|
|
|
41
41
|
return { first: Math.min(...indices), last: Math.max(...indices) };
|
|
42
42
|
},
|
|
43
43
|
scrollToColumn: async (context, colIndex) => {
|
|
44
|
-
var _a;
|
|
45
|
-
var _b;
|
|
44
|
+
var _a, _b;
|
|
46
45
|
const { page } = context;
|
|
47
46
|
const scroller = page.locator('.dvn-scroller').first();
|
|
48
47
|
// Derive total column count from the initialized header map (available post-init).
|
package/dist/presets/rdg.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import type { Locator } from '@playwright/test';
|
|
2
2
|
import { TableContext, TableConfig, ViewportStrategy, StrategyContext } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Scrolls the grid horizontally to collect all column headers.
|
|
5
|
-
* Handles empty headers by labeling them (e.g. "Checkbox").
|
|
6
|
-
*/
|
|
7
|
-
declare const scrollRightHeaderRDG: (context: TableContext) => Promise<string[]>;
|
|
8
|
-
declare const rdgGetCellLocator: ({ row, columnIndex }: {
|
|
9
|
-
row: Locator;
|
|
10
|
-
columnIndex: number;
|
|
11
|
-
}) => Locator;
|
|
12
3
|
/** Full strategies for React Data Grid. Use when you want to supply your own selectors: `strategies: presets.rdg.Strategies` */
|
|
13
4
|
export declare const RDGStrategies: {
|
|
14
|
-
header:
|
|
15
|
-
getCellLocator:
|
|
5
|
+
header: (context: TableContext) => Promise<string[]>;
|
|
6
|
+
getCellLocator: ({ row, columnIndex }: {
|
|
7
|
+
row: Locator;
|
|
8
|
+
columnIndex: number;
|
|
9
|
+
}) => Locator;
|
|
16
10
|
navigation: {
|
|
17
11
|
goRight: ({ root }: StrategyContext) => Promise<void>;
|
|
18
12
|
goLeft: ({ root }: StrategyContext) => Promise<void>;
|
|
@@ -26,8 +20,12 @@ export declare const RDG: Partial<TableConfig> & {
|
|
|
26
20
|
Strategies: typeof RDGStrategies;
|
|
27
21
|
};
|
|
28
22
|
export declare const RDG2DStrategies: {
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
viewport: ViewportStrategy;
|
|
24
|
+
header: (context: TableContext) => Promise<string[]>;
|
|
25
|
+
getCellLocator: ({ row, columnIndex }: {
|
|
26
|
+
row: Locator;
|
|
27
|
+
columnIndex: number;
|
|
28
|
+
}) => Locator;
|
|
31
29
|
navigation: {
|
|
32
30
|
goRight: ({ root }: StrategyContext) => Promise<void>;
|
|
33
31
|
goLeft: ({ root }: StrategyContext) => Promise<void>;
|
|
@@ -36,7 +34,6 @@ export declare const RDG2DStrategies: {
|
|
|
36
34
|
goHome: ({ root }: StrategyContext) => Promise<void>;
|
|
37
35
|
};
|
|
38
36
|
pagination: import("..").PaginationPrimitives;
|
|
39
|
-
viewport: ViewportStrategy;
|
|
40
37
|
};
|
|
41
38
|
export declare const RDG2D: Partial<TableConfig> & {
|
|
42
39
|
Strategies: typeof RDG2DStrategies;
|
package/dist/smartRow.js
CHANGED
|
@@ -327,8 +327,7 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
327
327
|
smart._barrier = barrier;
|
|
328
328
|
// Attach Methods
|
|
329
329
|
smart.getCell = (colName) => {
|
|
330
|
-
var _a;
|
|
331
|
-
var _b;
|
|
330
|
+
var _a, _b;
|
|
332
331
|
if ((_a = config.syntheticColumns) === null || _a === void 0 ? void 0 : _a[colName]) {
|
|
333
332
|
throw new Error(`Column "${colName}" is synthetic (no DOM cell) — use getValue("${colName}") or toJSON() instead`);
|
|
334
333
|
}
|
|
@@ -394,8 +393,7 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
394
393
|
return !smart[sentinel_1.SENTINEL_ROW];
|
|
395
394
|
};
|
|
396
395
|
smart.getValue = async (colName) => {
|
|
397
|
-
var _a, _b;
|
|
398
|
-
var _c;
|
|
396
|
+
var _a, _b, _c;
|
|
399
397
|
const syntheticDef = (_a = config.syntheticColumns) === null || _a === void 0 ? void 0 : _a[colName];
|
|
400
398
|
if (syntheticDef) {
|
|
401
399
|
const guardedRow = Object.create(smart);
|
|
@@ -411,9 +409,9 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
411
409
|
}
|
|
412
410
|
const idx = map.get(colName);
|
|
413
411
|
if (idx === undefined) {
|
|
414
|
-
throw new Error((0, stringUtils_1.buildColumnNotFoundError)(colName, [...map.keys(), ...Object.keys((
|
|
412
|
+
throw new Error((0, stringUtils_1.buildColumnNotFoundError)(colName, [...map.keys(), ...Object.keys((_b = config.syntheticColumns) !== null && _b !== void 0 ? _b : {})]));
|
|
415
413
|
}
|
|
416
|
-
const columnOverride = (
|
|
414
|
+
const columnOverride = (_c = config.columnOverrides) === null || _c === void 0 ? void 0 : _c[colName];
|
|
417
415
|
const page = rootLocator.page();
|
|
418
416
|
// Same nav pipeline as toJSON / getCell().bringIntoView() (#430) so virtualized
|
|
419
417
|
// off-screen columns don't return empty/stale text.
|
|
@@ -443,8 +441,7 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
443
441
|
return (await cell.innerText()).trim();
|
|
444
442
|
};
|
|
445
443
|
smart.toJSON = async (options) => {
|
|
446
|
-
var _a, _b, _c, _d, _e, _f;
|
|
447
|
-
var _g, _h, _j;
|
|
444
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
448
445
|
// Atomic mode: snapshot the row in a single evaluate, then apply column overrides
|
|
449
446
|
// against a frozen reconstruction. Zero inter-column stagger — even in-place React
|
|
450
447
|
// re-renders can't affect it because overrides read from a detached clone.
|
|
@@ -470,7 +467,7 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
470
467
|
if (rResult !== undefined && (0, rowResolution_1.normalizeRowIndexResult)(rResult).index === rowIndex)
|
|
471
468
|
return r;
|
|
472
469
|
}
|
|
473
|
-
catch (_a) { /* element may have detached during scan */ }
|
|
470
|
+
catch ( /* element may have detached during scan */_a) { /* element may have detached during scan */ }
|
|
474
471
|
}
|
|
475
472
|
return null;
|
|
476
473
|
}
|
|
@@ -602,7 +599,7 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
602
599
|
result[col] = snapshot.cells[idx].text;
|
|
603
600
|
}
|
|
604
601
|
}
|
|
605
|
-
for (const [name, def] of Object.entries((
|
|
602
|
+
for (const [name, def] of Object.entries((_c = config.syntheticColumns) !== null && _c !== void 0 ? _c : {})) {
|
|
606
603
|
if ((options === null || options === void 0 ? void 0 : options.columns) && !options.columns.includes(name))
|
|
607
604
|
continue;
|
|
608
605
|
const snapshotRow = Object.create(smart);
|
|
@@ -701,7 +698,7 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
701
698
|
// Re-pin to the correct logical row before reading this column (#366).
|
|
702
699
|
const stableRow = await resolveStableRow();
|
|
703
700
|
// Check if we have a column override for this column
|
|
704
|
-
const columnOverride = (
|
|
701
|
+
const columnOverride = (_d = config.columnOverrides) === null || _d === void 0 ? void 0 : _d[col];
|
|
705
702
|
const mapper = columnOverride === null || columnOverride === void 0 ? void 0 : columnOverride.read;
|
|
706
703
|
// --- Navigation Logic Start ---
|
|
707
704
|
const cell = config.strategies.getCellLocator
|
|
@@ -750,13 +747,13 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
750
747
|
});
|
|
751
748
|
}
|
|
752
749
|
// Cell loading wait (if configured)
|
|
753
|
-
const isCellLoading = (
|
|
754
|
-
const rawCellTimeout = (
|
|
750
|
+
const isCellLoading = (_e = config.strategies.loading) === null || _e === void 0 ? void 0 : _e.isCellLoading;
|
|
751
|
+
const rawCellTimeout = (_f = config.strategies.loading) === null || _f === void 0 ? void 0 : _f.cellLoadingTimeout;
|
|
755
752
|
// undefined = unset (read as-is immediately); 0 = no wait (immediate check); >0 = wait up to N ms
|
|
756
753
|
const cellLoadingTimeout = rawCellTimeout !== undefined && Number.isFinite(rawCellTimeout) && rawCellTimeout >= 0
|
|
757
754
|
? rawCellTimeout
|
|
758
755
|
: undefined;
|
|
759
|
-
const onCellLoadingTimeout = (_h = (
|
|
756
|
+
const onCellLoadingTimeout = (_h = (_g = config.strategies.loading) === null || _g === void 0 ? void 0 : _g.onCellLoadingTimeout) !== null && _h !== void 0 ? _h : 'read-as-is';
|
|
760
757
|
if (isCellLoading) {
|
|
761
758
|
let loading = await isCellLoading(targetCell, col, smart);
|
|
762
759
|
// First-paint race: the cell node can attach a tick before the loading
|
|
@@ -823,8 +820,7 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
823
820
|
return result;
|
|
824
821
|
};
|
|
825
822
|
smart.smartFill = async (data, fillOptions) => {
|
|
826
|
-
var _a, _b;
|
|
827
|
-
var _c;
|
|
823
|
+
var _a, _b, _c;
|
|
828
824
|
(0, debugUtils_1.logDebug)(config, 'info', 'Filling row', data);
|
|
829
825
|
for (const [colName, value] of Object.entries(data)) {
|
|
830
826
|
if (value === undefined)
|
|
@@ -834,7 +830,7 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
834
830
|
}
|
|
835
831
|
const colIdx = map.get(colName);
|
|
836
832
|
if (colIdx === undefined) {
|
|
837
|
-
throw new Error((0, stringUtils_1.buildColumnNotFoundError)(colName, [...map.keys(), ...Object.keys((
|
|
833
|
+
throw new Error((0, stringUtils_1.buildColumnNotFoundError)(colName, [...map.keys(), ...Object.keys((_b = config.syntheticColumns) !== null && _b !== void 0 ? _b : {})]));
|
|
838
834
|
}
|
|
839
835
|
await _navigateToCell({
|
|
840
836
|
config,
|
|
@@ -849,7 +845,7 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
849
845
|
renderWindowPosition,
|
|
850
846
|
barrier: smart._barrier
|
|
851
847
|
});
|
|
852
|
-
const columnOverride = (
|
|
848
|
+
const columnOverride = (_c = config.columnOverrides) === null || _c === void 0 ? void 0 : _c[colName];
|
|
853
849
|
if (columnOverride === null || columnOverride === void 0 ? void 0 : columnOverride.write) {
|
|
854
850
|
const cellLocator = smart.getCell(colName);
|
|
855
851
|
let currentValue;
|
|
@@ -29,13 +29,13 @@ export declare const Strategies: {
|
|
|
29
29
|
}, options?: {
|
|
30
30
|
nextBulkPages?: number;
|
|
31
31
|
previousBulkPages?: number;
|
|
32
|
-
numberOfPages?: number | ((root: import(
|
|
33
|
-
detectCurrentPage?: (root: import(
|
|
32
|
+
numberOfPages?: number | ((root: import("@playwright/test").Locator) => number | Promise<number>);
|
|
33
|
+
detectCurrentPage?: (root: import("@playwright/test").Locator) => number | Promise<number>;
|
|
34
34
|
stabilization?: import("./stabilization").StabilizationStrategy;
|
|
35
35
|
timeout?: number;
|
|
36
36
|
}) => import("..").PaginationStrategy;
|
|
37
37
|
infiniteScroll: (options?: {
|
|
38
|
-
action?:
|
|
38
|
+
action?: "scroll" | "js-scroll";
|
|
39
39
|
scrollTarget?: import("..").Selector;
|
|
40
40
|
scrollAmount?: number;
|
|
41
41
|
stabilization?: import("./stabilization").StabilizationStrategy;
|
|
@@ -81,7 +81,7 @@ export declare const Strategies: {
|
|
|
81
81
|
};
|
|
82
82
|
Stabilization: {
|
|
83
83
|
contentChanged: (options?: {
|
|
84
|
-
scope?:
|
|
84
|
+
scope?: "all" | "first";
|
|
85
85
|
timeout?: number;
|
|
86
86
|
}) => import("./stabilization").StabilizationStrategy;
|
|
87
87
|
rowCountIncreased: (options?: {
|
|
@@ -19,8 +19,8 @@ export declare const PaginationStrategies: {
|
|
|
19
19
|
}, options?: {
|
|
20
20
|
nextBulkPages?: number;
|
|
21
21
|
previousBulkPages?: number;
|
|
22
|
-
numberOfPages?: number | ((root: import(
|
|
23
|
-
detectCurrentPage?: (root: import(
|
|
22
|
+
numberOfPages?: number | ((root: import("@playwright/test").Locator) => number | Promise<number>);
|
|
23
|
+
detectCurrentPage?: (root: import("@playwright/test").Locator) => number | Promise<number>;
|
|
24
24
|
stabilization?: StabilizationStrategy;
|
|
25
25
|
timeout?: number;
|
|
26
26
|
}) => PaginationStrategy;
|
|
@@ -36,7 +36,7 @@ export declare const PaginationStrategies: {
|
|
|
36
36
|
* Use `contentChanged` for virtualization.
|
|
37
37
|
*/
|
|
38
38
|
infiniteScroll: (options?: {
|
|
39
|
-
action?:
|
|
39
|
+
action?: "scroll" | "js-scroll";
|
|
40
40
|
scrollTarget?: Selector;
|
|
41
41
|
scrollAmount?: number;
|
|
42
42
|
stabilization?: StabilizationStrategy;
|
|
@@ -12,7 +12,7 @@ exports.SortingStrategies = {
|
|
|
12
12
|
*/
|
|
13
13
|
AriaSort: () => {
|
|
14
14
|
return {
|
|
15
|
-
async doSort({ columnName, context }) {
|
|
15
|
+
async doSort({ columnName, direction, context }) {
|
|
16
16
|
// getHeaderCell is always present on TableContext after table is initialized
|
|
17
17
|
const targetHeader = await context.getHeaderCell(columnName);
|
|
18
18
|
// The table engine handles verify-and-retry. We only provide the trigger here.
|
|
@@ -50,38 +50,6 @@ export type DataAttributeViewportOptions = {
|
|
|
50
50
|
*/
|
|
51
51
|
columnOffset?: number;
|
|
52
52
|
};
|
|
53
|
-
/**
|
|
54
|
-
* Viewport strategies for tables where row and cell elements carry a DOM attribute
|
|
55
|
-
* equal to their index (e.g. Braintrust logs table, TanStack-style grids).
|
|
56
|
-
*
|
|
57
|
-
* Derives selectors from the table config so no duplication is needed:
|
|
58
|
-
* - getVisibleColumnRange — reads column attribute from cells in the first visible row
|
|
59
|
-
* - getVisibleRowRange — reads row attribute from all visible row elements
|
|
60
|
-
* - scrollToColumn — aligns header's left edge to container left, waits for cell mount
|
|
61
|
-
* - scrollToRow — scrolls row into view, waits for row mount
|
|
62
|
-
*
|
|
63
|
-
* **Important:** `rowAttribute` must be present on the elements matched by `rowSelector`,
|
|
64
|
-
* not on child cells. If row elements lack the attribute, `getVisibleRowRange` returns
|
|
65
|
-
* `{first:0, last:0}` and logs a warning at the `error` log level.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* // TanStack / Braintrust — pass your scroll container explicitly (no Tailwind default)
|
|
69
|
-
* viewport: Strategies.Viewport.dataAttribute({
|
|
70
|
-
* scrollContainer: 'div[class*="overflow-auto"]',
|
|
71
|
-
* })
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* // ARIA grid (aria-rowindex / aria-colindex, 1-based)
|
|
75
|
-
* viewport: Strategies.Viewport.dataAttribute({
|
|
76
|
-
* scrollContainer: '.MuiDataGrid-virtualScroller',
|
|
77
|
-
* rowAttribute: 'aria-rowindex',
|
|
78
|
-
* columnAttribute: 'aria-colindex',
|
|
79
|
-
* rowOffset: 1,
|
|
80
|
-
* columnOffset: 1,
|
|
81
|
-
* })
|
|
82
|
-
*/
|
|
83
|
-
declare const dataAttribute: (options?: DataAttributeViewportOptions) => ViewportStrategy;
|
|
84
53
|
export declare const ViewportStrategies: {
|
|
85
|
-
dataAttribute:
|
|
54
|
+
dataAttribute: (options?: DataAttributeViewportOptions) => ViewportStrategy;
|
|
86
55
|
};
|
|
87
|
-
export {};
|
package/dist/useTable.js
CHANGED
|
@@ -38,7 +38,7 @@ const smartRowInternals_1 = require("./utils/smartRowInternals");
|
|
|
38
38
|
// Helper to safely serialize objects containing functions for logging
|
|
39
39
|
const safeStringify = (obj) => {
|
|
40
40
|
try {
|
|
41
|
-
return JSON.stringify(obj, (
|
|
41
|
+
return JSON.stringify(obj, (key, value) => {
|
|
42
42
|
if (typeof value === 'function') {
|
|
43
43
|
return '[Function]';
|
|
44
44
|
}
|
|
@@ -319,14 +319,13 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
319
319
|
return resolve(config.headerSelector, rootLocator).nth(idx);
|
|
320
320
|
},
|
|
321
321
|
countRows: async (filters, options) => {
|
|
322
|
-
var _a, _b, _c, _d;
|
|
323
|
-
var _e;
|
|
322
|
+
var _a, _b, _c, _d, _e;
|
|
324
323
|
if (tableState.empty)
|
|
325
324
|
return 0;
|
|
326
325
|
await _autoInit();
|
|
327
326
|
const filtersRecord = (filters !== null && filters !== void 0 ? filters : {});
|
|
328
327
|
const hasFilters = Object.keys(filtersRecord).length > 0;
|
|
329
|
-
const effectiveMaxPages = (
|
|
328
|
+
const effectiveMaxPages = (_a = options === null || options === void 0 ? void 0 : options.maxPages) !== null && _a !== void 0 ? _a : config.maxPages;
|
|
330
329
|
const pag = config.strategies.pagination;
|
|
331
330
|
const hasPagination = effectiveMaxPages > 1 && !!((pag === null || pag === void 0 ? void 0 : pag.goNext) || (pag === null || pag === void 0 ? void 0 : pag.goNextBulk));
|
|
332
331
|
const domFilters = {};
|
|
@@ -334,10 +333,10 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
334
333
|
const syntheticFilters = {};
|
|
335
334
|
if (hasFilters) {
|
|
336
335
|
for (const [key, value] of Object.entries(filtersRecord)) {
|
|
337
|
-
if ((
|
|
336
|
+
if ((_b = config.syntheticColumns) === null || _b === void 0 ? void 0 : _b[key]) {
|
|
338
337
|
syntheticFilters[key] = value;
|
|
339
338
|
}
|
|
340
|
-
else if ((
|
|
339
|
+
else if ((_d = (_c = config.columnOverrides) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.read) {
|
|
341
340
|
overrideFilters[key] = value;
|
|
342
341
|
}
|
|
343
342
|
else {
|
|
@@ -379,7 +378,7 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
379
378
|
return count;
|
|
380
379
|
};
|
|
381
380
|
// Wait for table to finish loading before counting
|
|
382
|
-
const isTableLoading = (
|
|
381
|
+
const isTableLoading = (_e = config.strategies.loading) === null || _e === void 0 ? void 0 : _e.isTableLoading;
|
|
383
382
|
if (isTableLoading) {
|
|
384
383
|
const ctx = createStrategyContext();
|
|
385
384
|
await (0, loadingWait_1.waitWhileTableLoading)(config, ctx, rootLocator.page(), 'countRows');
|
|
@@ -598,8 +597,7 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
598
597
|
},
|
|
599
598
|
sorting: {
|
|
600
599
|
apply: async (columnName, direction) => {
|
|
601
|
-
var _a, _b;
|
|
602
|
-
var _c, _d, _e, _f;
|
|
600
|
+
var _a, _b, _c, _d, _e, _f;
|
|
603
601
|
await _autoInit();
|
|
604
602
|
if (!config.strategies.sorting)
|
|
605
603
|
throw new Error('No sorting strategy has been configured.');
|
|
@@ -614,15 +612,15 @@ const useTable = (rootLocator, configOptions = {}) => {
|
|
|
614
612
|
}
|
|
615
613
|
await config.strategies.sorting.doSort({ columnName, direction, context });
|
|
616
614
|
if ((_a = config.strategies.loading) === null || _a === void 0 ? void 0 : _a.isTableLoading) {
|
|
617
|
-
const timeout = (
|
|
618
|
-
const poll = (
|
|
615
|
+
const timeout = (_c = (_b = config.strategies.loading.sortStabilizationTimeout) !== null && _b !== void 0 ? _b : config.strategies.loading.loadingTimeout) !== null && _c !== void 0 ? _c : 10000;
|
|
616
|
+
const poll = (_d = config.strategies.loading.sortStabilizationPollInterval) !== null && _d !== void 0 ? _d : 100;
|
|
619
617
|
await (0, loadingWait_1.waitWhileTableLoading)(config, context, rootLocator.page(), 'sorting.apply', {
|
|
620
618
|
timeout,
|
|
621
619
|
pollInterval: poll,
|
|
622
620
|
});
|
|
623
621
|
}
|
|
624
622
|
else {
|
|
625
|
-
const fallback = (_f = (
|
|
623
|
+
const fallback = (_f = (_e = config.strategies.loading) === null || _e === void 0 ? void 0 : _e.sortStabilizationFallbackDelay) !== null && _f !== void 0 ? _f : 200;
|
|
626
624
|
await rootLocator.page().waitForTimeout(fallback);
|
|
627
625
|
}
|
|
628
626
|
await (0, debugUtils_1.debugDelay)(config, 'default');
|
package/dist/utils/debugUtils.js
CHANGED
|
@@ -8,8 +8,7 @@ exports.warnIfDebugInCI = warnIfDebugInCI;
|
|
|
8
8
|
* Get delay for specific action type
|
|
9
9
|
*/
|
|
10
10
|
function getDebugDelay(config, actionType) {
|
|
11
|
-
var _a;
|
|
12
|
-
var _b, _c;
|
|
11
|
+
var _a, _b, _c;
|
|
13
12
|
if (!((_a = config.debug) === null || _a === void 0 ? void 0 : _a.slow))
|
|
14
13
|
return 0;
|
|
15
14
|
if (typeof config.debug.slow === 'number') {
|
|
@@ -30,8 +29,7 @@ async function debugDelay(config, actionType) {
|
|
|
30
29
|
* Log debug message based on log level
|
|
31
30
|
*/
|
|
32
31
|
function logDebug(config, level, message, data) {
|
|
33
|
-
var _a;
|
|
34
|
-
var _b;
|
|
32
|
+
var _a, _b;
|
|
35
33
|
const logLevel = (_b = (_a = config.debug) === null || _a === void 0 ? void 0 : _a.logLevel) !== null && _b !== void 0 ? _b : 'none';
|
|
36
34
|
const levels = { none: 0, error: 1, info: 2, verbose: 3 };
|
|
37
35
|
if (levels[logLevel] >= levels[level]) {
|
|
@@ -12,8 +12,7 @@ const debugUtils_1 = require("./debugUtils");
|
|
|
12
12
|
* 3. 10_000 ms default
|
|
13
13
|
*/
|
|
14
14
|
async function waitWhileTableLoading(config, context, page, label, options) {
|
|
15
|
-
var _a;
|
|
16
|
-
var _b, _c, _d, _e;
|
|
15
|
+
var _a, _b, _c, _d, _e;
|
|
17
16
|
const isTableLoading = (_a = config.strategies.loading) === null || _a === void 0 ? void 0 : _a.isTableLoading;
|
|
18
17
|
if (!isTableLoading)
|
|
19
18
|
return;
|
|
@@ -22,8 +22,7 @@ exports.mergeTableConfig = mergeTableConfig;
|
|
|
22
22
|
* });
|
|
23
23
|
*/
|
|
24
24
|
function mergeTableConfig(base, overrides) {
|
|
25
|
-
var _a, _b;
|
|
26
|
-
var _c, _d;
|
|
25
|
+
var _a, _b, _c, _d;
|
|
27
26
|
const result = Object.assign(Object.assign({}, base), overrides);
|
|
28
27
|
// Deep-merge strategies one level down
|
|
29
28
|
if (base.strategies || overrides.strategies) {
|
|
@@ -32,12 +31,12 @@ function mergeTableConfig(base, overrides) {
|
|
|
32
31
|
// so that e.g. base.strategies.loading and overrides.strategies.loading are combined.
|
|
33
32
|
// Function values (pagination, header, dedupe, getCellLocator, etc.) are replaced, not merged.
|
|
34
33
|
const strategyKeys = new Set([
|
|
35
|
-
...Object.keys((
|
|
36
|
-
...Object.keys((
|
|
34
|
+
...Object.keys((_a = base.strategies) !== null && _a !== void 0 ? _a : {}),
|
|
35
|
+
...Object.keys((_b = overrides.strategies) !== null && _b !== void 0 ? _b : {}),
|
|
37
36
|
]);
|
|
38
37
|
for (const key of strategyKeys) {
|
|
39
|
-
const baseVal = (
|
|
40
|
-
const overrideVal = (
|
|
38
|
+
const baseVal = (_c = base.strategies) === null || _c === void 0 ? void 0 : _c[key];
|
|
39
|
+
const overrideVal = (_d = overrides.strategies) === null || _d === void 0 ? void 0 : _d[key];
|
|
41
40
|
if (baseVal !== undefined &&
|
|
42
41
|
overrideVal !== undefined &&
|
|
43
42
|
typeof baseVal === 'object' &&
|
|
@@ -7,11 +7,10 @@ exports.resolveCellLocatorForFilter = resolveCellLocatorForFilter;
|
|
|
7
7
|
* otherwise `cellSelector` + `.nth(columnIndex)`.
|
|
8
8
|
*/
|
|
9
9
|
function resolveCellLocator(args) {
|
|
10
|
-
var _a;
|
|
11
|
-
var _b;
|
|
10
|
+
var _a, _b;
|
|
12
11
|
const { config, resolve, row, root, columnName, columnIndex, rowIndex } = args;
|
|
13
|
-
const page = (
|
|
14
|
-
if ((
|
|
12
|
+
const page = (_a = args.page) !== null && _a !== void 0 ? _a : root.page();
|
|
13
|
+
if ((_b = config.strategies) === null || _b === void 0 ? void 0 : _b.getCellLocator) {
|
|
15
14
|
return config.strategies.getCellLocator({
|
|
16
15
|
row,
|
|
17
16
|
root,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rickcedwhat/playwright-smart-table",
|
|
3
|
-
"version": "6.23.1-next.
|
|
3
|
+
"version": "6.23.1-next.b64b66c",
|
|
4
4
|
"description": "Smart, column-aware table interactions for Playwright",
|
|
5
5
|
"author": "Cedrick Catalan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"@vitest/ui": "^3.2.6",
|
|
127
127
|
"happy-dom": "^20.10.6",
|
|
128
128
|
"husky": "^9.1.7",
|
|
129
|
-
"typescript": "^
|
|
129
|
+
"typescript": "^6.0.2",
|
|
130
130
|
"vitepress": "^1.6.4",
|
|
131
131
|
"vitepress-plugin-tabs": "^0.9.0",
|
|
132
132
|
"vitest": "^3.2.6"
|