@immense/vue-pom-generator 1.0.43 → 1.0.45

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
@@ -3312,7 +3312,10 @@ function generateGoToSelfMethod(componentName) {
3312
3312
  " if (!route) {",
3313
3313
  ` throw new Error("[pom] No router path found for component/page-object '${componentName}'.");`,
3314
3314
  " }",
3315
- " await this.page.goto(route.template);",
3315
+ " const runtimeEnv = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env;",
3316
+ " const runtimeBaseUrl = runtimeEnv?.PLAYWRIGHT_RUNTIME_BASE_URL ?? runtimeEnv?.PLAYWRIGHT_TEST_BASE_URL ?? runtimeEnv?.VITE_PLAYWRIGHT_BASE_URL;",
3317
+ " const targetUrl = runtimeBaseUrl ? new URL(route.template, runtimeBaseUrl).toString() : route.template;",
3318
+ " await this.page.goto(targetUrl);",
3316
3319
  " }",
3317
3320
  ""
3318
3321
  ].join("\n");
@@ -3671,6 +3674,26 @@ function generateAggregatedCSharpFiles(componentHierarchyMap, outDir, options =
3671
3674
  " protected IPage Page { get; }",
3672
3675
  ` protected ILocator LocatorByTestId(string testId) => Page.Locator($"[${testIdAttribute}=\\"{testId}\\"]");`,
3673
3676
  " protected ILocator LocatorWithinTestIdByLabel(string rootTestId, string label, bool exact = true) => LocatorByTestId(rootTestId).GetByLabel(label, new() { Exact = exact });",
3677
+ " protected async Task<ILocator> ResolveEditableLocatorAsync(ILocator locator)",
3678
+ " {",
3679
+ ' var isEditable = await locator.EvaluateAsync<bool>(@"el => {',
3680
+ " if (!el || !(el instanceof HTMLElement)) return false;",
3681
+ " const tagName = el.tagName.toLowerCase();",
3682
+ " return tagName === 'input' || tagName === 'textarea' || tagName === 'select' || el.isContentEditable;",
3683
+ ' }");',
3684
+ " if (isEditable)",
3685
+ " {",
3686
+ " return locator;",
3687
+ " }",
3688
+ "",
3689
+ ` var descendant = locator.Locator("input, textarea, select, [contenteditable=''], [contenteditable='true'], [contenteditable]:not([contenteditable='false'])").First;`,
3690
+ " if (await descendant.CountAsync() > 0)",
3691
+ " {",
3692
+ " return descendant;",
3693
+ " }",
3694
+ "",
3695
+ " return locator;",
3696
+ " }",
3674
3697
  " protected async Task ClickWithinTestIdByLabelAsync(string rootTestId, string label, bool exact = true)",
3675
3698
  " {",
3676
3699
  " await LocatorWithinTestIdByLabel(rootTestId, label, exact).ClickAsync();",
@@ -3772,7 +3795,8 @@ function generateAggregatedCSharpFiles(componentHierarchyMap, outDir, options =
3772
3795
  const callSuffix = pom.formattedDataTestId.includes("${") ? `(${args})` : "";
3773
3796
  const emitActionCall = (locatorAccess) => {
3774
3797
  if (pom.nativeRole === "input") {
3775
- chunks.push(` await ${locatorAccess}.FillAsync(text);`);
3798
+ chunks.push(` var editableLocator = await ResolveEditableLocatorAsync(${locatorAccess});`);
3799
+ chunks.push(" await editableLocator.FillAsync(text);");
3776
3800
  } else if (pom.nativeRole === "select") {
3777
3801
  chunks.push(` await ${locatorAccess}.SelectOptionAsync(value);`);
3778
3802
  } else if (pom.nativeRole === "vselect") {
@@ -3800,7 +3824,8 @@ function generateAggregatedCSharpFiles(componentHierarchyMap, outDir, options =
3800
3824
  chunks.push(" if (await locator.CountAsync() > 0)");
3801
3825
  chunks.push(" {");
3802
3826
  if (pom.nativeRole === "input") {
3803
- chunks.push(" await locator.FillAsync(text);");
3827
+ chunks.push(" var editableLocator = await ResolveEditableLocatorAsync(locator);");
3828
+ chunks.push(" await editableLocator.FillAsync(text);");
3804
3829
  } else if (pom.nativeRole === "select") {
3805
3830
  chunks.push(" await locator.SelectOptionAsync(value);");
3806
3831
  } else {
@@ -4024,7 +4049,8 @@ function generateViewObjectModelContent(componentName, dependencies, componentHi
4024
4049
  if (!Object.prototype.hasOwnProperty.call(customPomClassIdentifierMap, a.className))
4025
4050
  return false;
4026
4051
  const scope = a.attachTo ?? "views";
4027
- const scopeOk = isView ? scope === "views" || scope === "both" : scope === "components" || scope === "both";
4052
+ const scopeMatchesBoth = scope === "both" || scope === "pagesAndComponents";
4053
+ const scopeOk = isView ? scope === "views" || scopeMatchesBoth : scope === "components" || scopeMatchesBoth;
4028
4054
  if (!scopeOk)
4029
4055
  return false;
4030
4056
  return a.attachWhenUsesComponents.some((c) => hasChildComponent(c));