@immense/vue-pom-generator 1.0.81 → 1.0.82

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
@@ -2206,6 +2206,11 @@ function getNativeWrapperTransformInfo(node, componentName, nativeWrappers) {
2206
2206
  return { nativeWrappersValue: null, optionDataTestIdPrefixValue: null, semanticNameHint: null };
2207
2207
  }
2208
2208
  const { role, valueAttribute, requiresOptionDataTestIdPrefix, inferred } = wrapperConfig;
2209
+ if (!role) {
2210
+ throw new Error(
2211
+ `[vue-pom-generator] Native wrapper <${node.tag}> has no resolved role in getNativeWrapperTransformInfo. The transform infers or declares a role before reaching this point; if calling this helper directly, pass a config with \`role\` set.`
2212
+ );
2213
+ }
2209
2214
  if (nodeHasClickDirective(node) && role === "button") {
2210
2215
  return { nativeWrappersValue: null, optionDataTestIdPrefixValue: null, semanticNameHint: null };
2211
2216
  }
@@ -2294,7 +2299,13 @@ function generateToDirectiveDataTestId(componentName, node, toDirective, context
2294
2299
  }
2295
2300
  function formatTagName(node, nativeWrappers) {
2296
2301
  if (Object.keys(nativeWrappers).includes(node.tag)) {
2297
- return `-${nativeWrappers[node.tag].role}`;
2302
+ const role = nativeWrappers[node.tag].role;
2303
+ if (!role) {
2304
+ throw new Error(
2305
+ `[vue-pom-generator] Native wrapper <${node.tag}> has no resolved role in formatTagName. The transform infers or declares a role before reaching this point; if calling this helper directly, pass a config with \`role\` set.`
2306
+ );
2307
+ }
2308
+ return `-${role}`;
2298
2309
  }
2299
2310
  const nodeName = node.tag.replace(/-/g, "").toLowerCase();
2300
2311
  return `-${nodeName}`;
@@ -2898,7 +2909,7 @@ Fix: reduce the template to a single key-based interpolation, or remove the expl
2898
2909
  );
2899
2910
  }
2900
2911
  const hasExact = requiredKeyTemplateValue ? templateFragmentContainsSingleExpression(existingTemplateValue.parsedTemplate, requiredKeyTemplateValue.parsedTemplate) : false;
2901
- const hasVarAccess = getBestKeyAccessCandidates(bestKeyVariable).some((candidate) => existingTemplateFragment.expressionSource === candidate);
2912
+ const hasVarAccess = getBestKeyAccessCandidates(bestKeyVariable).includes(existingTemplateFragment.expressionSource);
2902
2913
  if (!hasExact && !hasVarAccess && bestKeyPreservePlaceholder) {
2903
2914
  throw new Error(
2904
2915
  `[vue-pom-generator] Existing ${attrLabel} appears to be missing the key placeholder needed to keep it unique.
@@ -2960,6 +2971,7 @@ Fix: either (1) include ${bestKeyPreservePlaceholder} in your :${attrLabel} temp
2960
2971
  case "toggle":
2961
2972
  case "radio":
2962
2973
  case "grid":
2974
+ case "link":
2963
2975
  return role;
2964
2976
  default:
2965
2977
  return void 0;
@@ -3581,7 +3593,8 @@ const STANDALONE_WRAPPER_FALLBACK_ROLES = /* @__PURE__ */ new Set([
3581
3593
  "vselect",
3582
3594
  "checkbox",
3583
3595
  "toggle",
3584
- "radio"
3596
+ "radio",
3597
+ "link"
3585
3598
  ]);
3586
3599
  function stripTrailingAsciiDigits(value) {
3587
3600
  let end = value.length;
@@ -7127,6 +7140,18 @@ ${buildSearchRootsKey(normalizedSearchRoots)}`;
7127
7140
  });
7128
7141
  return (typeAttr?.value?.content ?? "").toLowerCase();
7129
7142
  };
7143
+ const hasHrefAttribute = (element) => {
7144
+ return element.props.some((prop) => {
7145
+ if (prop.type === NodeTypes.ATTRIBUTE) {
7146
+ return prop.name === "href";
7147
+ }
7148
+ if (prop.type === NodeTypes.DIRECTIVE) {
7149
+ const directive = prop;
7150
+ return directive.name === "bind" && directive.arg?.type === NodeTypes.SIMPLE_EXPRESSION && directive.arg.content === "href";
7151
+ }
7152
+ return false;
7153
+ });
7154
+ };
7130
7155
  let inferRoleFromNode;
7131
7156
  const inferRoleFromElement = (element) => {
7132
7157
  const elementTag = (element.tag || "").toLowerCase();
@@ -7146,6 +7171,10 @@ ${buildSearchRootsKey(normalizedSearchRoots)}`;
7146
7171
  return { role: "vselect" };
7147
7172
  if (elementTag === "button" || elementTag === "ubutton")
7148
7173
  return { role: "button" };
7174
+ if (elementTag === "router-link" || elementTag === "routerlink")
7175
+ return { role: "link" };
7176
+ if ((elementTag === "a" || elementTag === "ua") && hasHrefAttribute(element))
7177
+ return { role: "link" };
7149
7178
  if (isComponentLikeTag(element.tag) && element.tag !== tag) {
7150
7179
  const nested = tryInferNativeWrapperRoleFromSfc(element.tag, vueFilesPathMap, normalizedSearchRoots, nextSeen);
7151
7180
  if (nested)
@@ -7440,11 +7469,6 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
7440
7469
  }
7441
7470
  const element = node;
7442
7471
  const parentIsRoot = context?.parent?.type === NodeTypes.ROOT;
7443
- {
7444
- element.props.find(
7445
- (p) => p.type === NodeTypes.DIRECTIVE && p.name === "bind" && p.arg?.type === NodeTypes.SIMPLE_EXPRESSION && p.arg.content === testIdAttribute && !!p.exp
7446
- );
7447
- }
7448
7472
  const grandParent = context.grandParent;
7449
7473
  const parentElement = !parentIsRoot && context?.parent?.type === NodeTypes.ELEMENT ? context.parent : !parentIsRoot && grandParent?.type === NodeTypes.ELEMENT ? grandParent : null;
7450
7474
  hierarchyMap.set(element, parentElement);
@@ -7502,7 +7526,8 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
7502
7526
  }
7503
7527
  }
7504
7528
  }
7505
- if (!nativeWrappers[element.tag]) {
7529
+ const existingWrapperConfig = nativeWrappers[element.tag];
7530
+ if (!existingWrapperConfig) {
7506
7531
  const inferred = tryInferNativeWrapperRoleFromSfc(element.tag, vueFilesPathMap, wrapperSearchRoots);
7507
7532
  if (inferred?.role) {
7508
7533
  nativeWrappers[element.tag] = { role: inferred.role, inferred: true };
@@ -7511,6 +7536,22 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
7511
7536
  } else if (element.tag === "DxDataGrid") {
7512
7537
  nativeWrappers[element.tag] = { role: "grid" };
7513
7538
  }
7539
+ } else if (!existingWrapperConfig.role) {
7540
+ const inferred = tryInferNativeWrapperRoleFromSfc(element.tag, vueFilesPathMap, wrapperSearchRoots);
7541
+ if (!inferred?.role) {
7542
+ const loc = element.loc?.start;
7543
+ const locationHint = loc ? `${loc.line}:${loc.column}` : "unknown";
7544
+ throw new Error(
7545
+ `[vue-pom-generator] Could not infer a native role for declared wrapper <${element.tag}> in ${componentName} (${context.filename ?? "unknown"}:${locationHint}).
7546
+ The component's template does not render a recognized native control (input, textarea, select, button, vselect, a[href]/RouterLink, radio, checkbox).
7547
+
7548
+ Fix: set \`role\` explicitly in nativeWrappers (e.g. { "${element.tag}": { role: "button", ... } }).`
7549
+ );
7550
+ }
7551
+ nativeWrappers[element.tag] = {
7552
+ ...existingWrapperConfig,
7553
+ role: inferred.role
7554
+ };
7514
7555
  }
7515
7556
  const getBestAvailableKeyInfo = () => {
7516
7557
  const parentNode = context.parent && typeof context.parent === "object" ? context.parent : null;
@@ -7820,7 +7861,7 @@ Fix: remove the explicit ${attrLabel}, or change existingIdBehavior to "overwrit
7820
7861
  }
7821
7862
  if (existingElementDataTestId) {
7822
7863
  const inferredRole = getNativeRoleFromTagSuffix().toLowerCase();
7823
- const isRecognizedInteractiveRole = inferredRole === "button" || inferredRole === "input" || inferredRole === "select" || inferredRole === "vselect" || inferredRole === "checkbox" || inferredRole === "toggle" || inferredRole === "radio" || inferredRole === "grid" || isComponentLikeTag(element.tag);
7864
+ const isRecognizedInteractiveRole = inferredRole === "button" || inferredRole === "input" || inferredRole === "select" || inferredRole === "vselect" || inferredRole === "checkbox" || inferredRole === "toggle" || inferredRole === "radio" || inferredRole === "grid" || inferredRole === "link" || isComponentLikeTag(element.tag);
7824
7865
  if (!isRecognizedInteractiveRole) {
7825
7866
  return;
7826
7867
  }
@@ -8919,23 +8960,9 @@ function createInternalPlugins(options) {
8919
8960
  annotatorRuntime
8920
8961
  } = options;
8921
8962
  const {
8922
- outDir,
8923
- emitLanguages,
8924
- typescriptOutputStructure,
8925
- csharp,
8926
- generateFixtures,
8927
- customPomAttachments,
8928
- customPomDir,
8929
- requireCustomPomDir,
8930
- customPomImportAliases,
8931
- customPomImportNameCollisionBehavior,
8932
- nameCollisionBehavior,
8933
- existingIdBehavior,
8934
- testIdAttribute,
8935
8963
  routerAwarePoms,
8936
8964
  routerEntry,
8937
- routerType,
8938
- routerModuleShims
8965
+ routerType
8939
8966
  } = generation;
8940
8967
  const resolveRouterEntry2 = () => {
8941
8968
  if (!routerAwarePoms)
@@ -9057,7 +9084,7 @@ function findStaticAttributeValue(element, attributeName) {
9057
9084
  (prop) => prop.type === NodeTypes.ATTRIBUTE && prop.name === attributeName
9058
9085
  );
9059
9086
  const value = attribute?.value?.content?.trim();
9060
- return value ? value : void 0;
9087
+ return value || void 0;
9061
9088
  }
9062
9089
  function collectStaticTextContent(children) {
9063
9090
  const parts = [];