@immense/vue-pom-generator 1.0.39 → 1.0.41

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
@@ -698,14 +698,16 @@ function nodeHasForDirective(node) {
698
698
  function getKeyDirective(node) {
699
699
  return findDirectiveByName(node, "bind", "key") ?? null;
700
700
  }
701
- function getKeyDirectiveValue(node, context = null) {
701
+ function getKeyDirectiveValue(node, _context = null) {
702
702
  const keyDirective = getKeyDirective(node);
703
- let value = keyDirective?.exp?.loc.source;
704
- if (value) {
705
- if (context) {
706
- value = stringifyExpression(keyDirective.exp);
707
- }
708
- return `\${${value}}`;
703
+ const rawSource = keyDirective?.exp?.loc.source?.trim();
704
+ if (rawSource) {
705
+ return `\${${rawSource}}`;
706
+ }
707
+ if (keyDirective?.exp) {
708
+ const value = stringifyExpression(keyDirective.exp);
709
+ if (value)
710
+ return `\${${value}}`;
709
711
  }
710
712
  return null;
711
713
  }
@@ -2054,9 +2056,6 @@ Fix: either (1) include ${args.bestKeyPlaceholder} in your :${attrLabel} templat
2054
2056
  })();
2055
2057
  const tryMergeWithExistingPrimary = (candidateActionName) => {
2056
2058
  const mergeKey = (args.pomMergeKey ?? "").trim();
2057
- if (isKeyed) {
2058
- return false;
2059
- }
2060
2059
  const existingEntry = primaryByActionName.get(candidateActionName);
2061
2060
  const existingPom = existingEntry?.pom;
2062
2061
  if (!existingEntry || !existingPom) {
@@ -2067,6 +2066,9 @@ Fix: either (1) include ${args.bestKeyPlaceholder} in your :${attrLabel} templat
2067
2066
  ...existingPom.alternateFormattedDataTestIds ?? []
2068
2067
  ];
2069
2068
  const sharesSelectorIdentity = existingSelectors.includes(formattedDataTestIdForPom);
2069
+ if (isKeyed && !sharesSelectorIdentity) {
2070
+ return false;
2071
+ }
2070
2072
  if (!mergeKey && !sharesSelectorIdentity) {
2071
2073
  return false;
2072
2074
  }
@@ -2113,6 +2115,11 @@ Fix: either (1) include ${args.bestKeyPlaceholder} in your :${attrLabel} templat
2113
2115
  conflicts = false;
2114
2116
  }
2115
2117
  }
2118
+ if (conflicts && nameCollisionBehavior === "error" && tryMergeWithExistingPrimary(actionName)) {
2119
+ methodName = candidate;
2120
+ mergedIntoExisting = true;
2121
+ break;
2122
+ }
2116
2123
  if (conflicts && nameCollisionBehavior === "error") {
2117
2124
  const roleSuffix = upperFirst(normalizedRole || "Element");
2118
2125
  const baseNameUpper = upperFirst(baseWithSuffix);
@@ -2159,11 +2166,6 @@ Fix: either (1) include ${args.bestKeyPlaceholder} in your :${attrLabel} templat
2159
2166
  reservedMembers.add(actionName);
2160
2167
  break;
2161
2168
  }
2162
- if (nameCollisionBehavior === "error" && tryMergeWithExistingPrimary(actionName)) {
2163
- methodName = candidate;
2164
- mergedIntoExisting = true;
2165
- break;
2166
- }
2167
2169
  if (!collisionDetails) {
2168
2170
  collisionDetails = { getterName: chosenGetterName, actionName };
2169
2171
  collisionHint = hint || (args.semanticNameHint ?? "").trim() || null;
@@ -3740,6 +3742,7 @@ function generateAggregatedCSharpFiles(componentHierarchyMap, outDir, options =
3740
3742
  chunks.push(" {");
3741
3743
  if (pom.formattedDataTestId.includes("${") || allTestIds.length <= 1) {
3742
3744
  chunks.push(` await ${locatorName}${pom.formattedDataTestId.includes("${") ? `(${args})` : ""}.ClickAsync();`);
3745
+ chunks.push(` return new ${target}(Page);`);
3743
3746
  } else {
3744
3747
  chunks.push(" Exception? lastError = null;");
3745
3748
  chunks.push(` foreach (var testId in new[] { ${allTestIds.map(toCSharpTestIdExpression).join(", ")} })`);
@@ -3760,7 +3763,6 @@ function generateAggregatedCSharpFiles(componentHierarchyMap, outDir, options =
3760
3763
  chunks.push(" }");
3761
3764
  chunks.push(' throw lastError ?? new System.Exception("[pom] Failed to navigate using any candidate test id.");');
3762
3765
  }
3763
- chunks.push(` return new ${target}(Page);`);
3764
3766
  chunks.push(" }");
3765
3767
  chunks.push("");
3766
3768
  continue;
@@ -5967,6 +5969,7 @@ function createDevProcessorPlugin(options) {
5967
5969
  customPomDir,
5968
5970
  customPomImportAliases,
5969
5971
  customPomImportNameCollisionBehavior,
5972
+ nameCollisionBehavior = "suffix",
5970
5973
  testIdAttribute,
5971
5974
  routerAwarePoms,
5972
5975
  resolvedRouterEntry,
@@ -6114,7 +6117,14 @@ function createDevProcessorPlugin(options) {
6114
6117
  nativeWrappers,
6115
6118
  excludedComponents,
6116
6119
  getViewsDirAbs(),
6117
- { existingIdBehavior: "preserve", testIdAttribute, wrapperSearchRoots: getWrapperSearchRoots() }
6120
+ {
6121
+ existingIdBehavior: "preserve",
6122
+ nameCollisionBehavior,
6123
+ testIdAttribute,
6124
+ warn: (message) => loggerRef.current.warn(message),
6125
+ vueFilesPathMap: snapshotVuePathMap,
6126
+ wrapperSearchRoots: getWrapperSearchRoots()
6127
+ }
6118
6128
  )
6119
6129
  ]
6120
6130
  });
@@ -6157,6 +6167,8 @@ function createDevProcessorPlugin(options) {
6157
6167
  customPomDir,
6158
6168
  customPomImportAliases,
6159
6169
  customPomImportNameCollisionBehavior,
6170
+ viewsDir,
6171
+ scanDirs,
6160
6172
  testIdAttribute,
6161
6173
  vueRouterFluentChaining: routerAwarePoms,
6162
6174
  routerEntry: resolvedRouterEntry,
@@ -6340,6 +6352,7 @@ function createSupportPlugins(options) {
6340
6352
  viewsDir,
6341
6353
  scanDirs,
6342
6354
  getWrapperSearchRoots,
6355
+ nameCollisionBehavior = "suffix",
6343
6356
  outDir,
6344
6357
  emitLanguages,
6345
6358
  csharp,
@@ -6416,6 +6429,7 @@ function createSupportPlugins(options) {
6416
6429
  customPomDir,
6417
6430
  customPomImportAliases,
6418
6431
  customPomImportNameCollisionBehavior,
6432
+ nameCollisionBehavior,
6419
6433
  testIdAttribute,
6420
6434
  routerAwarePoms,
6421
6435
  routerType,
@@ -6996,6 +7010,7 @@ function createVuePomGeneratorPlugins(options = {}) {
6996
7010
  viewsDir,
6997
7011
  scanDirs,
6998
7012
  getWrapperSearchRoots: getWrapperSearchRootsAbs,
7013
+ nameCollisionBehavior,
6999
7014
  outDir,
7000
7015
  emitLanguages,
7001
7016
  csharp,