@rickcedwhat/playwright-smart-table 2.0.5 → 2.0.6
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.
|
@@ -15,9 +15,14 @@ export declare const TableStrategies: {
|
|
|
15
15
|
*/
|
|
16
16
|
clickLoadMore: (buttonSelector: Selector, timeout?: number) => PaginationStrategy;
|
|
17
17
|
/**
|
|
18
|
-
* Strategy: Scrolls
|
|
18
|
+
* Strategy: Scrolls a specific container (or the window) to the bottom.
|
|
19
19
|
* Best for: Infinite Scroll grids (Ag-Grid, Virtual Lists)
|
|
20
|
-
* * @param timeout - Wait timeout (default: 5000ms)
|
|
20
|
+
* * @param options.timeout - Wait timeout (default: 5000ms)
|
|
21
|
+
* @param options.scrollerSelector - (Optional) Selector for the scrollable container.
|
|
22
|
+
* If omitted, tries to scroll the table root.
|
|
21
23
|
*/
|
|
22
|
-
infiniteScroll: (
|
|
24
|
+
infiniteScroll: (options?: {
|
|
25
|
+
timeout?: number;
|
|
26
|
+
scrollerSelector?: Selector;
|
|
27
|
+
}) => PaginationStrategy;
|
|
23
28
|
};
|
package/dist/strategies/index.js
CHANGED
|
@@ -74,24 +74,37 @@ exports.TableStrategies = {
|
|
|
74
74
|
});
|
|
75
75
|
},
|
|
76
76
|
/**
|
|
77
|
-
* Strategy: Scrolls
|
|
77
|
+
* Strategy: Scrolls a specific container (or the window) to the bottom.
|
|
78
78
|
* Best for: Infinite Scroll grids (Ag-Grid, Virtual Lists)
|
|
79
|
-
* * @param timeout - Wait timeout (default: 5000ms)
|
|
79
|
+
* * @param options.timeout - Wait timeout (default: 5000ms)
|
|
80
|
+
* @param options.scrollerSelector - (Optional) Selector for the scrollable container.
|
|
81
|
+
* If omitted, tries to scroll the table root.
|
|
80
82
|
*/
|
|
81
|
-
infiniteScroll: (
|
|
83
|
+
infiniteScroll: (options) => {
|
|
84
|
+
const { timeout = 5000, scrollerSelector } = options || {};
|
|
82
85
|
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, config, resolve, page }) {
|
|
83
86
|
const rows = resolve(config.rowSelector, root);
|
|
84
87
|
const oldCount = yield rows.count();
|
|
85
88
|
if (oldCount === 0)
|
|
86
89
|
return false;
|
|
87
|
-
// Aggressive Scroll Logic:
|
|
88
|
-
// We use expect.poll to RETRY the scroll action if the count hasn't increased.
|
|
89
|
-
// This fixes flakiness where the first scroll might be missed by the intersection observer.
|
|
90
90
|
try {
|
|
91
91
|
yield test_1.expect.poll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
-
// 1.
|
|
93
|
-
|
|
94
|
-
//
|
|
92
|
+
// 1. Determine target container
|
|
93
|
+
// If user provided a specific scroller (e.g. the div WRAPPING the table), use it.
|
|
94
|
+
// Otherwise, default to the root locator.
|
|
95
|
+
const scroller = scrollerSelector
|
|
96
|
+
? resolve(scrollerSelector, root)
|
|
97
|
+
: root;
|
|
98
|
+
// 2. Perform the Scroll
|
|
99
|
+
// Method A: DOM Manipulation (Fastest/Most Reliable for containers)
|
|
100
|
+
// We set scrollTop to a huge number to force it to the bottom
|
|
101
|
+
yield scroller.evaluate((el) => {
|
|
102
|
+
el.scrollTop = el.scrollHeight;
|
|
103
|
+
}).catch(() => { }); // Ignore if element doesn't support scrollTop (e.g. it's a window wrapper)
|
|
104
|
+
// Method B: Playwright Native (Fallback)
|
|
105
|
+
// Scroll the last row into view (good for Window scroll)
|
|
106
|
+
yield rows.last().scrollIntoViewIfNeeded().catch(() => { });
|
|
107
|
+
// Method C: Keyboard (Desperation)
|
|
95
108
|
yield page.keyboard.press('End');
|
|
96
109
|
// 3. Return count for assertion
|
|
97
110
|
return rows.count();
|
package/package.json
CHANGED