pw-core 1.2.0 → 1.3.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 +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +777 -0
- package/dist/codegen/config/context-weights.d.ts +8 -0
- package/dist/codegen/config/context-weights.js +11 -0
- package/dist/codegen/config/ignored-attributes.d.ts +1 -0
- package/dist/codegen/config/ignored-attributes.js +4 -0
- package/dist/codegen/config/ignored-classes.d.ts +1 -0
- package/dist/codegen/config/ignored-classes.js +144 -0
- package/dist/codegen/config/ignored-values.d.ts +1 -0
- package/dist/codegen/config/ignored-values.js +4 -0
- package/dist/codegen/config/index.d.ts +29 -0
- package/dist/codegen/config/index.js +17 -0
- package/dist/codegen/config/strategy-order.d.ts +1 -0
- package/dist/codegen/config/strategy-order.js +18 -0
- package/dist/codegen/config/weights.d.ts +15 -0
- package/dist/codegen/config/weights.js +18 -0
- package/dist/codegen/floating-panel/client.d.ts +1 -0
- package/dist/codegen/floating-panel/client.js +248 -0
- package/dist/codegen/floating-panel/index.d.ts +4 -0
- package/dist/codegen/floating-panel/index.js +20 -0
- package/dist/codegen/floating-panel/manager.d.ts +19 -0
- package/dist/codegen/floating-panel/manager.js +90 -0
- package/dist/codegen/floating-panel/template.d.ts +2 -0
- package/dist/codegen/floating-panel/template.js +58 -0
- package/dist/codegen/floating-panel/types.d.ts +7 -0
- package/dist/codegen/floating-panel/types.js +2 -0
- package/dist/codegen/generator/action.validator.d.ts +5 -0
- package/dist/codegen/generator/action.validator.js +27 -0
- package/dist/codegen/generator/index.d.ts +13 -0
- package/dist/codegen/generator/index.js +724 -0
- package/dist/codegen/generator/locator.restricted.d.ts +36 -0
- package/dist/codegen/generator/locator.restricted.js +127 -0
- package/dist/codegen/generator/locator.validator.d.ts +8 -0
- package/dist/codegen/generator/locator.validator.js +38 -0
- package/dist/codegen/hover-tracker/client.d.ts +1 -0
- package/dist/codegen/hover-tracker/client.js +75 -0
- package/dist/codegen/hover-tracker/index.d.ts +3 -0
- package/dist/codegen/hover-tracker/index.js +19 -0
- package/dist/codegen/hover-tracker/manager.d.ts +11 -0
- package/dist/codegen/hover-tracker/manager.js +28 -0
- package/dist/codegen/hover-tracker/types.d.ts +3 -0
- package/dist/codegen/hover-tracker/types.js +2 -0
- package/dist/codegen/index.d.ts +35 -0
- package/dist/codegen/index.js +1147 -0
- package/dist/codegen/key-utils.d.ts +23 -0
- package/dist/codegen/key-utils.js +68 -0
- package/dist/codegen/scorer/base-score.d.ts +1 -0
- package/dist/codegen/scorer/base-score.js +7 -0
- package/dist/codegen/scorer/context-score.d.ts +2 -0
- package/dist/codegen/scorer/context-score.js +27 -0
- package/dist/codegen/scorer/index.d.ts +5 -0
- package/dist/codegen/scorer/index.js +23 -0
- package/dist/codegen/scorer/locator.ranking.d.ts +15 -0
- package/dist/codegen/scorer/locator.ranking.js +83 -0
- package/dist/codegen/scorer/semantic-score.d.ts +1 -0
- package/dist/codegen/scorer/semantic-score.js +47 -0
- package/dist/codegen/types.d.ts +35 -0
- package/dist/codegen/types.js +2 -0
- package/dist/component/table.js +14 -10
- package/dist/constants/methods.d.ts +2 -0
- package/dist/constants/methods.js +33 -0
- package/dist/constants/strategies.d.ts +2 -0
- package/dist/constants/strategies.js +47 -0
- package/dist/page/actions/locator-actions.js +15 -4
- package/dist/page/assertions/verify-chain.d.ts +39 -32
- package/dist/page/assertions/verify-chain.js +18 -4
- package/dist/page/assertions/verify-helpers.js +12 -3
- package/dist/page/config.d.ts +109 -71
- package/dist/page/config.js +10 -31
- package/dist/page/locators/dynamic-locator-resolver.js +29 -9
- package/dist/page/locators/resolver.d.ts +15 -15
- package/dist/page/locators/resolver.js +151 -32
- package/dist/page/registry.d.ts +43 -6
- package/dist/page/registry.js +90 -18
- package/dist/page/typed-page.d.ts +33 -29
- package/dist/page/typed-page.js +40 -11
- package/dist/page/types/proxy-methods.d.ts +69 -54
- package/dist/page/types/validation.d.ts +48 -1
- package/dist/page/utils/caller-location.js +13 -9
- package/dist/page/utils/formatter.js +6 -3
- package/dist/types/methods.d.ts +4 -0
- package/dist/types/methods.js +2 -0
- package/dist/types/strategies.d.ts +17 -0
- package/dist/types/strategies.js +2 -0
- package/package.json +8 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const FLOATING_PANEL_STYLE = "\n @keyframes __pwpulse{0%,100%{opacity:.4}50%{opacity:1}}\n @keyframes __pwcolorchange{0%,100%{color:#000}50%{color:#ef4444}}\n #pw-core-test-num {\n animation: __pwcolorchange 3s ease-in-out infinite;\n font-weight: 700;\n }\n #pw-core-codegen-panel .__pw-btn {\n all:unset; display:flex; align-items:center; justify-content:center;\n width:32px; height:36px; cursor:pointer; color:#000;\n transition:background .12s, color .12s; flex-shrink:0;\n }\n #pw-core-codegen-panel .__pw-btn:hover:not(:disabled) { background:rgba(0,0,0,0.07); color:#000; }\n #pw-core-codegen-panel .__pw-btn.--active { color:#000; }\n #pw-core-codegen-panel .__pw-sep { width:1px; height:20px; background:rgba(0,0,0,0.12); flex-shrink:0; margin:0; }\n #pw-core-codegen-panel .__pw-drag { display:flex; align-items:center; justify-content:center; width:22px; height:36px; cursor:grab; color:rgba(0,0,0,0.4); flex-shrink:0; }\n #pw-core-codegen-panel .__pw-drag:active { cursor:grabbing; }\n #pw-core-codegen-panel .__pw-label { font-size:13px; font-weight:500; color:#000; padding:0 4px; white-space:nowrap; line-height:36px; }\n";
|
|
2
|
+
export declare function getFloatingPanelHtml(idx: string, fileName: string, newTestTitle: string, newSerialTitle: string, disabledAttr: string): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FLOATING_PANEL_STYLE = void 0;
|
|
4
|
+
exports.getFloatingPanelHtml = getFloatingPanelHtml;
|
|
5
|
+
exports.FLOATING_PANEL_STYLE = `
|
|
6
|
+
@keyframes __pwpulse{0%,100%{opacity:.4}50%{opacity:1}}
|
|
7
|
+
@keyframes __pwcolorchange{0%,100%{color:#000}50%{color:#ef4444}}
|
|
8
|
+
#pw-core-test-num {
|
|
9
|
+
animation: __pwcolorchange 3s ease-in-out infinite;
|
|
10
|
+
font-weight: 700;
|
|
11
|
+
}
|
|
12
|
+
#pw-core-codegen-panel .__pw-btn {
|
|
13
|
+
all:unset; display:flex; align-items:center; justify-content:center;
|
|
14
|
+
width:32px; height:36px; cursor:pointer; color:#000;
|
|
15
|
+
transition:background .12s, color .12s; flex-shrink:0;
|
|
16
|
+
}
|
|
17
|
+
#pw-core-codegen-panel .__pw-btn:hover:not(:disabled) { background:rgba(0,0,0,0.07); color:#000; }
|
|
18
|
+
#pw-core-codegen-panel .__pw-btn.--active { color:#000; }
|
|
19
|
+
#pw-core-codegen-panel .__pw-sep { width:1px; height:20px; background:rgba(0,0,0,0.12); flex-shrink:0; margin:0; }
|
|
20
|
+
#pw-core-codegen-panel .__pw-drag { display:flex; align-items:center; justify-content:center; width:22px; height:36px; cursor:grab; color:rgba(0,0,0,0.4); flex-shrink:0; }
|
|
21
|
+
#pw-core-codegen-panel .__pw-drag:active { cursor:grabbing; }
|
|
22
|
+
#pw-core-codegen-panel .__pw-label { font-size:13px; font-weight:500; color:#000; padding:0 4px; white-space:nowrap; line-height:36px; }
|
|
23
|
+
`;
|
|
24
|
+
function getFloatingPanelHtml(idx, fileName, newTestTitle, newSerialTitle, disabledAttr) {
|
|
25
|
+
return `
|
|
26
|
+
<!-- Drag handle (grid dots like Playwright) -->
|
|
27
|
+
<div class="__pw-drag" id="pw-core-drag-handle" title="Drag to move">
|
|
28
|
+
<svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor">
|
|
29
|
+
<rect x="1" y="0.5" width="2" height="2" rx="0.5"/><rect x="6" y="0.5" width="2" height="2" rx="0.5"/>
|
|
30
|
+
<rect x="1" y="4.5" width="2" height="2" rx="0.5"/><rect x="6" y="4.5" width="2" height="2" rx="0.5"/>
|
|
31
|
+
<rect x="1" y="8.5" width="2" height="2" rx="0.5"/><rect x="6" y="8.5" width="2" height="2" rx="0.5"/>
|
|
32
|
+
</svg>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="__pw-sep"></div>
|
|
35
|
+
<!-- Test label -->
|
|
36
|
+
<span class="__pw-label" title="Recording to ${fileName}">Test <span id="pw-core-test-num">#${idx}</span></span>
|
|
37
|
+
<div class="__pw-sep"></div>
|
|
38
|
+
<!-- New Test button -->
|
|
39
|
+
<button class="__pw-btn" id="pw-core-new-test-btn" title="${newTestTitle}"${disabledAttr}>
|
|
40
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">
|
|
41
|
+
<rect x="2" y="2" width="9" height="11" rx="1.5"/>
|
|
42
|
+
<line x1="11" y1="5" x2="14" y2="5"/>
|
|
43
|
+
<line x1="12.5" y1="3.5" x2="12.5" y2="6.5"/>
|
|
44
|
+
<line x1="5" y1="6" x2="8" y2="6"/>
|
|
45
|
+
<line x1="5" y1="8.5" x2="8" y2="8.5"/>
|
|
46
|
+
</svg>
|
|
47
|
+
</button>
|
|
48
|
+
<div class="__pw-sep"></div>
|
|
49
|
+
<!-- New Serial Test button -->
|
|
50
|
+
<button class="__pw-btn" id="pw-core-new-serial-btn" title="${newSerialTitle}"${disabledAttr}>
|
|
51
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">
|
|
52
|
+
<rect x="2" y="2" width="7" height="12" rx="1"/>
|
|
53
|
+
<rect x="11" y="2" width="3" height="3" rx="0.5"/>
|
|
54
|
+
<rect x="11" y="6.5" width="3" height="3" rx="0.5"/>
|
|
55
|
+
<rect x="11" y="11" width="3" height="3" rx="0.5"/>
|
|
56
|
+
</svg>
|
|
57
|
+
</button>`;
|
|
58
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeActionName = normalizeActionName;
|
|
4
|
+
/**
|
|
5
|
+
* Normalizes action name to ensure check/uncheck are only used on checkboxes.
|
|
6
|
+
* Otherwise, falls back to click.
|
|
7
|
+
*/
|
|
8
|
+
async function normalizeActionName(page, selector, actionName) {
|
|
9
|
+
if (actionName !== 'check' && actionName !== 'uncheck') {
|
|
10
|
+
return actionName;
|
|
11
|
+
}
|
|
12
|
+
if (!selector) {
|
|
13
|
+
return 'click';
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const isCheckbox = await page.locator(selector).evaluate((el) => {
|
|
17
|
+
return el.tagName.toLowerCase() === 'input' && el.type === 'checkbox';
|
|
18
|
+
}, null, { timeout: 500 }).catch(() => false);
|
|
19
|
+
if (!isCheckbox) {
|
|
20
|
+
return 'click';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
return 'click';
|
|
25
|
+
}
|
|
26
|
+
return actionName;
|
|
27
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LocatorCandidate } from '../types';
|
|
2
|
+
export declare function isStableId(id: string): boolean;
|
|
3
|
+
export declare function generateKeyFromText(text: string, role?: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Derive a camelCase key from a candidate's attribute/selector value.
|
|
6
|
+
* E.g. data-parent-id="why-pw-core" → whyPwCore
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateKeyFromCandidate(candidate: {
|
|
9
|
+
strategy: string;
|
|
10
|
+
selector: string;
|
|
11
|
+
valueToScore?: string;
|
|
12
|
+
}, role?: string): string;
|
|
13
|
+
export declare function generateSmartLocator(page: any, selector: string): Promise<LocatorCandidate | null>;
|