@rickcedwhat/playwright-smart-table 2.0.5 → 2.0.7

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,16 @@ export declare const TableStrategies: {
15
15
  */
16
16
  clickLoadMore: (buttonSelector: Selector, timeout?: number) => PaginationStrategy;
17
17
  /**
18
- * Strategy: Scrolls to the bottom of the table and waits for more rows to appear.
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.
23
+ * @param options.interval - (Optional) Polling interval in ms (default: 1000ms)
21
24
  */
22
- infiniteScroll: (timeout?: number) => PaginationStrategy;
25
+ infiniteScroll: (options?: {
26
+ timeout?: number;
27
+ scrollerSelector?: Selector;
28
+ interval?: number;
29
+ }) => PaginationStrategy;
23
30
  };
@@ -74,11 +74,15 @@ exports.TableStrategies = {
74
74
  });
75
75
  },
76
76
  /**
77
- * Strategy: Scrolls to the bottom of the table and waits for more rows to appear.
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.
82
+ * @param options.interval - (Optional) Polling interval in ms (default: 1000ms)
80
83
  */
81
- infiniteScroll: (timeout = 5000) => {
84
+ infiniteScroll: (options) => {
85
+ const { timeout = 5000, scrollerSelector, interval = 1000 } = options || {};
82
86
  return (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, config, resolve, page }) {
83
87
  const rows = resolve(config.rowSelector, root);
84
88
  const oldCount = yield rows.count();
@@ -89,13 +93,30 @@ exports.TableStrategies = {
89
93
  // This fixes flakiness where the first scroll might be missed by the intersection observer.
90
94
  try {
91
95
  yield test_1.expect.poll(() => __awaiter(void 0, void 0, void 0, function* () {
92
- // 1. Trigger: Scroll the last row into view
93
- yield rows.last().scrollIntoViewIfNeeded();
94
- // 2. Force: Press "End" to help with stubborn window-scrollers
96
+ // 1. Determine target container
97
+ // If user provided a specific scroller (e.g. the div WRAPPING the table), use it.
98
+ // Otherwise, default to the root locator.
99
+ const scroller = scrollerSelector
100
+ ? resolve(scrollerSelector, root)
101
+ : root;
102
+ // 2. Perform the Scroll
103
+ // Method A: DOM Manipulation (Fastest/Most Reliable for containers)
104
+ // We set scrollTop to a huge number to force it to the bottom
105
+ yield scroller.evaluate((el) => {
106
+ el.scrollTop = el.scrollHeight;
107
+ }).catch(() => { }); // Ignore if element doesn't support scrollTop (e.g. it's a window wrapper)
108
+ // Method B: Playwright Native (Fallback)
109
+ // Scroll the last row into view (good for Window scroll)
110
+ yield rows.last().scrollIntoViewIfNeeded().catch(() => { });
111
+ // Method C: Keyboard (Desperation)
95
112
  yield page.keyboard.press('End');
96
113
  // 3. Return count for assertion
97
114
  return rows.count();
98
- }), { timeout }).toBeGreaterThan(oldCount);
115
+ }), {
116
+ timeout,
117
+ // ✅ FIX: Use user-provided interval (default 1000ms)
118
+ intervals: [interval]
119
+ }).toBeGreaterThan(oldCount);
99
120
  return true;
100
121
  }
101
122
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rickcedwhat/playwright-smart-table",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "A smart table utility for Playwright with built-in pagination strategies that are fully extensible.",
5
5
  "repository": {
6
6
  "type": "git",