@immense/vue-pom-generator 1.0.79 → 1.0.80
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/RELEASE_NOTES.md +40 -21
- package/dist/index.cjs +63 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +63 -0
- package/dist/index.mjs.map +1 -1
- package/dist/transform.d.ts.map +1 -1
- package/dist/utils.d.ts +24 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,36 +1,55 @@
|
|
|
1
|
+
I'll examine the actual diff for PR #42 to write accurate release notes.
|
|
2
|
+
|
|
3
|
+
Now I have full context. Only PR #42 is in the v1.0.79..HEAD diff (confirmed via git log). The other
|
|
4
|
+
listed PRs were already in prior tags. Here are the release notes:
|
|
5
|
+
|
|
1
6
|
Highlights
|
|
2
7
|
|
|
3
|
-
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
(
|
|
8
|
-
|
|
8
|
+
- Singleton accessors for slot-scope callback click handlers — when a scoped slot exposes an event
|
|
9
|
+
callback (e.g. toggle from <template #trigger="{ toggle }">), a @click="toggle" button now generates
|
|
10
|
+
a plain singleton test id instead of a keyed accessor, since the slot renders a single control
|
|
11
|
+
rather than one row per iteration.
|
|
12
|
+
- Recognizes common callback wrappers — bare identifiers, withModifiers(fn, […]) /
|
|
13
|
+
_withModifiers(…), and arrow expression bodies (() => fn) — while method calls (remove(item)) and
|
|
14
|
+
member access (data.action()) correctly remain keyed as per-iteration row data.
|
|
15
|
+
- Two new regression tests covering the bare-callback and withModifiers-wrapped cases.
|
|
9
16
|
|
|
10
17
|
Changes
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
Transform logic
|
|
20
|
+
|
|
21
|
+
- Added isSlotScopeCallbackClickHandler check in transform.ts: when an element's @click handler is
|
|
22
|
+
a bare identifier matching an enclosing slot-scope variable, the keyed-slot path is bypassed (return
|
|
23
|
+
null) so a singleton accessor is emitted.
|
|
24
|
+
- Method-call and member-access handlers are unaffected and retain their keyed selectors.
|
|
25
|
+
|
|
26
|
+
Utilities (utils.ts)
|
|
27
|
+
|
|
28
|
+
- unwrapToBareCallbackIdentifier — recursively unwraps a parsed click-handler AST to a plain
|
|
29
|
+
identifier name, handling withModifiers/_withModifiers call wrappers, arrow expression bodies, and
|
|
30
|
+
expression-statement envelopes. Returns null for method calls, member access, assignments, and
|
|
31
|
+
conditionals.
|
|
32
|
+
- tryGetBareCallbackClickHandlerName — extracts the bare callback name from an element's @click
|
|
33
|
+
directive, parsing the handler source into a Babel AST.
|
|
34
|
+
- isSlotScopeCallbackClickHandler — determines whether an element is a singleton trigger inside a
|
|
35
|
+
scoped slot by cross-referencing the handler name against the slot's scope variables.
|
|
36
|
+
|
|
37
|
+
Tests
|
|
38
|
+
|
|
39
|
+
- Added test: emits a singleton (non-keyed) test id (MyComp-Toggle-button) for a bare slot-scope
|
|
40
|
+
callback click handler.
|
|
41
|
+
- Added test: emits a singleton test id for a callback wrapped in withModifiers.
|
|
17
42
|
|
|
18
43
|
Breaking Changes
|
|
19
44
|
|
|
20
|
-
|
|
21
|
-
consumers must use to wire up Playwright tests. Update any imports of the generated test to use
|
|
22
|
-
withPomFixtures instead. (#39)
|
|
45
|
+
None.
|
|
23
46
|
|
|
24
47
|
Pull Requests Included
|
|
25
48
|
|
|
26
|
-
- ]8;id=md-
|
|
27
|
-
- ]8;id=md-fg7y2m;https://github.com/immense/vue-pom-generator/pull/40#40]8;;]8;; — chore: remove product-specific (Immy/Ayla) heuristics and fixtures]8;;
|
|
28
|
-
- ]8;id=md-1d0dvwm;https://github.com/immense/vue-pom-generator/pull/39#39]8;;]8;; — feat!: export withPomFixtures instead of a generated test]8;;
|
|
29
|
-
- ]8;id=md-1dadhll;https://github.com/immense/vue-pom-generator/pull/38#38]8;;]8;; — fix: drop self-referential child instance for recursively-nested components]8;;
|
|
49
|
+
- ]8;id=md-ew8qoo;https://github.com/immense/vue-pom-generator/pull/42#42 — feat: emit singleton accessor for slot-scope callback click handlers]8;;]8;; (@dkattan)]8;;
|
|
30
50
|
|
|
31
51
|
Testing
|
|
32
52
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
withPomFixtures API and the recursive-nesting fix.
|
|
53
|
+
Two new unit tests added in tests/transform.test.ts covering bare and withModifiers-wrapped
|
|
54
|
+
slot-scope callback handlers; both assert singleton (non-keyed) test id generation.
|
|
36
55
|
|
package/dist/index.cjs
CHANGED
|
@@ -1544,6 +1544,66 @@ function tryExtractSlotScopeVariableNames(expression) {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
return names;
|
|
1546
1546
|
}
|
|
1547
|
+
function unwrapToBareCallbackIdentifier(node) {
|
|
1548
|
+
if (!node) {
|
|
1549
|
+
return null;
|
|
1550
|
+
}
|
|
1551
|
+
if (types.isFile(node)) {
|
|
1552
|
+
const stmt = node.program.body[0];
|
|
1553
|
+
return types.isExpressionStatement(stmt) ? unwrapToBareCallbackIdentifier(stmt.expression) : null;
|
|
1554
|
+
}
|
|
1555
|
+
if (types.isProgram(node)) {
|
|
1556
|
+
const stmt = node.body[0];
|
|
1557
|
+
return types.isExpressionStatement(stmt) ? unwrapToBareCallbackIdentifier(stmt.expression) : null;
|
|
1558
|
+
}
|
|
1559
|
+
if (types.isExpressionStatement(node)) {
|
|
1560
|
+
return unwrapToBareCallbackIdentifier(node.expression);
|
|
1561
|
+
}
|
|
1562
|
+
if (types.isIdentifier(node)) {
|
|
1563
|
+
return node.name;
|
|
1564
|
+
}
|
|
1565
|
+
if (types.isCallExpression(node) || types.isOptionalCallExpression(node)) {
|
|
1566
|
+
const callee = node.callee;
|
|
1567
|
+
if (types.isIdentifier(callee) && (callee.name === "withModifiers" || callee.name === "_withModifiers")) {
|
|
1568
|
+
return unwrapToBareCallbackIdentifier(node.arguments[0]);
|
|
1569
|
+
}
|
|
1570
|
+
return null;
|
|
1571
|
+
}
|
|
1572
|
+
if (types.isArrowFunctionExpression(node)) {
|
|
1573
|
+
return types.isBlockStatement(node.body) ? null : unwrapToBareCallbackIdentifier(node.body);
|
|
1574
|
+
}
|
|
1575
|
+
return null;
|
|
1576
|
+
}
|
|
1577
|
+
function tryGetBareCallbackClickHandlerName(node) {
|
|
1578
|
+
const click = tryGetClickDirective(node);
|
|
1579
|
+
if (!click?.exp) {
|
|
1580
|
+
return null;
|
|
1581
|
+
}
|
|
1582
|
+
const source = getVueExpressionSource(click.exp, "content", "compiled");
|
|
1583
|
+
if (!source) {
|
|
1584
|
+
return null;
|
|
1585
|
+
}
|
|
1586
|
+
const parsed = tryParseBabelAstFromHandlerSource(source);
|
|
1587
|
+
if (!parsed) {
|
|
1588
|
+
return null;
|
|
1589
|
+
}
|
|
1590
|
+
return unwrapToBareCallbackIdentifier(parsed);
|
|
1591
|
+
}
|
|
1592
|
+
function isSlotScopeCallbackClickHandler(node, hierarchyMap2) {
|
|
1593
|
+
const handlerName = tryGetBareCallbackClickHandlerName(node);
|
|
1594
|
+
if (!handlerName) {
|
|
1595
|
+
return false;
|
|
1596
|
+
}
|
|
1597
|
+
const templateNode = getContainedInSlotTemplateNode(node, hierarchyMap2);
|
|
1598
|
+
if (!templateNode) {
|
|
1599
|
+
return false;
|
|
1600
|
+
}
|
|
1601
|
+
const scopeExpression = findTemplateSlotScopeExpression(templateNode);
|
|
1602
|
+
if (!scopeExpression) {
|
|
1603
|
+
return false;
|
|
1604
|
+
}
|
|
1605
|
+
return tryExtractSlotScopeVariableNames(scopeExpression).includes(handlerName);
|
|
1606
|
+
}
|
|
1547
1607
|
function nodeHasToDirective(node) {
|
|
1548
1608
|
const toDirective = findDirectiveByName(node, "bind", "to");
|
|
1549
1609
|
if (toDirective?.exp) {
|
|
@@ -7502,6 +7562,9 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
7502
7562
|
}
|
|
7503
7563
|
const slotKeyInfo = getContainedInSlotDataKeyInfo(element, hierarchyMap);
|
|
7504
7564
|
if (slotKeyInfo) {
|
|
7565
|
+
if (isSlotScopeCallbackClickHandler(element, hierarchyMap)) {
|
|
7566
|
+
return null;
|
|
7567
|
+
}
|
|
7505
7568
|
return slotKeyInfo;
|
|
7506
7569
|
}
|
|
7507
7570
|
if (crossFileKeyRegistry) {
|