@immense/vue-pom-generator 1.0.78 → 1.0.79

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/index.mjs CHANGED
@@ -5485,15 +5485,16 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
5485
5485
  sourceFile.addStatements("/** Generated Playwright fixtures (typed page objects). */");
5486
5486
  addNamedImport(sourceFile, {
5487
5487
  moduleSpecifier: "@playwright/test",
5488
- namedImports: [
5489
- "expect",
5490
- { name: "test", alias: "base" }
5491
- ]
5488
+ namedImports: ["expect"]
5492
5489
  });
5493
5490
  addNamedImport(sourceFile, {
5494
5491
  moduleSpecifier: "@playwright/test",
5495
5492
  isTypeOnly: true,
5496
- namedImports: [{ name: "Page", alias: "PwPage" }]
5493
+ namedImports: [
5494
+ { name: "Page", alias: "PwPage" },
5495
+ "PlaywrightTestArgs",
5496
+ "TestType"
5497
+ ]
5497
5498
  });
5498
5499
  sourceFile.addImportDeclaration({
5499
5500
  namespaceImport: "Pom",
@@ -5577,6 +5578,14 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
5577
5578
  name: "GeneratedComponentFixtures",
5578
5579
  type: "{ [K in keyof typeof componentCtors]: InstanceType<(typeof componentCtors)[K]> }"
5579
5580
  });
5581
+ sourceFile.addTypeAlias({
5582
+ isExported: true,
5583
+ name: "PomFixtures",
5584
+ docs: [{
5585
+ description: "Every fixture contributed by the generator: the `animation` option, the internal\n`pomSetup`/`pomFactory` fixtures, and one fixture per generated page/component POM."
5586
+ }],
5587
+ type: "PlaywrightOptions & PomSetupFixture & PomFactoryFixture & GeneratedPageFixtures & GeneratedComponentFixtures"
5588
+ });
5580
5589
  sourceFile.addFunction({
5581
5590
  name: "makePomFixture",
5582
5591
  typeParameters: [{ name: "T" }],
@@ -5599,43 +5608,61 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
5599
5608
  "return out as any;"
5600
5609
  ]
5601
5610
  });
5602
- sourceFile.addVariableStatement({
5603
- declarationKind: VariableDeclarationKind.Const,
5604
- declarations: [{
5605
- name: "test",
5606
- initializer: (writer) => {
5607
- writer.write("base.extend<PlaywrightOptions & PomSetupFixture & PomFactoryFixture & GeneratedPageFixtures & GeneratedComponentFixtures>(");
5608
- writer.block(() => {
5609
- writer.writeLine("animation: [{");
5610
- writer.indent(() => {
5611
- writer.writeLine('pointer: { durationMilliseconds: 250, transitionStyle: "ease-in-out", clickDelayMilliseconds: 0 },');
5612
- writer.writeLine("keyboard: { typeDelayMilliseconds: 100 },");
5613
- });
5614
- writer.writeLine("}, { option: true }],");
5615
- writer.writeLine("pomSetup: [async ({ animation }, use) => {");
5616
- writer.indent(() => {
5617
- writer.writeLine("Pom.setPlaywrightAnimationOptions(animation);");
5618
- writer.writeLine("await use();");
5619
- });
5620
- writer.writeLine("}, { auto: true }],");
5621
- writer.writeLine("pomFactory: async ({ page }, use) => {");
5611
+ sourceFile.addStatements([
5612
+ "/**",
5613
+ " * Attach the generated POM fixtures to a project-owned Playwright `test`.",
5614
+ " *",
5615
+ " * This generator deliberately does not export a `test` of its own. Projects should own",
5616
+ " * exactly one `test` object so project-wide fixtures (console-error capture, error-overlay",
5617
+ " * detection, auth, ...) are inherited by every spec. Compose it once in a project module:",
5618
+ " *",
5619
+ " * const base = playwrightTest.extend({ ...project-wide fixtures... });",
5620
+ " * export const test = withPomFixtures(base);",
5621
+ " *",
5622
+ " * Then have every spec import `test` from that module.",
5623
+ " */"
5624
+ ].join("\n"));
5625
+ sourceFile.addFunction({
5626
+ isExported: true,
5627
+ name: "withPomFixtures",
5628
+ typeParameters: [
5629
+ { name: "TTestArgs", constraint: "PlaywrightTestArgs" },
5630
+ { name: "TWorkerArgs", constraint: "object" }
5631
+ ],
5632
+ parameters: [{ name: "base", type: "TestType<TTestArgs, TWorkerArgs>" }],
5633
+ returnType: "TestType<TTestArgs & PomFixtures, TWorkerArgs>",
5634
+ statements: (writer) => {
5635
+ writer.write("return base.extend<PomFixtures>(");
5636
+ writer.block(() => {
5637
+ writer.writeLine("animation: [{");
5638
+ writer.indent(() => {
5639
+ writer.writeLine('pointer: { durationMilliseconds: 250, transitionStyle: "ease-in-out", clickDelayMilliseconds: 0 },');
5640
+ writer.writeLine("keyboard: { typeDelayMilliseconds: 100 },");
5641
+ });
5642
+ writer.writeLine("}, { option: true }],");
5643
+ writer.writeLine("pomSetup: [async ({ animation }: PomFixtures, use: (r: void) => Promise<void>) => {");
5644
+ writer.indent(() => {
5645
+ writer.writeLine("Pom.setPlaywrightAnimationOptions(animation);");
5646
+ writer.writeLine("await use();");
5647
+ });
5648
+ writer.writeLine("}, { auto: true }],");
5649
+ writer.writeLine("pomFactory: async ({ page }: { page: PwPage }, use: (r: PomFactory) => Promise<void>) => {");
5650
+ writer.indent(() => {
5651
+ writer.writeLine("await use({");
5622
5652
  writer.indent(() => {
5623
- writer.writeLine("await use({");
5624
- writer.indent(() => {
5625
- writer.writeLine("create: <T>(ctor: PomConstructor<T>) => new ctor(page),");
5626
- });
5627
- writer.writeLine("});");
5653
+ writer.writeLine("create: <T>(ctor: PomConstructor<T>) => new ctor(page),");
5628
5654
  });
5629
- writer.writeLine("},");
5630
- writer.writeLine("...createPomFixtures(pageCtors),");
5631
- writer.writeLine("...createPomFixtures(componentCtors),");
5655
+ writer.writeLine("});");
5632
5656
  });
5633
- writer.write(")");
5634
- }
5635
- }]
5657
+ writer.writeLine("},");
5658
+ writer.writeLine("...createPomFixtures(pageCtors),");
5659
+ writer.writeLine("...createPomFixtures(componentCtors),");
5660
+ });
5661
+ writer.write(") as TestType<TTestArgs & PomFixtures, TWorkerArgs>;");
5662
+ }
5636
5663
  });
5637
5664
  sourceFile.addExportDeclaration({
5638
- namedExports: ["test", "expect"]
5665
+ namedExports: ["expect"]
5639
5666
  });
5640
5667
  }, {
5641
5668
  prefixText: buildFilePrefix({
@@ -5685,9 +5712,16 @@ function prepareViewObjectModelClass(componentName, dependencies, componentHiera
5685
5712
  return match;
5686
5713
  };
5687
5714
  const rawComponentRefsForInstances = usedComponentSet?.size ? usedComponentSet : childrenComponentSet;
5715
+ const ownClassName = toPascalCaseLocal(componentName);
5716
+ const isSelfReference = (ref) => {
5717
+ return toPascalCaseLocal(normalizeTrackedComponentRef(ref)) === ownClassName && ownClassName.length > 0;
5718
+ };
5688
5719
  const componentRefsForInstances = /* @__PURE__ */ new Set();
5689
5720
  for (const ref of rawComponentRefsForInstances) {
5690
5721
  const resolvedRef = resolveTrackedComponentRef(ref) ?? normalizeTrackedComponentRef(ref);
5722
+ if (isSelfReference(resolvedRef)) {
5723
+ continue;
5724
+ }
5691
5725
  const resolvedDependencies = componentHierarchyMap.get(resolvedRef);
5692
5726
  if (!resolvedDependencies?.dataTestIdSet.size) {
5693
5727
  continue;
@@ -7412,7 +7446,7 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
7412
7446
  const inferred = tryInferNativeWrapperRoleFromSfc(element.tag, vueFilesPathMap, wrapperSearchRoots);
7413
7447
  if (inferred?.role) {
7414
7448
  nativeWrappers[element.tag] = { role: inferred.role, inferred: true };
7415
- } else if (element.tag.endsWith("Button") || element.tag === "AylaButton") {
7449
+ } else if (element.tag.endsWith("Button")) {
7416
7450
  nativeWrappers[element.tag] = { role: "button" };
7417
7451
  } else if (element.tag === "DxDataGrid") {
7418
7452
  nativeWrappers[element.tag] = { role: "grid" };