@rickcedwhat/playwright-smart-table 6.20.1 → 6.21.0-next.3ab7a18

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.
Files changed (46) hide show
  1. package/dist/engine/rowFinder.d.ts +1 -0
  2. package/dist/engine/rowFinder.js +73 -75
  3. package/dist/engine/scanPages.d.ts +58 -0
  4. package/dist/engine/scanPages.js +46 -0
  5. package/dist/engine/tableIteration.d.ts +1 -0
  6. package/dist/engine/tableIteration.js +40 -22
  7. package/dist/filterEngine.d.ts +4 -0
  8. package/dist/filterEngine.js +15 -4
  9. package/dist/index.d.ts +6 -2
  10. package/dist/index.js +5 -1
  11. package/dist/packageVersion.d.ts +1 -1
  12. package/dist/packageVersion.js +1 -1
  13. package/dist/plugins/index.d.ts +51 -10
  14. package/dist/plugins/index.js +14 -6
  15. package/dist/presets/glide/index.d.ts +1 -1
  16. package/dist/presets/glide/index.js +2 -2
  17. package/dist/presets/mui.js +15 -29
  18. package/dist/presets/rdg.d.ts +1 -1
  19. package/dist/presets/rdg.js +4 -4
  20. package/dist/smartRow.d.ts +2 -2
  21. package/dist/smartRow.js +163 -51
  22. package/dist/strategies/columns.d.ts +5 -9
  23. package/dist/strategies/columns.js +0 -10
  24. package/dist/strategies/contentReady.d.ts +20 -0
  25. package/dist/strategies/contentReady.js +62 -0
  26. package/dist/strategies/filter.d.ts +0 -4
  27. package/dist/strategies/filter.js +0 -16
  28. package/dist/strategies/headers.d.ts +5 -0
  29. package/dist/strategies/headers.js +17 -9
  30. package/dist/strategies/index.d.ts +23 -15
  31. package/dist/strategies/index.js +9 -5
  32. package/dist/strategies/pagination.js +11 -2
  33. package/dist/strategies/viewport.d.ts +4 -1
  34. package/dist/strategies/viewport.js +62 -32
  35. package/dist/typeContext.d.ts +1 -1
  36. package/dist/typeContext.js +77 -17
  37. package/dist/types.d.ts +74 -17
  38. package/dist/useTable.js +125 -56
  39. package/dist/utils/elementTracker.js +6 -3
  40. package/dist/utils/loadingWait.d.ts +15 -0
  41. package/dist/utils/loadingWait.js +43 -0
  42. package/dist/utils/pageIndex.d.ts +12 -0
  43. package/dist/utils/pageIndex.js +19 -0
  44. package/dist/utils/resolveCellLocator.d.ts +35 -0
  45. package/dist/utils/resolveCellLocator.js +52 -0
  46. package/package.json +1 -1
@@ -1,13 +1,32 @@
1
1
  /**
2
2
  * @deprecated Use `presets` instead. Plugins will be removed in v7.0.0.
3
- * Presets for specific table/grid libraries. Each plugin exposes:
4
- * - Plugins.X — full preset (selectors + headerTransformer if any + strategies). Spread: useTable(loc, { ...Presets.MUI, maxPages: 5 }).
5
- * - Plugins.X.Strategies — strategies only. Use with your own selectors: useTable(loc, { rowSelector: '...', strategies: Presets.MUI.Strategies }).
3
+ *
4
+ * Compatibility shim over official presets:
5
+ * - `Plugins.MUI` → `presets.muiDataGrid` (**DataGrid only** — not `presets.muiTable`)
6
+ * - `Plugins.RDG` → `presets.rdg`
7
+ * - `Plugins.Glide` → `presets.glide`
8
+ *
9
+ * Prefer: `useTable(loc, { ...presets.muiDataGrid, maxPages: 5 })`.
10
+ * Strategies only: `useTable(loc, { rowSelector: '...', strategies: presets.muiDataGrid.strategies })`.
6
11
  */
7
12
  export declare const Plugins: {
8
13
  /** @deprecated Use `presets.rdg` */
9
14
  RDG: {
10
- Strategies: import("../types").TableStrategies | undefined;
15
+ Strategies: {
16
+ header: (context: import("..").TableContext) => Promise<string[]>;
17
+ getCellLocator: ({ row, columnIndex }: {
18
+ row: import("@playwright/test").Locator;
19
+ columnIndex: number;
20
+ }) => import("@playwright/test").Locator;
21
+ navigation: {
22
+ goRight: ({ root }: import("..").StrategyContext) => Promise<void>;
23
+ goLeft: ({ root }: import("..").StrategyContext) => Promise<void>;
24
+ goDown: ({ root }: import("..").StrategyContext) => Promise<void>;
25
+ goUp: ({ root }: import("..").StrategyContext) => Promise<void>;
26
+ goHome: ({ root }: import("..").StrategyContext) => Promise<void>;
27
+ };
28
+ pagination: import("..").PaginationPrimitives;
29
+ };
11
30
  headerSelector?: string | ((root: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
12
31
  rowSelector?: string | undefined;
13
32
  cellSelector?: string | ((row: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
@@ -22,14 +41,33 @@ export declare const Plugins: {
22
41
  autoScroll?: boolean | undefined;
23
42
  debug?: import("..").DebugConfig | undefined;
24
43
  onReset?: ((context: import("..").TableContext) => Promise<void>) | undefined;
25
- strategies?: import("../types").TableStrategies | undefined;
44
+ strategies?: import("..").TableStrategies | undefined;
26
45
  columnOverrides?: Partial<Record<string | number | symbol, import("..").ColumnOverride<any>>> | undefined;
27
46
  syntheticColumns?: Record<string, import("..").SyntheticColumnDef<any>> | undefined;
28
47
  emptyState?: import("@playwright/test").Locator | undefined;
29
48
  };
30
49
  /** @deprecated Use `presets.glide` */
31
50
  Glide: {
32
- Strategies: import("../types").TableStrategies | undefined;
51
+ Strategies: {
52
+ fillSimple: import("..").FillStrategy;
53
+ fill: import("..").FillStrategy;
54
+ pagination: import("..").PaginationPrimitives;
55
+ header: (context: import("..").StrategyContext, options?: {
56
+ limit?: number;
57
+ selector?: string;
58
+ scrollAmount?: number;
59
+ }) => Promise<string[]>;
60
+ viewport: import("..").ViewportStrategy;
61
+ loading: {
62
+ isHeaderLoading: () => Promise<boolean>;
63
+ };
64
+ getCellLocator: ({ row, columnIndex }: any) => any;
65
+ getActiveCell: ({ page }: any) => Promise<{
66
+ rowIndex: number;
67
+ columnIndex: number;
68
+ locator: any;
69
+ } | null>;
70
+ };
33
71
  headerSelector?: string | ((root: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
34
72
  rowSelector?: string | undefined;
35
73
  cellSelector?: string | ((row: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
@@ -44,14 +82,17 @@ export declare const Plugins: {
44
82
  autoScroll?: boolean | undefined;
45
83
  debug?: import("..").DebugConfig | undefined;
46
84
  onReset?: ((context: import("..").TableContext) => Promise<void>) | undefined;
47
- strategies?: import("../types").TableStrategies | undefined;
85
+ strategies?: import("..").TableStrategies | undefined;
48
86
  columnOverrides?: Partial<Record<string | number | symbol, import("..").ColumnOverride<any>>> | undefined;
49
87
  syntheticColumns?: Record<string, import("..").SyntheticColumnDef<any>> | undefined;
50
88
  emptyState?: import("@playwright/test").Locator | undefined;
51
89
  };
52
- /** @deprecated Use `presets.muiDataGrid` */
90
+ /**
91
+ * @deprecated Use `presets.muiDataGrid`.
92
+ * DataGrid only — for MUI `<Table>` use `presets.muiTable`.
93
+ */
53
94
  MUI: {
54
- Strategies: import("../types").TableStrategies | undefined;
95
+ Strategies: import("..").TableStrategies | undefined;
55
96
  headerSelector?: string | ((root: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
56
97
  rowSelector?: string | undefined;
57
98
  cellSelector?: string | ((row: import("@playwright/test").Locator) => import("@playwright/test").Locator) | undefined;
@@ -66,7 +107,7 @@ export declare const Plugins: {
66
107
  autoScroll?: boolean | undefined;
67
108
  debug?: import("..").DebugConfig | undefined;
68
109
  onReset?: ((context: import("..").TableContext) => Promise<void>) | undefined;
69
- strategies?: import("../types").TableStrategies | undefined;
110
+ strategies?: import("..").TableStrategies | undefined;
70
111
  columnOverrides?: Partial<Record<string | number | symbol, import("..").ColumnOverride<any>>> | undefined;
71
112
  syntheticColumns?: Record<string, import("..").SyntheticColumnDef<any>> | undefined;
72
113
  emptyState?: import("@playwright/test").Locator | undefined;
@@ -4,15 +4,23 @@ exports.Plugins = void 0;
4
4
  const presets_1 = require("../presets");
5
5
  /**
6
6
  * @deprecated Use `presets` instead. Plugins will be removed in v7.0.0.
7
- * Presets for specific table/grid libraries. Each plugin exposes:
8
- * - Plugins.X — full preset (selectors + headerTransformer if any + strategies). Spread: useTable(loc, { ...Presets.MUI, maxPages: 5 }).
9
- * - Plugins.X.Strategies — strategies only. Use with your own selectors: useTable(loc, { rowSelector: '...', strategies: Presets.MUI.Strategies }).
7
+ *
8
+ * Compatibility shim over official presets:
9
+ * - `Plugins.MUI` → `presets.muiDataGrid` (**DataGrid only** — not `presets.muiTable`)
10
+ * - `Plugins.RDG` → `presets.rdg`
11
+ * - `Plugins.Glide` → `presets.glide`
12
+ *
13
+ * Prefer: `useTable(loc, { ...presets.muiDataGrid, maxPages: 5 })`.
14
+ * Strategies only: `useTable(loc, { rowSelector: '...', strategies: presets.muiDataGrid.strategies })`.
10
15
  */
11
16
  exports.Plugins = {
12
17
  /** @deprecated Use `presets.rdg` */
13
- RDG: Object.assign(Object.assign({}, presets_1.rdg), { Strategies: presets_1.rdg.strategies }),
18
+ RDG: Object.assign(Object.assign({}, presets_1.rdg), { Strategies: presets_1.rdg.Strategies }),
14
19
  /** @deprecated Use `presets.glide` */
15
- Glide: Object.assign(Object.assign({}, presets_1.glide), { Strategies: presets_1.glide.strategies }),
16
- /** @deprecated Use `presets.muiDataGrid` */
20
+ Glide: Object.assign(Object.assign({}, presets_1.glide), { Strategies: presets_1.glide.Strategies }),
21
+ /**
22
+ * @deprecated Use `presets.muiDataGrid`.
23
+ * DataGrid only — for MUI `<Table>` use `presets.muiTable`.
24
+ */
17
25
  MUI: Object.assign(Object.assign({}, presets_1.muiDataGrid), { Strategies: presets_1.muiDataGrid.strategies }),
18
26
  };
@@ -12,7 +12,7 @@ export declare const GlideStrategies: {
12
12
  selector?: string;
13
13
  scrollAmount?: number;
14
14
  }) => Promise<string[]>;
15
- viewport: import("../../types").ViewportStrategy;
15
+ viewport: import("../..").ViewportStrategy;
16
16
  loading: {
17
17
  isHeaderLoading: () => Promise<boolean>;
18
18
  };
@@ -123,8 +123,8 @@ function createGlide(options = {}) {
123
123
  }
124
124
  /**
125
125
  * Full preset for Glide Data Grid (selectors + default strategies only).
126
- * Spread: useTable(loc, { ...Plugins.Glide, maxPages: 5 }).
127
- * Strategies only (including fillSimple): useTable(loc, { rowSelector: '...', strategies: Plugins.Glide.Strategies }).
126
+ * Spread: `useTable(loc, { ...presets.glide, maxPages: 5 })`.
127
+ * Strategies only (including fillSimple): `useTable(loc, { rowSelector: '...', strategies: presets.glide.Strategies })`.
128
128
  * For a non-64-column grid, use `createGlide({ columnCount })` instead.
129
129
  */
130
130
  const GlidePreset = {
@@ -146,22 +146,14 @@ function createMuiTable(opts) {
146
146
  return 'asc';
147
147
  return 'none';
148
148
  },
149
- doSort: async ({ columnName, direction, context }) => {
150
- var _a, _b;
149
+ doSort: async ({ columnName, context }) => {
150
+ // Trigger-only: core `sorting.apply` owns retries + state checks (#434).
151
151
  if (!context.getHeaderCell)
152
152
  return;
153
153
  const header = await context.getHeaderCell(columnName);
154
154
  const sortLabel = header.locator('.MuiTableSortLabel-root').first();
155
155
  const target = await sortLabel.isVisible().catch(() => false) ? sortLabel : header;
156
- let current = await ((_a = context.config.strategies.sorting) === null || _a === void 0 ? void 0 : _a.getSortState({ columnName, context })) || 'none';
157
- let attempts = 0;
158
- // Click until the state matches the target direction, max 3 times (none -> asc -> desc)
159
- while (current !== direction && attempts < 3) {
160
- await target.click();
161
- await context.page.waitForTimeout(100);
162
- current = await ((_b = context.config.strategies.sorting) === null || _b === void 0 ? void 0 : _b.getSortState({ columnName, context })) || 'none';
163
- attempts++;
164
- }
156
+ await target.click();
165
157
  }
166
158
  },
167
159
  dedupe: async (row) => {
@@ -303,28 +295,22 @@ function createMuiDataGrid(opts) {
303
295
  return 'desc';
304
296
  return 'none';
305
297
  },
306
- doSort: async ({ columnName, direction, context }) => {
307
- var _a, _b;
298
+ doSort: async ({ columnName, context }) => {
299
+ // Trigger-only: core `sorting.apply` owns retries + state checks (#434).
308
300
  if (!context.getHeaderCell)
309
301
  return;
310
302
  const header = await context.getHeaderCell(columnName);
311
- let current = await ((_a = context.config.strategies.sorting) === null || _a === void 0 ? void 0 : _a.getSortState({ columnName, context })) || 'none';
312
- let attempts = 0;
313
- while (current !== direction && attempts < 3) {
314
- const clickTarget = header.locator('.MuiDataGrid-columnHeaderTitleContainer').first();
315
- if (await clickTarget.isVisible()) {
316
- await clickTarget.click({ force: true });
317
- }
318
- else {
319
- await header.click({ force: true });
320
- }
321
- // Wait for stabilization (using DataGrid specific overlay check inside helper)
322
- const displayedRows = context.root.locator('.MuiTablePagination-displayedRows');
323
- const text = await displayedRows.innerText().catch(() => '');
324
- await waitForMuiPaginationStabilization(context, displayedRows, text);
325
- current = await ((_b = context.config.strategies.sorting) === null || _b === void 0 ? void 0 : _b.getSortState({ columnName, context })) || 'none';
326
- attempts++;
303
+ const clickTarget = header.locator('.MuiDataGrid-columnHeaderTitleContainer').first();
304
+ if (await clickTarget.isVisible()) {
305
+ await clickTarget.click({ force: true });
306
+ }
307
+ else {
308
+ await header.click({ force: true });
327
309
  }
310
+ // One stabilization wait after the click; core also polls isTableLoading.
311
+ const displayedRows = context.root.locator('.MuiTablePagination-displayedRows');
312
+ const text = await displayedRows.innerText().catch(() => '');
313
+ await waitForMuiPaginationStabilization(context, displayedRows, text);
328
314
  }
329
315
  },
330
316
  dedupe: async (row) => {
@@ -1,6 +1,6 @@
1
1
  import type { Locator } from '@playwright/test';
2
2
  import { TableContext, TableConfig, ViewportStrategy, StrategyContext } from '../types';
3
- /** Full strategies for React Data Grid. Use when you want to supply your own selectors: strategies: Plugins.RDG.Strategies */
3
+ /** Full strategies for React Data Grid. Use when you want to supply your own selectors: `strategies: presets.rdg.Strategies` */
4
4
  export declare const RDGStrategies: {
5
5
  header: (context: TableContext) => Promise<string[]>;
6
6
  getCellLocator: ({ row, columnIndex }: {
@@ -92,20 +92,20 @@ const rdgNavigation = {
92
92
  });
93
93
  }
94
94
  };
95
- /** Default strategies for the RDG preset (used when you spread Plugins.RDG). */
95
+ /** Default strategies for the RDG preset (used when you spread `presets.rdg`). */
96
96
  const RDGDefaultStrategies = {
97
97
  header: scrollRightHeaderRDG,
98
98
  getCellLocator: rdgGetCellLocator,
99
99
  navigation: rdgNavigation,
100
100
  pagination: rdgPaginationStrategy
101
101
  };
102
- /** Full strategies for React Data Grid. Use when you want to supply your own selectors: strategies: Plugins.RDG.Strategies */
102
+ /** Full strategies for React Data Grid. Use when you want to supply your own selectors: `strategies: presets.rdg.Strategies` */
103
103
  // fallow-ignore-next-line unused-export
104
104
  exports.RDGStrategies = RDGDefaultStrategies;
105
105
  /**
106
106
  * Full preset for React Data Grid (selectors + default strategies).
107
- * Spread: useTable(loc, { ...Plugins.RDG, maxPages: 5 }).
108
- * Strategies only: useTable(loc, { rowSelector: '...', strategies: Plugins.RDG.Strategies }).
107
+ * Spread: `useTable(loc, { ...presets.rdg, maxPages: 5 })`.
108
+ * Strategies only: `useTable(loc, { rowSelector: '...', strategies: presets.rdg.Strategies })`.
109
109
  */
110
110
  const RDGPreset = {
111
111
  rowSelector: '[role="row"].rdg-row',
@@ -1,4 +1,4 @@
1
- import type { Locator, Page } from '@playwright/test';
1
+ import { type Locator, type Page } from '@playwright/test';
2
2
  import { SmartRow as SmartRowType, FinalTableConfig, TableResult } from './types';
3
3
  import { NavigationBarrier } from './utils/navigationBarrier';
4
4
  /**
@@ -9,5 +9,5 @@ import { NavigationBarrier } from './utils/navigationBarrier';
9
9
  * @internal Internal factory for creating SmartRow objects.
10
10
  * Not part of the public package surface; tests and consumers should use public APIs.
11
11
  */
12
- declare const createSmartRow: <T = any>(rowLocator: Locator, map: Map<string, number>, rowIndex: number | undefined, config: FinalTableConfig<T>, rootLocator: Locator, resolve: (item: any, parent: Locator | Page) => Locator, table: TableResult<T> | null, tablePageIndex?: number, barrier?: NavigationBarrier) => SmartRowType<T>;
12
+ declare const createSmartRow: <T = any>(rowLocator: Locator, map: Map<string, number>, rowIndex: number | undefined, config: FinalTableConfig<T>, rootLocator: Locator, resolve: (item: any, parent: Locator | Page) => Locator, table: TableResult<T> | null, tablePageIndex?: number, barrier?: NavigationBarrier, renderWindowPosition?: boolean) => SmartRowType<T>;
13
13
  export default createSmartRow;