@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 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
- - Breaking API change: the generator now exports withPomFixtures instead of a generated test
4
- function, giving consumers explicit control over Playwright fixture wiring (#39)
5
- - Fixed a self-referential child instance created for recursively-nested components (#38)
6
- - Removed product-specific (Immy/Ayla) heuristics and fixtures, making the generator fully generic
7
- (#40)
8
- - Deleted stale pom-element-wrapper design and implementation plan documents (#41)
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
- - Generation API: Export withPomFixtures instead of generating a test function; README,
13
- generated-tsc fixtures, and test suites updated to match (#39)
14
- - Bug fix: Drop the self-referential child instance created for recursively-nested components (#38)
15
- - Cleanup: Remove product-specific (Immy/Ayla) heuristics and fixtures from class generation (#40)
16
- - Docs: Remove stale pom-element-wrapper design and implementation plan documents (#41)
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
- - The generator no longer emits a generated test function. It now exports withPomFixtures, which
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-fq7jrl;https://github.com/immense/vue-pom-generator/pull/41#41]8;;]8;; — chore: remove stale pom-element-wrapper plan docs]8;;
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
- - Updated test suites (generated-tsc, transform, class-generation-coverage, existing-id-error,
34
- utils-coverage) and regenerated TypeScript fixtures (playwright-test.d.ts) to reflect the new
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) {