sela-core 1.0.1 → 1.0.2
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/dist/cli/index.js +1 -1
- package/dist/fixtures/expectProxy.d.ts.map +1 -1
- package/dist/fixtures/expectProxy.js +10 -0
- package/dist/fixtures/index.d.ts +2 -0
- package/dist/fixtures/index.d.ts.map +1 -1
- package/dist/fixtures/index.js +24 -1
- package/dist/fixtures/moduleExpect.d.ts.map +1 -1
- package/dist/fixtures/moduleExpect.js +2 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -58,7 +58,7 @@ const program = new commander_1.Command();
|
|
|
58
58
|
program
|
|
59
59
|
.name('sela')
|
|
60
60
|
.description('Sela CLI — proactive DNA management for Fixwright')
|
|
61
|
-
.version('1.0.
|
|
61
|
+
.version('1.0.2')
|
|
62
62
|
.exitOverride(ErrorHandler_js_1.handleError)
|
|
63
63
|
.configureOutput({ outputError: () => { } });
|
|
64
64
|
// ── sela init ────────────────────────────────────────────────────────────────
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expectProxy.d.ts","sourceRoot":"","sources":["../../src/fixtures/expectProxy.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,OAAO,EAER,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"expectProxy.d.ts","sourceRoot":"","sources":["../../src/fixtures/expectProxy.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,OAAO,EAER,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAgO5D;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,OAAO,kBAAkB,EAAE,IAAI,EACrC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EAAE,6CAA6C;AAClE,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,IAAI,GAChD,CAAC,cAAc,EAAE,OAAO,KAAK,GAAG,CAiElC"}
|
|
@@ -29,6 +29,11 @@ function isRealLocator(value) {
|
|
|
29
29
|
return false;
|
|
30
30
|
if (typeof value !== "object")
|
|
31
31
|
return false;
|
|
32
|
+
// Fixwright locator proxies expose `_fixwrightSelector`. The proxy forwards
|
|
33
|
+
// `_frame` via Reflect.get so `hasFrame` would lie — explicitly reject them
|
|
34
|
+
// here. Callers should unwrap via `resolveProxy` first.
|
|
35
|
+
if (value._fixwrightSelector !== undefined)
|
|
36
|
+
return false;
|
|
32
37
|
const hasFrame = value._frame !== undefined ||
|
|
33
38
|
value._impl?._frame !== undefined;
|
|
34
39
|
const isFrameLocator = value._frameSelector !== undefined ||
|
|
@@ -206,6 +211,11 @@ resolveProxy) {
|
|
|
206
211
|
resolved = unwrapped;
|
|
207
212
|
}
|
|
208
213
|
const base = (0, test_1.expect)(resolved);
|
|
214
|
+
// Defensive: if for any reason `base` is not an object, return it as-is
|
|
215
|
+
// rather than crashing inside `new Proxy(...)`.
|
|
216
|
+
if (base === null || typeof base !== "object") {
|
|
217
|
+
return base;
|
|
218
|
+
}
|
|
209
219
|
// Step 2 — only wrap matchers for genuine page-level Locator objects.
|
|
210
220
|
if (!isRealLocator(resolved)) {
|
|
211
221
|
return base;
|
package/dist/fixtures/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Locator } from "@playwright/test";
|
|
1
2
|
import { createHealingExpect } from "./expectProxy";
|
|
3
|
+
export declare function resolveFixwrightProxy(value: unknown): Locator | null;
|
|
2
4
|
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
|
|
3
5
|
expect: ReturnType<typeof createHealingExpect>;
|
|
4
6
|
}, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixtures/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixtures/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EAER,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAWpD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAIpE;AA02BD,eAAO,MAAM,IAAI;YACP,UAAU,CAAC,OAAO,mBAAmB,CAAC;wGA+F9C,CAAC;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/fixtures/index.js
CHANGED
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createHealingExpect = exports.test = void 0;
|
|
37
|
+
exports.resolveFixwrightProxy = resolveFixwrightProxy;
|
|
37
38
|
const test_1 = require("@playwright/test");
|
|
38
39
|
const StackUtils_1 = require("../utils/StackUtils");
|
|
39
40
|
const HealingRegistry_1 = require("../engine/HealingRegistry");
|
|
@@ -43,6 +44,15 @@ const fs = __importStar(require("fs"));
|
|
|
43
44
|
const path = __importStar(require("path"));
|
|
44
45
|
const registry = HealingRegistry_1.HealingRegistry.getInstance();
|
|
45
46
|
const proxyToActiveLocator = new WeakMap();
|
|
47
|
+
// Module-level resolver — moduleExpect.ts uses this to unwrap a Fixwright
|
|
48
|
+
// locator proxy back to its live underlying Playwright Locator without
|
|
49
|
+
// needing access to the WeakMap directly.
|
|
50
|
+
function resolveFixwrightProxy(value) {
|
|
51
|
+
if (!value || typeof value !== "object")
|
|
52
|
+
return null;
|
|
53
|
+
const getActive = proxyToActiveLocator.get(value);
|
|
54
|
+
return getActive ? getActive() : null;
|
|
55
|
+
}
|
|
46
56
|
// ─── Action classification (identical to original) ────────────────
|
|
47
57
|
const INTERCEPTED_ACTIONS = [
|
|
48
58
|
"click",
|
|
@@ -461,6 +471,12 @@ function createFrameLocatorProxy(rawFrameLocator, frameSelector, rawPage, testTi
|
|
|
461
471
|
// 3. Exposes _fixwrightUnsubscribe so the fixture can clean up.
|
|
462
472
|
// ─────────────────────────────────────────────────────────────────
|
|
463
473
|
function createLocatorProxy(rawLocator, selector, rawPage, testTitle, actionCounter, elementSelectorOnly) {
|
|
474
|
+
// Defensive: Proxy ctor throws "Cannot create proxy with a non-object as target"
|
|
475
|
+
// when downstream callers (e.g. chained traps) pass a non-Locator return value.
|
|
476
|
+
// Returning the raw value lets the caller see it unchanged instead of crashing.
|
|
477
|
+
if (rawLocator === null || rawLocator === undefined || typeof rawLocator !== "object") {
|
|
478
|
+
return rawLocator;
|
|
479
|
+
}
|
|
464
480
|
// ── Resolve immediately (handles post-heal proxy creation) ────
|
|
465
481
|
const initialResolved = registry.resolveSelector(selector);
|
|
466
482
|
let currentFullSelector = initialResolved;
|
|
@@ -517,9 +533,13 @@ function createLocatorProxy(rawLocator, selector, rawPage, testTitle, actionCoun
|
|
|
517
533
|
// ── getBy* ───────────────────────────────────────────────
|
|
518
534
|
if (prop in GET_BY_METHODS) {
|
|
519
535
|
return (...args) => {
|
|
536
|
+
const nextLocator = activeLocator[prop](...args);
|
|
537
|
+
if (nextLocator === null || nextLocator === undefined || typeof nextLocator !== "object") {
|
|
538
|
+
return nextLocator;
|
|
539
|
+
}
|
|
520
540
|
const semanticSelector = GET_BY_METHODS[prop](args);
|
|
521
541
|
const childFullSelector = `${currentFullSelector} >> ${semanticSelector}`;
|
|
522
|
-
return createLocatorProxy(
|
|
542
|
+
return createLocatorProxy(nextLocator, childFullSelector, rawPage, testTitle, actionCounter, semanticSelector);
|
|
523
543
|
};
|
|
524
544
|
}
|
|
525
545
|
// ── Chainable methods ────────────────────────────────────
|
|
@@ -527,6 +547,9 @@ function createLocatorProxy(rawLocator, selector, rawPage, testTitle, actionCoun
|
|
|
527
547
|
if (chainables.includes(prop)) {
|
|
528
548
|
return (...args) => {
|
|
529
549
|
const nextLocator = activeLocator[prop](...args);
|
|
550
|
+
if (nextLocator === null || nextLocator === undefined || typeof nextLocator !== "object") {
|
|
551
|
+
return nextLocator;
|
|
552
|
+
}
|
|
530
553
|
let nextFull = currentFullSelector;
|
|
531
554
|
let nextElement = currentElementSelector;
|
|
532
555
|
if (prop === "locator") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moduleExpect.d.ts","sourceRoot":"","sources":["../../src/fixtures/moduleExpect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"moduleExpect.d.ts","sourceRoot":"","sources":["../../src/fixtures/moduleExpect.ts"],"names":[],"mappings":"AAuCA,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAa1C"}
|
|
@@ -7,6 +7,7 @@ exports.expect = expect;
|
|
|
7
7
|
const test_1 = require("@playwright/test");
|
|
8
8
|
const singleton_js_1 = require("../engine/singleton.js");
|
|
9
9
|
const expectProxy_js_1 = require("./expectProxy.js");
|
|
10
|
+
const index_js_1 = require("./index.js");
|
|
10
11
|
function extractPage(value) {
|
|
11
12
|
if (!value || typeof value !== 'object')
|
|
12
13
|
return null;
|
|
@@ -40,7 +41,7 @@ function expect(value) {
|
|
|
40
41
|
const page = extractPage(value);
|
|
41
42
|
if (page) {
|
|
42
43
|
const filePath = getCallerFile();
|
|
43
|
-
return (0, expectProxy_js_1.createHealingExpect)(singleton_js_1.sharedEngine, page, filePath, 0)(value);
|
|
44
|
+
return (0, expectProxy_js_1.createHealingExpect)(singleton_js_1.sharedEngine, page, filePath, 0, index_js_1.resolveFixwrightProxy)(value);
|
|
44
45
|
}
|
|
45
46
|
return (0, test_1.expect)(value);
|
|
46
47
|
}
|