@immense/vue-pom-generator 1.0.78 → 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/README.md CHANGED
@@ -136,8 +136,26 @@ test("shows the list", async ({ page }) => {
136
136
 
137
137
  **After**
138
138
 
139
+ First compose your project's `test` once. The generator does **not** export a `test` — it
140
+ exports `withPomFixtures`, which attaches the generated POM fixtures to a base you own:
141
+
142
+ ```ts
143
+ // tests/playwright/test-base.ts
144
+ import { test as playwrightTest, expect } from "@playwright/test";
145
+ import { withPomFixtures } from "./__generated__/fixtures.g";
146
+
147
+ // Anything added here is inherited by every spec: console-error capture,
148
+ // error-overlay detection, auth, API cleanup, ...
149
+ const base = playwrightTest.extend({ /* project-wide fixtures */ });
150
+
151
+ export const test = withPomFixtures(base);
152
+ export { expect };
153
+ ```
154
+
155
+ Then specs import `test` from that module:
156
+
139
157
  ```ts
140
- import { test, expect } from "../tests/playwright/__generated__/fixtures.g";
158
+ import { test, expect } from "../tests/playwright/test-base";
141
159
 
142
160
  test("shows the list", async ({ userListPage }) => {
143
161
  await userListPage.goTo();
@@ -150,6 +168,8 @@ Why this is better:
150
168
  - less setup noise in tests
151
169
  - fixture types stay aligned with generated classes
152
170
  - if `tests/playwright/pom/overrides/UserListPage.ts` exists, the fixture will instantiate that override class automatically
171
+ - there is exactly one `test` object in the project, so project-wide fixtures cannot silently
172
+ miss some specs
153
173
 
154
174
  Without fixtures, you still use the generated POMs, but every test has to construct them manually.
155
175
 
@@ -612,6 +632,27 @@ Without `flatten`, helper composition still works; you just call through the hel
612
632
 
613
633
  When `generation.playwright.fixtures` is enabled, the generator emits a strongly typed Playwright fixture module.
614
634
 
635
+ ### The generated module does not own `test`
636
+
637
+ `fixtures.g.ts` exports `withPomFixtures`, not a ready-made `test`. Owning the `test` object
638
+ is a project concern: a project needs exactly one `test` so that project-wide fixtures
639
+ (console-error capture, error-overlay detection, auth) are inherited by *every* spec. If the
640
+ generator exported its own `test`, a project would end up with two runners and specs would
641
+ silently miss whichever fixtures were attached to the other one.
642
+
643
+ ```ts
644
+ // tests/playwright/test-base.ts — the single `test` your specs import
645
+ import { test as playwrightTest, expect } from "@playwright/test";
646
+ import { withPomFixtures } from "./__generated__/fixtures.g";
647
+
648
+ export const test = withPomFixtures(playwrightTest.extend({ /* project-wide fixtures */ }));
649
+ export { expect };
650
+ ```
651
+
652
+ The module also exports the fixture types (`PomFixtures`, `GeneratedPageFixtures`,
653
+ `GeneratedComponentFixtures`, `PlaywrightOptions`, `PomFactory`) and re-exports `expect`
654
+ for convenience.
655
+
615
656
  What it gives you:
616
657
 
617
658
  - lower-camel-case fixtures for views (`UserListPage` → `userListPage`)
@@ -622,6 +663,7 @@ What it gives you:
622
663
 
623
664
  Current caveats:
624
665
 
666
+ - `withPomFixtures` requires a base whose test args include Playwright's `page` (i.e. anything derived from `@playwright/test`'s `test`)
625
667
  - there are no generated `openXPage` helpers; tests call `goTo()` explicitly when available
626
668
  - override preference only affects fixture construction
627
669
  - component fixtures are skipped when their lower-camel-case name would collide with reserved Playwright fixture names such as `page`, `context`, `browser`, or `request`
@@ -808,8 +850,9 @@ Why it exists:
808
850
  Recommended usage:
809
851
 
810
852
  1. enable generated fixtures in the generator
811
- 2. migrate specs from `({ page })` to generated fixtures like `({ dashboardPage })`
812
- 3. turn this rule on for `tests/playwright/**/*.spec.ts`
853
+ 2. compose a single project `test` with `withPomFixtures` (see the fixtures section) and have specs import it
854
+ 3. migrate specs from `({ page })` to generated fixtures like `({ dashboardPage })`
855
+ 4. turn this rule on for `tests/playwright/**/*.spec.ts`
813
856
 
814
857
  Example flat config:
815
858
 
package/RELEASE_NOTES.md CHANGED
@@ -1,73 +1,55 @@
1
- I'll verify which PRs actually fall within the release window by checking their merge timestamps via
2
- the GitHub API.
1
+ I'll examine the actual diff for PR #42 to write accurate release notes.
3
2
 
4
- Let me verify the v1.0.77 tag position relative to PR #36's merge.
5
-
6
- v1.0.77 points to #36's merge commit, confirming #36 belongs to the prior release. Only #37 (plus a
7
- follow-up test commit) is in v1.0.78. Let me get the PR details and diff for accurate notes.
8
-
9
- Let me check the plugin wiring changes to fully understand the feature.
10
-
11
- I now have everything needed. Verification summary:
12
-
13
- - v1.0.77 tag = e5b00f4 (PR #36 merge), so #36 belongs to the prior release.
14
- - Range v1.0.77..HEAD contains only #37's merge commit (03d66fa) plus a follow-up test fix
15
- (d12efe7).
16
- - The long PR list in the prompt spans months; only #37 falls in the release window and git range.
17
-
18
- -----------------------------------------------------------------------------------------------
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:
19
5
 
20
6
  Highlights
21
7
 
22
- - Introduces a cross-file key registry so child components rendered inside keyed slot scopes (e.g.
23
- <template #item="{ data, key }">) get automatically keyed testids
24
- - Parent templates record which prop receives the slot-scope data; child components look up the
25
- registry to key their internal testids (e.g. RolePermissionSubject-${subject.key ?? subject.id ??
26
- …}-SelectAll-button)
27
- - Relies on Rolldown's depth-first module processing to guarantee the parent is always compiled
28
- before the child
29
- - Threads the shared registry through both the build and dev plugin pipelines
30
- - Adds new slot-scope variable extraction utilities plus positive/negative regression tests
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.
31
16
 
32
17
  Changes
33
18
 
34
- Cross-file key registry
19
+ Transform logic
35
20
 
36
- - Added CrossFileKeyRegistry type (Map<string, string>) exported from transform.ts
37
- - Parent transform records childComponentName → slotDataPropName when a component is rendered
38
- inside a v-slot keyed scope
39
- - Child transform consults the registry to build a keyed fallback expression when no in-file slot
40
- key is found
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.
41
25
 
42
- Plugin pipeline
26
+ Utilities (utils.ts)
43
27
 
44
- - Threaded crossFileKeyRegistry through createVuePomGeneratorPlugins, createInternalPlugins, the
45
- build processor, the dev processor, and the Vue plugin
46
- - Build mode shares the registry across files; dev mode uses a provisional per-file key registry
47
- - Added crossFileKeyRegistry to shared generator state
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.
48
36
 
49
- Utilities
37
+ Tests
50
38
 
51
- - New tryExtractSlotScopeVariableNames parses slot-scope bindings (simple identifiers, object
52
- destructuring, aliases, rest elements)
53
- - New getContainedInSlotTemplateNode walks the hierarchy map to the nearest enclosing scoped-slot
54
- <template>
55
- - Refactored getContainedInSlotDataKeyInfo to reuse getContainedInSlotTemplateNode
56
- - Exported previously-internal helpers: findTemplateSlotScopeExpression,
57
- buildSlotScopeFallbackKeyExpression, toResolvedKeyInfo, tryGetTemplateSlotScopeKeyInfo
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.
58
42
 
59
- Tests
43
+ Breaking Changes
60
44
 
61
- - Added transform tests for the cross-file key registry (keyed case and non-keyed negative case)
62
- - Updated the vue-plugin-state test to include crossFileKeyRegistry in shared state
45
+ None.
63
46
 
64
47
  Pull Requests Included
65
48
 
66
- - #37 feat: cross-file key registry for child components in keyed slots — by @dkattan
67
- (]8;id=md-1fs9wuc;https://github.com/immense/vue-pom-generator/pull/37https://github.com/immense/vue-pom-generator/pull/37]8;;]8;;)]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;;
68
50
 
69
51
  Testing
70
52
 
71
- All 204 tests pass per PR #37, including new cross-file key registry regression tests covering both
72
- the keyed and non-keyed cases.
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.
73
55
 
@@ -1417,17 +1417,24 @@ function maybeGenerateFixtureRegistry(
1417
1417
  const fixturesContent = renderSourceFile(fixtureFileName, (sourceFile) => {
1418
1418
  sourceFile.addStatements("/** Generated Playwright fixtures (typed page objects). */");
1419
1419
 
1420
+ // NOTE: this file intentionally does NOT create or export a `test` runner.
1421
+ // Owning the `test` object is a project concern, not a code-generation concern:
1422
+ // projects need to attach their own global fixtures (console-error capture,
1423
+ // error-overlay detection, auth, ...) and there must be exactly one `test` that
1424
+ // specs import. Instead we export `withPomFixtures`, which attaches the generated
1425
+ // POM fixtures to whatever base `test` the project owns.
1420
1426
  addNamedImport(sourceFile, {
1421
1427
  moduleSpecifier: "@playwright/test",
1422
- namedImports: [
1423
- "expect",
1424
- { name: "test", alias: "base" },
1425
- ],
1428
+ namedImports: ["expect"],
1426
1429
  });
1427
1430
  addNamedImport(sourceFile, {
1428
1431
  moduleSpecifier: "@playwright/test",
1429
1432
  isTypeOnly: true,
1430
- namedImports: [{ name: "Page", alias: "PwPage" }],
1433
+ namedImports: [
1434
+ { name: "Page", alias: "PwPage" },
1435
+ "PlaywrightTestArgs",
1436
+ "TestType",
1437
+ ],
1431
1438
  });
1432
1439
  sourceFile.addImportDeclaration({
1433
1440
  namespaceImport: "Pom",
@@ -1514,6 +1521,15 @@ function maybeGenerateFixtureRegistry(
1514
1521
  name: "GeneratedComponentFixtures",
1515
1522
  type: "{ [K in keyof typeof componentCtors]: InstanceType<(typeof componentCtors)[K]> }",
1516
1523
  });
1524
+ sourceFile.addTypeAlias({
1525
+ isExported: true,
1526
+ name: "PomFixtures",
1527
+ docs: [{
1528
+ description: "Every fixture contributed by the generator: the `animation` option, the internal\n"
1529
+ + "`pomSetup`/`pomFactory` fixtures, and one fixture per generated page/component POM.",
1530
+ }],
1531
+ type: "PlaywrightOptions & PomSetupFixture & PomFactoryFixture & GeneratedPageFixtures & GeneratedComponentFixtures",
1532
+ });
1517
1533
 
1518
1534
  sourceFile.addFunction({
1519
1535
  name: "makePomFixture",
@@ -1538,44 +1554,66 @@ function maybeGenerateFixtureRegistry(
1538
1554
  ],
1539
1555
  });
1540
1556
 
1541
- sourceFile.addVariableStatement({
1542
- declarationKind: VariableDeclarationKind.Const,
1543
- declarations: [{
1544
- name: "test",
1545
- initializer: (writer) => {
1546
- writer.write("base.extend<PlaywrightOptions & PomSetupFixture & PomFactoryFixture & GeneratedPageFixtures & GeneratedComponentFixtures>(");
1547
- writer.block(() => {
1548
- writer.writeLine("animation: [{");
1549
- writer.indent(() => {
1550
- writer.writeLine('pointer: { durationMilliseconds: 250, transitionStyle: "ease-in-out", clickDelayMilliseconds: 0 },');
1551
- writer.writeLine("keyboard: { typeDelayMilliseconds: 100 },");
1552
- });
1553
- writer.writeLine("}, { option: true }],");
1554
- writer.writeLine("pomSetup: [async ({ animation }, use) => {");
1555
- writer.indent(() => {
1556
- writer.writeLine("Pom.setPlaywrightAnimationOptions(animation);");
1557
- writer.writeLine("await use();");
1558
- });
1559
- writer.writeLine("}, { auto: true }],");
1560
- writer.writeLine("pomFactory: async ({ page }, use) => {");
1557
+ sourceFile.addStatements([
1558
+ "/**",
1559
+ " * Attach the generated POM fixtures to a project-owned Playwright `test`.",
1560
+ " *",
1561
+ " * This generator deliberately does not export a `test` of its own. Projects should own",
1562
+ " * exactly one `test` object so project-wide fixtures (console-error capture, error-overlay",
1563
+ " * detection, auth, ...) are inherited by every spec. Compose it once in a project module:",
1564
+ " *",
1565
+ " * const base = playwrightTest.extend({ ...project-wide fixtures... });",
1566
+ " * export const test = withPomFixtures(base);",
1567
+ " *",
1568
+ " * Then have every spec import `test` from that module.",
1569
+ " */",
1570
+ ].join("\n"));
1571
+ sourceFile.addFunction({
1572
+ isExported: true,
1573
+ name: "withPomFixtures",
1574
+ typeParameters: [
1575
+ { name: "TTestArgs", constraint: "PlaywrightTestArgs" },
1576
+ { name: "TWorkerArgs", constraint: "object" },
1577
+ ],
1578
+ parameters: [{ name: "base", type: "TestType<TTestArgs, TWorkerArgs>" }],
1579
+ returnType: "TestType<TTestArgs & PomFixtures, TWorkerArgs>",
1580
+ statements: (writer) => {
1581
+ writer.write("return base.extend<PomFixtures>(");
1582
+ writer.block(() => {
1583
+ writer.writeLine("animation: [{");
1584
+ writer.indent(() => {
1585
+ writer.writeLine('pointer: { durationMilliseconds: 250, transitionStyle: "ease-in-out", clickDelayMilliseconds: 0 },');
1586
+ writer.writeLine("keyboard: { typeDelayMilliseconds: 100 },");
1587
+ });
1588
+ writer.writeLine("}, { option: true }],");
1589
+ // The fixture callbacks are annotated explicitly rather than relying on
1590
+ // contextual typing: `base` is generic here, so TypeScript cannot resolve
1591
+ // Playwright's `Fixtures<...>` parameter types and the callbacks would
1592
+ // otherwise be implicitly `any` (an error under `noImplicitAny`).
1593
+ writer.writeLine("pomSetup: [async ({ animation }: PomFixtures, use: (r: void) => Promise<void>) => {");
1594
+ writer.indent(() => {
1595
+ writer.writeLine("Pom.setPlaywrightAnimationOptions(animation);");
1596
+ writer.writeLine("await use();");
1597
+ });
1598
+ writer.writeLine("}, { auto: true }],");
1599
+ writer.writeLine("pomFactory: async ({ page }: { page: PwPage }, use: (r: PomFactory) => Promise<void>) => {");
1600
+ writer.indent(() => {
1601
+ writer.writeLine("await use({");
1561
1602
  writer.indent(() => {
1562
- writer.writeLine("await use({");
1563
- writer.indent(() => {
1564
- writer.writeLine("create: <T>(ctor: PomConstructor<T>) => new ctor(page),");
1565
- });
1566
- writer.writeLine("});");
1603
+ writer.writeLine("create: <T>(ctor: PomConstructor<T>) => new ctor(page),");
1567
1604
  });
1568
- writer.writeLine("},");
1569
- writer.writeLine("...createPomFixtures(pageCtors),");
1570
- writer.writeLine("...createPomFixtures(componentCtors),");
1605
+ writer.writeLine("});");
1571
1606
  });
1572
- writer.write(")");
1573
- },
1574
- }],
1607
+ writer.writeLine("},");
1608
+ writer.writeLine("...createPomFixtures(pageCtors),");
1609
+ writer.writeLine("...createPomFixtures(componentCtors),");
1610
+ });
1611
+ writer.write(") as TestType<TTestArgs & PomFixtures, TWorkerArgs>;");
1612
+ },
1575
1613
  });
1576
1614
 
1577
1615
  sourceFile.addExportDeclaration({
1578
- namedExports: ["test", "expect"],
1616
+ namedExports: ["expect"],
1579
1617
  });
1580
1618
  }, {
1581
1619
  prefixText: buildFilePrefix({
@@ -1640,9 +1678,21 @@ function prepareViewObjectModelClass(
1640
1678
  const rawComponentRefsForInstances = usedComponentSet?.size
1641
1679
  ? usedComponentSet
1642
1680
  : childrenComponentSet;
1681
+ // A component may render itself recursively (e.g. a tree/list that nests same-named
1682
+ // children). Without this guard the generator emits `this.<SelfName> = new <SelfName>(page)`
1683
+ // in the constructor, which infinitely recurses the moment any POM transitively
1684
+ // instantiates this class. A self-reference is never a useful child instance (it would
1685
+ // just re-wrap the same page), so drop it before it becomes a property + ctor assignment.
1686
+ const ownClassName = toPascalCaseLocal(componentName);
1687
+ const isSelfReference = (ref: string): boolean => {
1688
+ return toPascalCaseLocal(normalizeTrackedComponentRef(ref)) === ownClassName && ownClassName.length > 0;
1689
+ };
1643
1690
  const componentRefsForInstances = new Set<string>();
1644
1691
  for (const ref of rawComponentRefsForInstances) {
1645
1692
  const resolvedRef = resolveTrackedComponentRef(ref) ?? normalizeTrackedComponentRef(ref);
1693
+ if (isSelfReference(resolvedRef)) {
1694
+ continue;
1695
+ }
1646
1696
  const resolvedDependencies = componentHierarchyMap.get(resolvedRef);
1647
1697
  if (!resolvedDependencies?.dataTestIdSet.size) {
1648
1698
  continue;
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) {
@@ -5526,15 +5586,16 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
5526
5586
  sourceFile.addStatements("/** Generated Playwright fixtures (typed page objects). */");
5527
5587
  addNamedImport(sourceFile, {
5528
5588
  moduleSpecifier: "@playwright/test",
5529
- namedImports: [
5530
- "expect",
5531
- { name: "test", alias: "base" }
5532
- ]
5589
+ namedImports: ["expect"]
5533
5590
  });
5534
5591
  addNamedImport(sourceFile, {
5535
5592
  moduleSpecifier: "@playwright/test",
5536
5593
  isTypeOnly: true,
5537
- namedImports: [{ name: "Page", alias: "PwPage" }]
5594
+ namedImports: [
5595
+ { name: "Page", alias: "PwPage" },
5596
+ "PlaywrightTestArgs",
5597
+ "TestType"
5598
+ ]
5538
5599
  });
5539
5600
  sourceFile.addImportDeclaration({
5540
5601
  namespaceImport: "Pom",
@@ -5618,6 +5679,14 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
5618
5679
  name: "GeneratedComponentFixtures",
5619
5680
  type: "{ [K in keyof typeof componentCtors]: InstanceType<(typeof componentCtors)[K]> }"
5620
5681
  });
5682
+ sourceFile.addTypeAlias({
5683
+ isExported: true,
5684
+ name: "PomFixtures",
5685
+ docs: [{
5686
+ description: "Every fixture contributed by the generator: the `animation` option, the internal\n`pomSetup`/`pomFactory` fixtures, and one fixture per generated page/component POM."
5687
+ }],
5688
+ type: "PlaywrightOptions & PomSetupFixture & PomFactoryFixture & GeneratedPageFixtures & GeneratedComponentFixtures"
5689
+ });
5621
5690
  sourceFile.addFunction({
5622
5691
  name: "makePomFixture",
5623
5692
  typeParameters: [{ name: "T" }],
@@ -5640,43 +5709,61 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
5640
5709
  "return out as any;"
5641
5710
  ]
5642
5711
  });
5643
- sourceFile.addVariableStatement({
5644
- declarationKind: tsMorph.VariableDeclarationKind.Const,
5645
- declarations: [{
5646
- name: "test",
5647
- initializer: (writer) => {
5648
- writer.write("base.extend<PlaywrightOptions & PomSetupFixture & PomFactoryFixture & GeneratedPageFixtures & GeneratedComponentFixtures>(");
5649
- writer.block(() => {
5650
- writer.writeLine("animation: [{");
5651
- writer.indent(() => {
5652
- writer.writeLine('pointer: { durationMilliseconds: 250, transitionStyle: "ease-in-out", clickDelayMilliseconds: 0 },');
5653
- writer.writeLine("keyboard: { typeDelayMilliseconds: 100 },");
5654
- });
5655
- writer.writeLine("}, { option: true }],");
5656
- writer.writeLine("pomSetup: [async ({ animation }, use) => {");
5657
- writer.indent(() => {
5658
- writer.writeLine("Pom.setPlaywrightAnimationOptions(animation);");
5659
- writer.writeLine("await use();");
5660
- });
5661
- writer.writeLine("}, { auto: true }],");
5662
- writer.writeLine("pomFactory: async ({ page }, use) => {");
5712
+ sourceFile.addStatements([
5713
+ "/**",
5714
+ " * Attach the generated POM fixtures to a project-owned Playwright `test`.",
5715
+ " *",
5716
+ " * This generator deliberately does not export a `test` of its own. Projects should own",
5717
+ " * exactly one `test` object so project-wide fixtures (console-error capture, error-overlay",
5718
+ " * detection, auth, ...) are inherited by every spec. Compose it once in a project module:",
5719
+ " *",
5720
+ " * const base = playwrightTest.extend({ ...project-wide fixtures... });",
5721
+ " * export const test = withPomFixtures(base);",
5722
+ " *",
5723
+ " * Then have every spec import `test` from that module.",
5724
+ " */"
5725
+ ].join("\n"));
5726
+ sourceFile.addFunction({
5727
+ isExported: true,
5728
+ name: "withPomFixtures",
5729
+ typeParameters: [
5730
+ { name: "TTestArgs", constraint: "PlaywrightTestArgs" },
5731
+ { name: "TWorkerArgs", constraint: "object" }
5732
+ ],
5733
+ parameters: [{ name: "base", type: "TestType<TTestArgs, TWorkerArgs>" }],
5734
+ returnType: "TestType<TTestArgs & PomFixtures, TWorkerArgs>",
5735
+ statements: (writer) => {
5736
+ writer.write("return base.extend<PomFixtures>(");
5737
+ writer.block(() => {
5738
+ writer.writeLine("animation: [{");
5739
+ writer.indent(() => {
5740
+ writer.writeLine('pointer: { durationMilliseconds: 250, transitionStyle: "ease-in-out", clickDelayMilliseconds: 0 },');
5741
+ writer.writeLine("keyboard: { typeDelayMilliseconds: 100 },");
5742
+ });
5743
+ writer.writeLine("}, { option: true }],");
5744
+ writer.writeLine("pomSetup: [async ({ animation }: PomFixtures, use: (r: void) => Promise<void>) => {");
5745
+ writer.indent(() => {
5746
+ writer.writeLine("Pom.setPlaywrightAnimationOptions(animation);");
5747
+ writer.writeLine("await use();");
5748
+ });
5749
+ writer.writeLine("}, { auto: true }],");
5750
+ writer.writeLine("pomFactory: async ({ page }: { page: PwPage }, use: (r: PomFactory) => Promise<void>) => {");
5751
+ writer.indent(() => {
5752
+ writer.writeLine("await use({");
5663
5753
  writer.indent(() => {
5664
- writer.writeLine("await use({");
5665
- writer.indent(() => {
5666
- writer.writeLine("create: <T>(ctor: PomConstructor<T>) => new ctor(page),");
5667
- });
5668
- writer.writeLine("});");
5754
+ writer.writeLine("create: <T>(ctor: PomConstructor<T>) => new ctor(page),");
5669
5755
  });
5670
- writer.writeLine("},");
5671
- writer.writeLine("...createPomFixtures(pageCtors),");
5672
- writer.writeLine("...createPomFixtures(componentCtors),");
5756
+ writer.writeLine("});");
5673
5757
  });
5674
- writer.write(")");
5675
- }
5676
- }]
5758
+ writer.writeLine("},");
5759
+ writer.writeLine("...createPomFixtures(pageCtors),");
5760
+ writer.writeLine("...createPomFixtures(componentCtors),");
5761
+ });
5762
+ writer.write(") as TestType<TTestArgs & PomFixtures, TWorkerArgs>;");
5763
+ }
5677
5764
  });
5678
5765
  sourceFile.addExportDeclaration({
5679
- namedExports: ["test", "expect"]
5766
+ namedExports: ["expect"]
5680
5767
  });
5681
5768
  }, {
5682
5769
  prefixText: buildFilePrefix({
@@ -5726,9 +5813,16 @@ function prepareViewObjectModelClass(componentName, dependencies, componentHiera
5726
5813
  return match;
5727
5814
  };
5728
5815
  const rawComponentRefsForInstances = usedComponentSet?.size ? usedComponentSet : childrenComponentSet;
5816
+ const ownClassName = toPascalCaseLocal(componentName);
5817
+ const isSelfReference = (ref) => {
5818
+ return toPascalCaseLocal(normalizeTrackedComponentRef(ref)) === ownClassName && ownClassName.length > 0;
5819
+ };
5729
5820
  const componentRefsForInstances = /* @__PURE__ */ new Set();
5730
5821
  for (const ref of rawComponentRefsForInstances) {
5731
5822
  const resolvedRef = resolveTrackedComponentRef(ref) ?? normalizeTrackedComponentRef(ref);
5823
+ if (isSelfReference(resolvedRef)) {
5824
+ continue;
5825
+ }
5732
5826
  const resolvedDependencies = componentHierarchyMap.get(resolvedRef);
5733
5827
  if (!resolvedDependencies?.dataTestIdSet.size) {
5734
5828
  continue;
@@ -7453,7 +7547,7 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
7453
7547
  const inferred = tryInferNativeWrapperRoleFromSfc(element.tag, vueFilesPathMap, wrapperSearchRoots);
7454
7548
  if (inferred?.role) {
7455
7549
  nativeWrappers[element.tag] = { role: inferred.role, inferred: true };
7456
- } else if (element.tag.endsWith("Button") || element.tag === "AylaButton") {
7550
+ } else if (element.tag.endsWith("Button")) {
7457
7551
  nativeWrappers[element.tag] = { role: "button" };
7458
7552
  } else if (element.tag === "DxDataGrid") {
7459
7553
  nativeWrappers[element.tag] = { role: "grid" };
@@ -7468,6 +7562,9 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
7468
7562
  }
7469
7563
  const slotKeyInfo = getContainedInSlotDataKeyInfo(element, hierarchyMap);
7470
7564
  if (slotKeyInfo) {
7565
+ if (isSlotScopeCallbackClickHandler(element, hierarchyMap)) {
7566
+ return null;
7567
+ }
7471
7568
  return slotKeyInfo;
7472
7569
  }
7473
7570
  if (crossFileKeyRegistry) {