@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
|
@@ -1,62 +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.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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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>;
|
|
@@ -1,22 +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.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
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/src/utils.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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>;
|
package/dist/src/utils.js
DELETED
|
@@ -1,29 +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.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;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Page } from '@playwright/test';
|
|
2
|
-
/**
|
|
3
|
-
* Add a custom trace event to Playwright's trace viewer
|
|
4
|
-
* Uses page.evaluate to log events that appear in the trace
|
|
5
|
-
*/
|
|
6
|
-
export declare function addTraceEvent(page: Page, type: string, data?: Record<string, any>): Promise<void>;
|
|
7
|
-
/**
|
|
8
|
-
* Check if tracing is currently enabled
|
|
9
|
-
* Used for conditional trace logic
|
|
10
|
-
*/
|
|
11
|
-
export declare function isTracingEnabled(page: Page): Promise<boolean>;
|
package/dist/utils/traceUtils.js
DELETED
|
@@ -1,47 +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.addTraceEvent = addTraceEvent;
|
|
13
|
-
exports.isTracingEnabled = isTracingEnabled;
|
|
14
|
-
/**
|
|
15
|
-
* Add a custom trace event to Playwright's trace viewer
|
|
16
|
-
* Uses page.evaluate to log events that appear in the trace
|
|
17
|
-
*/
|
|
18
|
-
function addTraceEvent(page_1, type_1) {
|
|
19
|
-
return __awaiter(this, arguments, void 0, function* (page, type, data = {}) {
|
|
20
|
-
try {
|
|
21
|
-
// Add a console log that will appear in the trace viewer
|
|
22
|
-
// Prefix with [SmartTable] for easy filtering
|
|
23
|
-
const message = `[SmartTable:${type}] ${JSON.stringify(data)}`;
|
|
24
|
-
yield page.evaluate((msg) => console.log(msg), message);
|
|
25
|
-
}
|
|
26
|
-
catch (_a) {
|
|
27
|
-
// Silently ignore if page is not available
|
|
28
|
-
// This ensures zero overhead when tracing is off
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Check if tracing is currently enabled
|
|
34
|
-
* Used for conditional trace logic
|
|
35
|
-
*/
|
|
36
|
-
function isTracingEnabled(page) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
try {
|
|
39
|
-
// We can't directly check if tracing is enabled
|
|
40
|
-
// But we can safely call addTraceEvent - it will just be a no-op if not tracing
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
catch (_a) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|