@rickcedwhat/playwright-smart-table 6.1.0 → 6.2.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/README.md +2 -0
- package/dist/engine/rowFinder.d.ts +26 -0
- package/dist/engine/rowFinder.js +161 -0
- package/dist/engine/tableMapper.d.ts +16 -0
- package/dist/engine/tableMapper.js +136 -0
- package/dist/{examples/glide-strategies → strategies/glide}/columns.d.ts +1 -1
- package/dist/{examples/glide-strategies → strategies/glide}/headers.d.ts +1 -1
- package/dist/{src/strategies → strategies}/glide.js +2 -2
- package/dist/strategies/index.d.ts +33 -2
- package/dist/strategies/index.js +6 -0
- package/dist/{src/strategies → strategies}/loading.d.ts +14 -0
- package/dist/{src/strategies → strategies}/loading.js +31 -0
- package/dist/strategies/pagination.d.ts +26 -4
- package/dist/strategies/pagination.js +52 -23
- package/dist/typeContext.d.ts +1 -1
- package/dist/typeContext.js +32 -7
- package/dist/types.d.ts +37 -5
- package/dist/useTable.d.ts +32 -3
- package/dist/useTable.js +81 -224
- package/dist/utils/stringUtils.js +12 -3
- package/package.json +10 -5
- package/dist/src/filterEngine.d.ts +0 -11
- package/dist/src/filterEngine.js +0 -39
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +0 -18
- package/dist/src/smartRow.d.ts +0 -7
- package/dist/src/smartRow.js +0 -160
- package/dist/src/strategies/columns.d.ts +0 -18
- package/dist/src/strategies/columns.js +0 -21
- package/dist/src/strategies/fill.d.ts +0 -7
- package/dist/src/strategies/fill.js +0 -88
- package/dist/src/strategies/headers.d.ts +0 -13
- package/dist/src/strategies/headers.js +0 -30
- package/dist/src/strategies/index.d.ts +0 -54
- package/dist/src/strategies/index.js +0 -43
- package/dist/src/strategies/pagination.d.ts +0 -33
- package/dist/src/strategies/pagination.js +0 -79
- package/dist/src/strategies/resolution.d.ts +0 -22
- package/dist/src/strategies/resolution.js +0 -30
- package/dist/src/strategies/sorting.d.ts +0 -12
- package/dist/src/strategies/sorting.js +0 -68
- package/dist/src/strategies/validation.d.ts +0 -22
- package/dist/src/strategies/validation.js +0 -54
- package/dist/src/strategies/virtualizedPagination.d.ts +0 -32
- package/dist/src/strategies/virtualizedPagination.js +0 -80
- package/dist/src/typeContext.d.ts +0 -6
- package/dist/src/typeContext.js +0 -465
- package/dist/src/types.d.ts +0 -458
- package/dist/src/types.js +0 -2
- package/dist/src/useTable.d.ts +0 -44
- package/dist/src/useTable.js +0 -641
- package/dist/src/utils/debugUtils.d.ts +0 -17
- package/dist/src/utils/debugUtils.js +0 -62
- package/dist/src/utils/smartRowArray.d.ts +0 -14
- package/dist/src/utils/smartRowArray.js +0 -22
- package/dist/src/utils/stringUtils.d.ts +0 -22
- package/dist/src/utils/stringUtils.js +0 -73
- package/dist/src/utils.d.ts +0 -7
- package/dist/src/utils.js +0 -29
- package/dist/utils/traceUtils.d.ts +0 -11
- package/dist/utils/traceUtils.js +0 -47
- /package/dist/{src/plugins.d.ts → plugins.d.ts} +0 -0
- /package/dist/{src/plugins.js → plugins.js} +0 -0
- /package/dist/{src/strategies → strategies}/dedupe.d.ts +0 -0
- /package/dist/{src/strategies → strategies}/dedupe.js +0 -0
- /package/dist/{examples/glide-strategies → strategies/glide}/columns.js +0 -0
- /package/dist/{examples/glide-strategies → strategies/glide}/headers.js +0 -0
- /package/dist/{src/strategies → strategies}/glide.d.ts +0 -0
- /package/dist/{src/strategies → strategies}/rdg.d.ts +0 -0
- /package/dist/{src/strategies → strategies}/rdg.js +0 -0
- /package/dist/{src/strategies → strategies}/stabilization.d.ts +0 -0
- /package/dist/{src/strategies → strategies}/stabilization.js +0 -0
package/dist/src/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./useTable"), exports);
|
|
18
|
-
__exportStar(require("./types"), exports);
|
package/dist/src/smartRow.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Locator, Page } from '@playwright/test';
|
|
2
|
-
import { SmartRow as SmartRowType, FinalTableConfig, TableResult } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Factory to create a SmartRow by extending a Playwright Locator.
|
|
5
|
-
* We avoid Class/Proxy to ensure full compatibility with Playwright's expect(locator) matchers.
|
|
6
|
-
*/
|
|
7
|
-
export declare const createSmartRow: <T = any>(rowLocator: Locator, map: Map<string, number>, rowIndex: number | undefined, config: FinalTableConfig, rootLocator: Locator, resolve: (item: any, parent: Locator | Page) => Locator, table: TableResult<T> | null) => SmartRowType<T>;
|
package/dist/src/smartRow.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createSmartRow = void 0;
|
|
13
|
-
const fill_1 = require("./strategies/fill");
|
|
14
|
-
const stringUtils_1 = require("./utils/stringUtils");
|
|
15
|
-
const debugUtils_1 = require("./utils/debugUtils");
|
|
16
|
-
/**
|
|
17
|
-
* Factory to create a SmartRow by extending a Playwright Locator.
|
|
18
|
-
* We avoid Class/Proxy to ensure full compatibility with Playwright's expect(locator) matchers.
|
|
19
|
-
*/
|
|
20
|
-
const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve, table) => {
|
|
21
|
-
const smart = rowLocator;
|
|
22
|
-
// Attach State
|
|
23
|
-
smart.rowIndex = rowIndex;
|
|
24
|
-
// Attach Methods
|
|
25
|
-
smart.getCell = (colName) => {
|
|
26
|
-
const idx = map.get(colName);
|
|
27
|
-
if (idx === undefined) {
|
|
28
|
-
throw new Error((0, stringUtils_1.buildColumnNotFoundError)(colName, Array.from(map.keys())));
|
|
29
|
-
}
|
|
30
|
-
if (config.strategies.getCellLocator) {
|
|
31
|
-
return config.strategies.getCellLocator({
|
|
32
|
-
row: rowLocator,
|
|
33
|
-
columnName: colName,
|
|
34
|
-
columnIndex: idx,
|
|
35
|
-
rowIndex: rowIndex,
|
|
36
|
-
page: rootLocator.page()
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return resolve(config.cellSelector, rowLocator).nth(idx);
|
|
40
|
-
};
|
|
41
|
-
smart.toJSON = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
const result = {};
|
|
43
|
-
const page = rootLocator.page();
|
|
44
|
-
for (const [col, idx] of map.entries()) {
|
|
45
|
-
if ((options === null || options === void 0 ? void 0 : options.columns) && !options.columns.includes(col)) {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
// Get the cell locator
|
|
49
|
-
const cell = config.strategies.getCellLocator
|
|
50
|
-
? config.strategies.getCellLocator({
|
|
51
|
-
row: rowLocator,
|
|
52
|
-
columnName: col,
|
|
53
|
-
columnIndex: idx,
|
|
54
|
-
rowIndex: rowIndex,
|
|
55
|
-
page: page
|
|
56
|
-
})
|
|
57
|
-
: resolve(config.cellSelector, rowLocator).nth(idx);
|
|
58
|
-
let targetCell = cell;
|
|
59
|
-
// Check if cell exists
|
|
60
|
-
const count = yield cell.count();
|
|
61
|
-
if (count === 0) {
|
|
62
|
-
// Optimization: Check if we are ALREADY at the target cell
|
|
63
|
-
if (config.strategies.getActiveCell) {
|
|
64
|
-
const active = yield config.strategies.getActiveCell({
|
|
65
|
-
config,
|
|
66
|
-
root: rootLocator,
|
|
67
|
-
page,
|
|
68
|
-
resolve
|
|
69
|
-
});
|
|
70
|
-
if (active && active.rowIndex === rowIndex && active.columnIndex === idx) {
|
|
71
|
-
if (config.debug)
|
|
72
|
-
console.log(`[SmartRow] Already at target cell (r:${active.rowIndex}, c:${active.columnIndex}), skipping navigation.`);
|
|
73
|
-
targetCell = active.locator;
|
|
74
|
-
// Skip navigation and go to reading text
|
|
75
|
-
const text = yield targetCell.innerText();
|
|
76
|
-
result[col] = (text || '').trim();
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Cell doesn't exist - navigate to it
|
|
81
|
-
if (config.debug) {
|
|
82
|
-
console.log(`[SmartRow.toJSON] Cell not found for column "${col}" (index ${idx}), navigating...`);
|
|
83
|
-
}
|
|
84
|
-
yield config.strategies.cellNavigation({
|
|
85
|
-
config: config,
|
|
86
|
-
root: rootLocator,
|
|
87
|
-
page: page,
|
|
88
|
-
resolve: resolve,
|
|
89
|
-
column: col,
|
|
90
|
-
index: idx,
|
|
91
|
-
rowLocator: rowLocator,
|
|
92
|
-
rowIndex: rowIndex
|
|
93
|
-
});
|
|
94
|
-
// Optimization: check if we can get the active cell directly
|
|
95
|
-
if (config.strategies.getActiveCell) {
|
|
96
|
-
const activeCell = yield config.strategies.getActiveCell({
|
|
97
|
-
config,
|
|
98
|
-
root: rootLocator,
|
|
99
|
-
page,
|
|
100
|
-
resolve
|
|
101
|
-
});
|
|
102
|
-
if (activeCell) {
|
|
103
|
-
if (config.debug) {
|
|
104
|
-
console.log(`[SmartRow.toJSON] switching to active cell locator (r:${activeCell.rowIndex}, c:${activeCell.columnIndex})`);
|
|
105
|
-
}
|
|
106
|
-
targetCell = activeCell.locator;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const text = yield targetCell.innerText();
|
|
111
|
-
result[col] = (text || '').trim();
|
|
112
|
-
}
|
|
113
|
-
return result;
|
|
114
|
-
});
|
|
115
|
-
smart.smartFill = (data, fillOptions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
-
(0, debugUtils_1.logDebug)(config, 'info', 'Filling row', data);
|
|
117
|
-
for (const [colName, value] of Object.entries(data)) {
|
|
118
|
-
if (value === undefined)
|
|
119
|
-
continue;
|
|
120
|
-
const colIdx = map.get(colName);
|
|
121
|
-
if (colIdx === undefined) {
|
|
122
|
-
throw new Error((0, stringUtils_1.buildColumnNotFoundError)(colName, Array.from(map.keys())));
|
|
123
|
-
}
|
|
124
|
-
yield config.strategies.cellNavigation({
|
|
125
|
-
config: config,
|
|
126
|
-
root: rootLocator,
|
|
127
|
-
page: rootLocator.page(),
|
|
128
|
-
resolve: resolve,
|
|
129
|
-
column: colName,
|
|
130
|
-
index: colIdx,
|
|
131
|
-
rowLocator: rowLocator,
|
|
132
|
-
rowIndex: rowIndex
|
|
133
|
-
});
|
|
134
|
-
const strategy = config.strategies.fill || fill_1.FillStrategies.default;
|
|
135
|
-
(0, debugUtils_1.logDebug)(config, 'verbose', `Filling cell "${colName}" with value`, value);
|
|
136
|
-
yield strategy({
|
|
137
|
-
row: smart,
|
|
138
|
-
columnName: colName,
|
|
139
|
-
value,
|
|
140
|
-
index: rowIndex !== null && rowIndex !== void 0 ? rowIndex : -1,
|
|
141
|
-
page: rowLocator.page(),
|
|
142
|
-
rootLocator,
|
|
143
|
-
table: table,
|
|
144
|
-
fillOptions
|
|
145
|
-
});
|
|
146
|
-
// Delay after filling
|
|
147
|
-
yield (0, debugUtils_1.debugDelay)(config, 'getCell');
|
|
148
|
-
}
|
|
149
|
-
(0, debugUtils_1.logDebug)(config, 'info', 'Row fill complete');
|
|
150
|
-
});
|
|
151
|
-
smart.bringIntoView = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
|
-
if (rowIndex === undefined) {
|
|
153
|
-
throw new Error('Cannot bring row into view - row index is unknown. Use getRowByIndex() instead of getRow().');
|
|
154
|
-
}
|
|
155
|
-
// Scroll row into view using Playwright's built-in method
|
|
156
|
-
yield rowLocator.scrollIntoViewIfNeeded();
|
|
157
|
-
});
|
|
158
|
-
return smart;
|
|
159
|
-
};
|
|
160
|
-
exports.createSmartRow = createSmartRow;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { StrategyContext } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Defines the contract for a cell navigation strategy.
|
|
4
|
-
* It is responsible for ensuring a specific CELL is visible/focused (navigates to row + column),
|
|
5
|
-
* typically by scrolling or using keyboard navigation.
|
|
6
|
-
*/
|
|
7
|
-
export type CellNavigationStrategy = (context: StrategyContext & {
|
|
8
|
-
column: string;
|
|
9
|
-
index: number;
|
|
10
|
-
rowIndex?: number;
|
|
11
|
-
}) => Promise<void>;
|
|
12
|
-
export declare const CellNavigationStrategies: {
|
|
13
|
-
/**
|
|
14
|
-
* Default strategy: Assumes column is accessible or standard scrolling works.
|
|
15
|
-
* No specific action taken other than what Playwright's default locator handling does.
|
|
16
|
-
*/
|
|
17
|
-
default: () => Promise<void>;
|
|
18
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CellNavigationStrategies = void 0;
|
|
13
|
-
exports.CellNavigationStrategies = {
|
|
14
|
-
/**
|
|
15
|
-
* Default strategy: Assumes column is accessible or standard scrolling works.
|
|
16
|
-
* No specific action taken other than what Playwright's default locator handling does.
|
|
17
|
-
*/
|
|
18
|
-
default: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
// No-op
|
|
20
|
-
})
|
|
21
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { FillStrategy } from '../types';
|
|
2
|
-
export declare const FillStrategies: {
|
|
3
|
-
/**
|
|
4
|
-
* Default strategy: Detects input type and fills accordingly (Text, Select, Checkbox, ContentEditable).
|
|
5
|
-
*/
|
|
6
|
-
default: ({ row, columnName, value, fillOptions }: Parameters<FillStrategy>[0]) => Promise<void>;
|
|
7
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.FillStrategies = void 0;
|
|
13
|
-
exports.FillStrategies = {
|
|
14
|
-
/**
|
|
15
|
-
* Default strategy: Detects input type and fills accordingly (Text, Select, Checkbox, ContentEditable).
|
|
16
|
-
*/
|
|
17
|
-
default: (_a) => __awaiter(void 0, [_a], void 0, function* ({ row, columnName, value, fillOptions }) {
|
|
18
|
-
var _b;
|
|
19
|
-
const cell = row.getCell(columnName);
|
|
20
|
-
// Use custom input mapper for this column if provided, otherwise auto-detect
|
|
21
|
-
let inputLocator;
|
|
22
|
-
if ((_b = fillOptions === null || fillOptions === void 0 ? void 0 : fillOptions.inputMappers) === null || _b === void 0 ? void 0 : _b[columnName]) {
|
|
23
|
-
inputLocator = fillOptions.inputMappers[columnName](cell);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// Auto-detect input type
|
|
27
|
-
// Check for text input
|
|
28
|
-
const textInput = cell.locator('input[type="text"], input:not([type]), textarea').first();
|
|
29
|
-
const textInputCount = yield textInput.count().catch(() => 0);
|
|
30
|
-
// Check for select
|
|
31
|
-
const select = cell.locator('select').first();
|
|
32
|
-
const selectCount = yield select.count().catch(() => 0);
|
|
33
|
-
// Check for checkbox/radio
|
|
34
|
-
const checkbox = cell.locator('input[type="checkbox"], input[type="radio"], [role="checkbox"]').first();
|
|
35
|
-
const checkboxCount = yield checkbox.count().catch(() => 0);
|
|
36
|
-
// Check for contenteditable or div-based inputs
|
|
37
|
-
const contentEditable = cell.locator('[contenteditable="true"]').first();
|
|
38
|
-
const contentEditableCount = yield contentEditable.count().catch(() => 0);
|
|
39
|
-
// Determine which input to use (prioritize by commonality)
|
|
40
|
-
if (textInputCount > 0 && selectCount === 0 && checkboxCount === 0) {
|
|
41
|
-
inputLocator = textInput;
|
|
42
|
-
}
|
|
43
|
-
else if (selectCount > 0) {
|
|
44
|
-
inputLocator = select;
|
|
45
|
-
}
|
|
46
|
-
else if (checkboxCount > 0) {
|
|
47
|
-
inputLocator = checkbox;
|
|
48
|
-
}
|
|
49
|
-
else if (contentEditableCount > 0) {
|
|
50
|
-
inputLocator = contentEditable;
|
|
51
|
-
}
|
|
52
|
-
else if (textInputCount > 0) {
|
|
53
|
-
// Fallback to text input even if others exist
|
|
54
|
-
inputLocator = textInput;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// No input found - try to click the cell itself (might trigger an editor)
|
|
58
|
-
inputLocator = cell;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Fill based on value type and input type
|
|
62
|
-
const inputTag = yield inputLocator.evaluate((el) => el.tagName.toLowerCase()).catch(() => 'unknown');
|
|
63
|
-
const inputType = yield inputLocator.getAttribute('type').catch(() => null);
|
|
64
|
-
const isContentEditable = yield inputLocator.getAttribute('contenteditable').catch(() => null);
|
|
65
|
-
// console.log(`[SmartTable] Filling "${columnName}" with value "${value}" (input: ${inputTag}, type: ${inputType})`);
|
|
66
|
-
if (inputType === 'checkbox' || inputType === 'radio') {
|
|
67
|
-
// Boolean value for checkbox/radio
|
|
68
|
-
const shouldBeChecked = Boolean(value);
|
|
69
|
-
const isChecked = yield inputLocator.isChecked().catch(() => false);
|
|
70
|
-
if (isChecked !== shouldBeChecked) {
|
|
71
|
-
yield inputLocator.click();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else if (inputTag === 'select') {
|
|
75
|
-
// Select dropdown
|
|
76
|
-
yield inputLocator.selectOption(String(value));
|
|
77
|
-
}
|
|
78
|
-
else if (isContentEditable === 'true') {
|
|
79
|
-
// Contenteditable div
|
|
80
|
-
yield inputLocator.click();
|
|
81
|
-
yield inputLocator.fill(String(value));
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
// Text input, textarea, or generic
|
|
85
|
-
yield inputLocator.fill(String(value));
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { StrategyContext } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Defines the contract for a header retrieval strategy.
|
|
4
|
-
* Returns a list of unique header names found in the table.
|
|
5
|
-
*/
|
|
6
|
-
export type HeaderStrategy = (context: StrategyContext) => Promise<string[]>;
|
|
7
|
-
export declare const HeaderStrategies: {
|
|
8
|
-
/**
|
|
9
|
-
* Default strategy: Returns only the headers currently visible in the DOM.
|
|
10
|
-
* This is fast but won't find virtualized columns off-screen.
|
|
11
|
-
*/
|
|
12
|
-
visible: ({ config, resolve, root }: StrategyContext) => Promise<string[]>;
|
|
13
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.HeaderStrategies = void 0;
|
|
13
|
-
exports.HeaderStrategies = {
|
|
14
|
-
/**
|
|
15
|
-
* Default strategy: Returns only the headers currently visible in the DOM.
|
|
16
|
-
* This is fast but won't find virtualized columns off-screen.
|
|
17
|
-
*/
|
|
18
|
-
visible: (_a) => __awaiter(void 0, [_a], void 0, function* ({ config, resolve, root }) {
|
|
19
|
-
const headerLoc = resolve(config.headerSelector, root);
|
|
20
|
-
try {
|
|
21
|
-
// Wait for at least one header to be visible
|
|
22
|
-
yield headerLoc.first().waitFor({ state: 'visible', timeout: 3000 });
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
// Ignore hydration/timeout issues, return what we have
|
|
26
|
-
}
|
|
27
|
-
const texts = yield headerLoc.allInnerTexts();
|
|
28
|
-
return texts.map(t => t.trim());
|
|
29
|
-
})
|
|
30
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export * from './pagination';
|
|
2
|
-
export * from './sorting';
|
|
3
|
-
export * from './columns';
|
|
4
|
-
export * from './headers';
|
|
5
|
-
export * from './fill';
|
|
6
|
-
export * from './resolution';
|
|
7
|
-
export * from './dedupe';
|
|
8
|
-
export * from './loading';
|
|
9
|
-
export declare const Strategies: {
|
|
10
|
-
Pagination: {
|
|
11
|
-
clickNext: (nextButtonSelector: import("..").Selector, options?: {
|
|
12
|
-
stabilization?: import("./stabilization").StabilizationStrategy;
|
|
13
|
-
timeout?: number;
|
|
14
|
-
}) => import("..").PaginationStrategy;
|
|
15
|
-
infiniteScroll: (options?: {
|
|
16
|
-
action?: "scroll" | "js-scroll";
|
|
17
|
-
scrollTarget?: import("..").Selector;
|
|
18
|
-
scrollAmount?: number;
|
|
19
|
-
stabilization?: import("./stabilization").StabilizationStrategy;
|
|
20
|
-
timeout?: number;
|
|
21
|
-
}) => import("..").PaginationStrategy;
|
|
22
|
-
};
|
|
23
|
-
Sorting: {
|
|
24
|
-
AriaSort: () => import("..").SortingStrategy;
|
|
25
|
-
};
|
|
26
|
-
CellNavigation: {
|
|
27
|
-
default: () => Promise<void>;
|
|
28
|
-
};
|
|
29
|
-
Header: {
|
|
30
|
-
visible: ({ config, resolve, root }: import("..").StrategyContext) => Promise<string[]>;
|
|
31
|
-
};
|
|
32
|
-
Fill: {
|
|
33
|
-
default: ({ row, columnName, value, fillOptions }: Parameters<import("..").FillStrategy>[0]) => Promise<void>;
|
|
34
|
-
};
|
|
35
|
-
Resolution: {
|
|
36
|
-
default: import("./resolution").ColumnResolutionStrategy;
|
|
37
|
-
};
|
|
38
|
-
Dedupe: {
|
|
39
|
-
byTopPosition: (tolerance?: number) => import("..").DedupeStrategy;
|
|
40
|
-
};
|
|
41
|
-
Loading: {
|
|
42
|
-
Table: {
|
|
43
|
-
hasSpinner: (selector?: string) => ({ root }: import("..").TableContext) => Promise<boolean>;
|
|
44
|
-
custom: (fn: (context: import("..").TableContext) => Promise<boolean>) => (context: import("..").TableContext) => Promise<boolean>;
|
|
45
|
-
never: () => Promise<boolean>;
|
|
46
|
-
};
|
|
47
|
-
Row: {
|
|
48
|
-
hasClass: (className?: string) => (row: import("..").SmartRow) => Promise<boolean>;
|
|
49
|
-
hasText: (text?: string | RegExp) => (row: import("..").SmartRow) => Promise<boolean>;
|
|
50
|
-
hasEmptyCells: () => (row: import("..").SmartRow) => Promise<boolean>;
|
|
51
|
-
never: () => Promise<boolean>;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Strategies = void 0;
|
|
18
|
-
const pagination_1 = require("./pagination");
|
|
19
|
-
const sorting_1 = require("./sorting");
|
|
20
|
-
const columns_1 = require("./columns");
|
|
21
|
-
const headers_1 = require("./headers");
|
|
22
|
-
const fill_1 = require("./fill");
|
|
23
|
-
const resolution_1 = require("./resolution");
|
|
24
|
-
const dedupe_1 = require("./dedupe");
|
|
25
|
-
const loading_1 = require("./loading");
|
|
26
|
-
__exportStar(require("./pagination"), exports);
|
|
27
|
-
__exportStar(require("./sorting"), exports);
|
|
28
|
-
__exportStar(require("./columns"), exports);
|
|
29
|
-
__exportStar(require("./headers"), exports);
|
|
30
|
-
__exportStar(require("./fill"), exports);
|
|
31
|
-
__exportStar(require("./resolution"), exports);
|
|
32
|
-
__exportStar(require("./dedupe"), exports);
|
|
33
|
-
__exportStar(require("./loading"), exports);
|
|
34
|
-
exports.Strategies = {
|
|
35
|
-
Pagination: pagination_1.PaginationStrategies,
|
|
36
|
-
Sorting: sorting_1.SortingStrategies,
|
|
37
|
-
CellNavigation: columns_1.CellNavigationStrategies,
|
|
38
|
-
Header: headers_1.HeaderStrategies,
|
|
39
|
-
Fill: fill_1.FillStrategies,
|
|
40
|
-
Resolution: resolution_1.ResolutionStrategies,
|
|
41
|
-
Dedupe: dedupe_1.DedupeStrategies,
|
|
42
|
-
Loading: loading_1.LoadingStrategies,
|
|
43
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { PaginationStrategy, Selector } from '../types';
|
|
2
|
-
import { StabilizationStrategy } from './stabilization';
|
|
3
|
-
export declare const PaginationStrategies: {
|
|
4
|
-
/**
|
|
5
|
-
* Strategy: Clicks a "Next" button and waits for stabilization.
|
|
6
|
-
* @param nextButtonSelector Selector for the next page button.
|
|
7
|
-
* @param options.stabilization Strategy to determine when the page has updated.
|
|
8
|
-
* Defaults to `contentChanged({ scope: 'first' })`.
|
|
9
|
-
* @param options.timeout Timeout for the click action.
|
|
10
|
-
*/
|
|
11
|
-
clickNext: (nextButtonSelector: Selector, options?: {
|
|
12
|
-
stabilization?: StabilizationStrategy;
|
|
13
|
-
timeout?: number;
|
|
14
|
-
}) => PaginationStrategy;
|
|
15
|
-
/**
|
|
16
|
-
* Strategy: Infinite Scroll (generic).
|
|
17
|
-
* Supports both simple "Scroll to Bottom" and "Virtualized Scroll".
|
|
18
|
-
*
|
|
19
|
-
* @param options.action 'scroll' (mouse wheel) or 'js-scroll' (direct scrollTop).
|
|
20
|
-
* @param options.scrollTarget Selector for the scroll container (defaults to table root).
|
|
21
|
-
* @param options.scrollAmount Amount to scroll in pixels (default 500).
|
|
22
|
-
* @param options.stabilization Strategy to determine if new content loaded.
|
|
23
|
-
* Defaults to `rowCountIncreased` (simple append).
|
|
24
|
-
* Use `contentChanged` for virtualization.
|
|
25
|
-
*/
|
|
26
|
-
infiniteScroll: (options?: {
|
|
27
|
-
action?: "scroll" | "js-scroll";
|
|
28
|
-
scrollTarget?: Selector;
|
|
29
|
-
scrollAmount?: number;
|
|
30
|
-
stabilization?: StabilizationStrategy;
|
|
31
|
-
timeout?: number;
|
|
32
|
-
}) => PaginationStrategy;
|
|
33
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PaginationStrategies = void 0;
|
|
13
|
-
const stabilization_1 = require("./stabilization");
|
|
14
|
-
exports.PaginationStrategies = {
|
|
15
|
-
/**
|
|
16
|
-
* Strategy: Clicks a "Next" button and waits for stabilization.
|
|
17
|
-
* @param nextButtonSelector Selector for the next page button.
|
|
18
|
-
* @param options.stabilization Strategy to determine when the page has updated.
|
|
19
|
-
* Defaults to `contentChanged({ scope: 'first' })`.
|
|
20
|
-
* @param options.timeout Timeout for the click action.
|
|
21
|
-
*/
|
|
22
|
-
clickNext: (nextButtonSelector, options = {}) => {
|
|
23
|
-
return (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
var _a;
|
|
25
|
-
const { root, resolve, page } = context;
|
|
26
|
-
const nextBtn = resolve(nextButtonSelector, root).first();
|
|
27
|
-
if (!(yield nextBtn.isVisible()) || !(yield nextBtn.isEnabled())) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
// Default stabilization: Wait for first row content to change
|
|
31
|
-
const stabilization = (_a = options.stabilization) !== null && _a !== void 0 ? _a : stabilization_1.StabilizationStrategies.contentChanged({ scope: 'first', timeout: options.timeout });
|
|
32
|
-
// Stabilization: Wrap action
|
|
33
|
-
const success = yield stabilization(context, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
yield nextBtn.click({ timeout: 2000 }).catch(() => { });
|
|
35
|
-
}));
|
|
36
|
-
return success;
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
/**
|
|
40
|
-
* Strategy: Infinite Scroll (generic).
|
|
41
|
-
* Supports both simple "Scroll to Bottom" and "Virtualized Scroll".
|
|
42
|
-
*
|
|
43
|
-
* @param options.action 'scroll' (mouse wheel) or 'js-scroll' (direct scrollTop).
|
|
44
|
-
* @param options.scrollTarget Selector for the scroll container (defaults to table root).
|
|
45
|
-
* @param options.scrollAmount Amount to scroll in pixels (default 500).
|
|
46
|
-
* @param options.stabilization Strategy to determine if new content loaded.
|
|
47
|
-
* Defaults to `rowCountIncreased` (simple append).
|
|
48
|
-
* Use `contentChanged` for virtualization.
|
|
49
|
-
*/
|
|
50
|
-
infiniteScroll: (options = {}) => {
|
|
51
|
-
return (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
const { root, resolve, page } = context;
|
|
54
|
-
const scrollTarget = options.scrollTarget
|
|
55
|
-
? resolve(options.scrollTarget, root)
|
|
56
|
-
: root;
|
|
57
|
-
// Default stabilization: Wait for row count to increase (Append mode)
|
|
58
|
-
const stabilization = (_a = options.stabilization) !== null && _a !== void 0 ? _a : stabilization_1.StabilizationStrategies.rowCountIncreased({ timeout: options.timeout });
|
|
59
|
-
const amount = (_b = options.scrollAmount) !== null && _b !== void 0 ? _b : 500;
|
|
60
|
-
const doScroll = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
-
const box = yield scrollTarget.boundingBox();
|
|
62
|
-
// Action: Scroll
|
|
63
|
-
if (options.action === 'js-scroll' || !box) {
|
|
64
|
-
yield scrollTarget.evaluate((el, y) => {
|
|
65
|
-
el.scrollTop += y;
|
|
66
|
-
}, amount);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
// Mouse Wheel
|
|
70
|
-
yield page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
|
|
71
|
-
yield page.mouse.wheel(0, amount);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
// Stabilization: Wait
|
|
75
|
-
const success = yield stabilization(context, doScroll);
|
|
76
|
-
return success;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { StrategyContext } from '../types';
|
|
2
|
-
export interface ColumnResolutionStrategy {
|
|
3
|
-
/**
|
|
4
|
-
* Resolves a column name (string or Regex) to a column index.
|
|
5
|
-
* Returns undefined if not found.
|
|
6
|
-
*/
|
|
7
|
-
resolveIndex(options: {
|
|
8
|
-
query: string | RegExp;
|
|
9
|
-
headerMap: Map<string, number>;
|
|
10
|
-
context: StrategyContext;
|
|
11
|
-
}): number | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* Resolves a column name to a clean string name (for error messages or debugging).
|
|
14
|
-
*/
|
|
15
|
-
resolveName(options: {
|
|
16
|
-
query: string | RegExp;
|
|
17
|
-
headerMap: Map<string, number>;
|
|
18
|
-
}): string;
|
|
19
|
-
}
|
|
20
|
-
export declare const ResolutionStrategies: {
|
|
21
|
-
default: ColumnResolutionStrategy;
|
|
22
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResolutionStrategies = void 0;
|
|
4
|
-
exports.ResolutionStrategies = {
|
|
5
|
-
default: {
|
|
6
|
-
resolveIndex: ({ query, headerMap }) => {
|
|
7
|
-
// 1. Exact / String Match
|
|
8
|
-
if (typeof query === 'string') {
|
|
9
|
-
if (headerMap.has(query))
|
|
10
|
-
return headerMap.get(query);
|
|
11
|
-
}
|
|
12
|
-
// 2. Regex Match
|
|
13
|
-
if (query instanceof RegExp) {
|
|
14
|
-
for (const [colName, idx] of headerMap.entries()) {
|
|
15
|
-
if (query.test(colName))
|
|
16
|
-
return idx;
|
|
17
|
-
}
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
// 3. (Optional) Fuzzy String Match fallback could go here
|
|
21
|
-
// But for strict default strategy, we might want to keep it simple first
|
|
22
|
-
// The original code didn't do fuzzy *resolution* logic inside the get(), it just did strict get().
|
|
23
|
-
// The fuzzy logic was only for *suggestions* on error.
|
|
24
|
-
return undefined;
|
|
25
|
-
},
|
|
26
|
-
resolveName: ({ query }) => {
|
|
27
|
-
return query.toString();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { SortingStrategy } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* A collection of pre-built sorting strategies.
|
|
4
|
-
*/
|
|
5
|
-
export declare const SortingStrategies: {
|
|
6
|
-
/**
|
|
7
|
-
* A sorting strategy that interacts with column headers based on ARIA attributes.
|
|
8
|
-
* - `doSort`: Clicks the header repeatedly until the desired `aria-sort` state is achieved.
|
|
9
|
-
* - `getSortState`: Reads the `aria-sort` attribute from the header.
|
|
10
|
-
*/
|
|
11
|
-
AriaSort: () => SortingStrategy;
|
|
12
|
-
};
|