@rickcedwhat/playwright-smart-table 5.4.0 → 6.0.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 +78 -964
- package/dist/examples/glide-strategies/columns.d.ts +13 -0
- package/dist/examples/glide-strategies/columns.js +43 -0
- package/dist/examples/glide-strategies/headers.d.ts +9 -0
- package/dist/examples/glide-strategies/headers.js +68 -0
- package/dist/src/filterEngine.d.ts +11 -0
- package/dist/src/filterEngine.js +39 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +18 -0
- package/dist/src/plugins.d.ts +32 -0
- package/dist/src/plugins.js +13 -0
- package/dist/src/smartRow.d.ts +7 -0
- package/dist/src/smartRow.js +160 -0
- package/dist/src/strategies/columns.d.ts +18 -0
- package/dist/src/strategies/columns.js +21 -0
- package/dist/src/strategies/dedupe.d.ts +9 -0
- package/dist/src/strategies/dedupe.js +27 -0
- package/dist/src/strategies/fill.d.ts +7 -0
- package/dist/src/strategies/fill.js +88 -0
- package/dist/src/strategies/glide.d.ts +29 -0
- package/dist/src/strategies/glide.js +98 -0
- package/dist/src/strategies/headers.d.ts +13 -0
- package/dist/src/strategies/headers.js +30 -0
- package/dist/src/strategies/index.d.ts +54 -0
- package/dist/src/strategies/index.js +43 -0
- package/dist/src/strategies/loading.d.ts +48 -0
- package/dist/src/strategies/loading.js +82 -0
- package/dist/src/strategies/pagination.d.ts +33 -0
- package/dist/src/strategies/pagination.js +79 -0
- package/dist/src/strategies/rdg.d.ts +25 -0
- package/dist/src/strategies/rdg.js +100 -0
- package/dist/src/strategies/resolution.d.ts +22 -0
- package/dist/src/strategies/resolution.js +30 -0
- package/dist/src/strategies/sorting.d.ts +12 -0
- package/dist/src/strategies/sorting.js +68 -0
- package/dist/src/strategies/stabilization.d.ts +29 -0
- package/dist/src/strategies/stabilization.js +91 -0
- package/dist/src/strategies/validation.d.ts +22 -0
- package/dist/src/strategies/validation.js +54 -0
- package/dist/src/strategies/virtualizedPagination.d.ts +32 -0
- package/dist/src/strategies/virtualizedPagination.js +80 -0
- package/dist/src/typeContext.d.ts +6 -0
- package/dist/src/typeContext.js +465 -0
- package/dist/src/types.d.ts +458 -0
- package/dist/src/types.js +2 -0
- package/dist/src/useTable.d.ts +44 -0
- package/dist/src/useTable.js +642 -0
- package/dist/src/utils/debugUtils.d.ts +17 -0
- package/dist/src/utils/debugUtils.js +62 -0
- package/dist/src/utils/smartRowArray.d.ts +14 -0
- package/dist/src/utils/smartRowArray.js +22 -0
- package/dist/src/utils/stringUtils.d.ts +22 -0
- package/dist/src/utils/stringUtils.js +73 -0
- package/dist/src/utils.d.ts +7 -0
- package/dist/src/utils.js +29 -0
- package/package.json +2 -4
|
@@ -0,0 +1,62 @@
|
|
|
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.getDebugDelay = getDebugDelay;
|
|
13
|
+
exports.debugDelay = debugDelay;
|
|
14
|
+
exports.logDebug = logDebug;
|
|
15
|
+
exports.warnIfDebugInCI = warnIfDebugInCI;
|
|
16
|
+
/**
|
|
17
|
+
* Get delay for specific action type
|
|
18
|
+
*/
|
|
19
|
+
function getDebugDelay(config, actionType) {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
if (!((_a = config.debug) === null || _a === void 0 ? void 0 : _a.slow))
|
|
22
|
+
return 0;
|
|
23
|
+
if (typeof config.debug.slow === 'number') {
|
|
24
|
+
return config.debug.slow;
|
|
25
|
+
}
|
|
26
|
+
return (_c = (_b = config.debug.slow[actionType]) !== null && _b !== void 0 ? _b : config.debug.slow.default) !== null && _c !== void 0 ? _c : 0;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Add debug delay for specific action type
|
|
30
|
+
*/
|
|
31
|
+
function debugDelay(config, actionType) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const delay = getDebugDelay(config, actionType);
|
|
34
|
+
if (delay > 0) {
|
|
35
|
+
yield new Promise(resolve => setTimeout(resolve, delay));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Log debug message based on log level
|
|
41
|
+
*/
|
|
42
|
+
function logDebug(config, level, message, data) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
const logLevel = (_b = (_a = config.debug) === null || _a === void 0 ? void 0 : _a.logLevel) !== null && _b !== void 0 ? _b : 'none';
|
|
45
|
+
const levels = { none: 0, error: 1, info: 2, verbose: 3 };
|
|
46
|
+
if (levels[logLevel] >= levels[level]) {
|
|
47
|
+
const prefix = level === 'error' ? '❌' : level === 'info' ? 'ℹ️' : '🔍';
|
|
48
|
+
const timestamp = new Date().toISOString().split('T')[1].split('.')[0];
|
|
49
|
+
console.log(`${prefix} [${timestamp}] [SmartTable] ${message}`, data !== null && data !== void 0 ? data : '');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Warn if debug.slow is enabled in CI environment
|
|
54
|
+
*/
|
|
55
|
+
function warnIfDebugInCI(config) {
|
|
56
|
+
var _a;
|
|
57
|
+
if (process.env.CI === 'true' && ((_a = config.debug) === null || _a === void 0 ? void 0 : _a.slow)) {
|
|
58
|
+
console.warn('⚠️ [SmartTable] Warning: debug.slow is enabled in CI environment.\n' +
|
|
59
|
+
' This will significantly slow down test execution.\n' +
|
|
60
|
+
' Consider disabling debug mode in CI.');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SmartRow } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Extended array type with a toJSON helper method
|
|
4
|
+
*/
|
|
5
|
+
export interface SmartRowArray<T = any> extends Array<SmartRow<T>> {
|
|
6
|
+
/**
|
|
7
|
+
* Converts all rows to JSON objects
|
|
8
|
+
*/
|
|
9
|
+
toJSON(): Promise<T[]>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a SmartRow array with a convenient toJSON() method
|
|
13
|
+
*/
|
|
14
|
+
export declare function createSmartRowArray<T>(rows: SmartRow<T>[]): SmartRowArray<T>;
|
|
@@ -0,0 +1,22 @@
|
|
|
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.createSmartRowArray = createSmartRowArray;
|
|
13
|
+
/**
|
|
14
|
+
* Wraps a SmartRow array with a convenient toJSON() method
|
|
15
|
+
*/
|
|
16
|
+
function createSmartRowArray(rows) {
|
|
17
|
+
const arr = rows;
|
|
18
|
+
arr.toJSON = () => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return Promise.all(rows.map(r => r.toJSON()));
|
|
20
|
+
});
|
|
21
|
+
return arr;
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate Levenshtein distance between two strings
|
|
3
|
+
* Used for "did you mean?" suggestions
|
|
4
|
+
*/
|
|
5
|
+
export declare function levenshteinDistance(a: string, b: string): number;
|
|
6
|
+
/**
|
|
7
|
+
* Calculate similarity score between two strings (0-1)
|
|
8
|
+
* 1 = identical, 0 = completely different
|
|
9
|
+
*/
|
|
10
|
+
export declare function stringSimilarity(a: string, b: string): number;
|
|
11
|
+
/**
|
|
12
|
+
* Find similar strings from a list
|
|
13
|
+
* Returns matches above threshold, sorted by similarity
|
|
14
|
+
*/
|
|
15
|
+
export declare function findSimilar(input: string, available: string[], threshold?: number): Array<{
|
|
16
|
+
value: string;
|
|
17
|
+
score: number;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Build a helpful error message for column not found
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildColumnNotFoundError(columnName: string, availableColumns: string[]): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.levenshteinDistance = levenshteinDistance;
|
|
4
|
+
exports.stringSimilarity = stringSimilarity;
|
|
5
|
+
exports.findSimilar = findSimilar;
|
|
6
|
+
exports.buildColumnNotFoundError = buildColumnNotFoundError;
|
|
7
|
+
/**
|
|
8
|
+
* Calculate Levenshtein distance between two strings
|
|
9
|
+
* Used for "did you mean?" suggestions
|
|
10
|
+
*/
|
|
11
|
+
function levenshteinDistance(a, b) {
|
|
12
|
+
const matrix = [];
|
|
13
|
+
for (let i = 0; i <= b.length; i++) {
|
|
14
|
+
matrix[i] = [i];
|
|
15
|
+
}
|
|
16
|
+
for (let j = 0; j <= a.length; j++) {
|
|
17
|
+
matrix[0][j] = j;
|
|
18
|
+
}
|
|
19
|
+
for (let i = 1; i <= b.length; i++) {
|
|
20
|
+
for (let j = 1; j <= a.length; j++) {
|
|
21
|
+
if (b.charAt(i - 1) === a.charAt(j - 1)) {
|
|
22
|
+
matrix[i][j] = matrix[i - 1][j - 1];
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, // substitution
|
|
26
|
+
matrix[i][j - 1] + 1, // insertion
|
|
27
|
+
matrix[i - 1][j] + 1 // deletion
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return matrix[b.length][a.length];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Calculate similarity score between two strings (0-1)
|
|
36
|
+
* 1 = identical, 0 = completely different
|
|
37
|
+
*/
|
|
38
|
+
function stringSimilarity(a, b) {
|
|
39
|
+
const distance = levenshteinDistance(a.toLowerCase(), b.toLowerCase());
|
|
40
|
+
const maxLen = Math.max(a.length, b.length);
|
|
41
|
+
return maxLen === 0 ? 1 : 1 - (distance / maxLen);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Find similar strings from a list
|
|
45
|
+
* Returns matches above threshold, sorted by similarity
|
|
46
|
+
*/
|
|
47
|
+
function findSimilar(input, available, threshold = 0.5) {
|
|
48
|
+
return available
|
|
49
|
+
.map(value => ({
|
|
50
|
+
value,
|
|
51
|
+
score: stringSimilarity(input, value)
|
|
52
|
+
}))
|
|
53
|
+
.filter(x => x.score >= threshold)
|
|
54
|
+
.sort((a, b) => b.score - a.score)
|
|
55
|
+
.slice(0, 3); // Top 3 suggestions
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Build a helpful error message for column not found
|
|
59
|
+
*/
|
|
60
|
+
function buildColumnNotFoundError(columnName, availableColumns) {
|
|
61
|
+
const suggestions = findSimilar(columnName, availableColumns);
|
|
62
|
+
let message = `Column '${columnName}' not found`;
|
|
63
|
+
if (suggestions.length > 0) {
|
|
64
|
+
message += `\n\nDid you mean:`;
|
|
65
|
+
suggestions.forEach(({ value, score }) => {
|
|
66
|
+
const percentage = Math.round(score * 100);
|
|
67
|
+
message += `\n • ${value} (${percentage}% match)`;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
message += `\n\nAvailable columns: ${availableColumns.join(', ')}`;
|
|
71
|
+
message += `\n\nTip: Column names are case-sensitive`;
|
|
72
|
+
return message;
|
|
73
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Page } from '@playwright/test';
|
|
2
|
+
/**
|
|
3
|
+
* Internal helper to wait for a condition to be met.
|
|
4
|
+
* Replaces the dependency on 'expect(...).toPass()' to ensure compatibility
|
|
5
|
+
* with environments where 'expect' is not globally available.
|
|
6
|
+
*/
|
|
7
|
+
export declare const waitForCondition: (predicate: () => Promise<boolean>, timeout: number, page: Page) => Promise<boolean>;
|
|
@@ -0,0 +1,29 @@
|
|
|
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.waitForCondition = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Internal helper to wait for a condition to be met.
|
|
15
|
+
* Replaces the dependency on 'expect(...).toPass()' to ensure compatibility
|
|
16
|
+
* with environments where 'expect' is not globally available.
|
|
17
|
+
*/
|
|
18
|
+
const waitForCondition = (predicate, timeout, page) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const startTime = Date.now();
|
|
20
|
+
while (Date.now() - startTime < timeout) {
|
|
21
|
+
if (yield predicate()) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
// Wait 100ms before next check (Standard Polling)
|
|
25
|
+
yield page.waitForTimeout(100).catch(() => new Promise(r => setTimeout(r, 100)));
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
});
|
|
29
|
+
exports.waitForCondition = waitForCondition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rickcedwhat/playwright-smart-table",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Smart, column-aware table interactions for Playwright",
|
|
5
5
|
"author": "Cedrick Catalan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,5 @@
|
|
|
42
42
|
"typescript": "^5.7.2",
|
|
43
43
|
"vitepress": "^1.6.4"
|
|
44
44
|
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"string-similarity": "^4.0.4"
|
|
47
|
-
}
|
|
45
|
+
"dependencies": {}
|
|
48
46
|
}
|