@immense/vue-pom-generator 1.0.45 → 1.0.47
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 +15 -0
- package/RELEASE_NOTES.md +30 -33
- package/dist/index.cjs +64 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +64 -2
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/create-vue-pom-generator-plugins.d.ts.map +1 -1
- package/dist/plugin/support/build-plugin.d.ts +1 -0
- package/dist/plugin/support/build-plugin.d.ts.map +1 -1
- package/dist/plugin/support/dev-plugin.d.ts +1 -0
- package/dist/plugin/support/dev-plugin.d.ts.map +1 -1
- package/dist/plugin/support-plugins.d.ts +1 -0
- package/dist/plugin/support-plugins.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +17 -0
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/transform.d.ts +1 -0
- package/dist/transform.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5396,6 +5396,7 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
5396
5396
|
const existingIdBehavior = options.existingIdBehavior ?? "preserve";
|
|
5397
5397
|
const testIdAttribute = (options.testIdAttribute || "data-testid").trim() || "data-testid";
|
|
5398
5398
|
const nameCollisionBehavior = options.nameCollisionBehavior ?? "suffix";
|
|
5399
|
+
const missingSemanticNameBehavior = options.missingSemanticNameBehavior ?? "ignore";
|
|
5399
5400
|
const warn = options.warn;
|
|
5400
5401
|
const vueFilesPathMap = options.vueFilesPathMap;
|
|
5401
5402
|
const wrapperSearchRoots = options.wrapperSearchRoots ?? [];
|
|
@@ -5661,6 +5662,22 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
5661
5662
|
});
|
|
5662
5663
|
};
|
|
5663
5664
|
const { nativeWrappersValue, optionDataTestIdPrefixValue, semanticNameHint } = getNativeWrapperTransformInfo(element, componentName, nativeWrappers);
|
|
5665
|
+
const handlerDirective = element.props.find((p) => {
|
|
5666
|
+
return p.type === NodeTypes.DIRECTIVE && p.name === "bind" && p.arg?.type === NodeTypes.SIMPLE_EXPRESSION && p.arg.content === "handler" && !!p.exp;
|
|
5667
|
+
}) ?? null;
|
|
5668
|
+
const handlerInfo = handlerDirective ? nodeHandlerAttributeInfo(element) : null;
|
|
5669
|
+
if (missingSemanticNameBehavior === "error" && nativeWrappers[element.tag]?.role === "button" && handlerDirective && !handlerInfo) {
|
|
5670
|
+
const loc = element.loc?.start;
|
|
5671
|
+
const locationHint = loc ? `${loc.line}:${loc.column}` : "unknown";
|
|
5672
|
+
const handlerSource = (handlerDirective.exp?.loc?.source ?? "").trim() || "<unknown>";
|
|
5673
|
+
throw new Error(
|
|
5674
|
+
`[vue-pom-generator] Could not derive a semantic POM action name for button-like wrapper in ${componentName} (${context.filename ?? "unknown"}:${locationHint}).
|
|
5675
|
+
Element: <${element.tag}>
|
|
5676
|
+
Handler: ${handlerSource}
|
|
5677
|
+
|
|
5678
|
+
Fix: move complex inline logic into a named function (for example, const onAction = () => ...; then bind :handler="onAction"), or simplify the handler to a direct identifier/call the generator can name. You can also set errorBehavior = "ignore" to keep generic fallback behavior.`
|
|
5679
|
+
);
|
|
5680
|
+
}
|
|
5664
5681
|
if (nativeWrappersValue) {
|
|
5665
5682
|
if (optionDataTestIdPrefixValue) {
|
|
5666
5683
|
const existing = existingIdBehavior === "preserve" ? tryGetExistingElementDataTestId(element, testIdAttribute) : null;
|
|
@@ -5770,7 +5787,6 @@ Fix: remove the explicit ${attrLabel}, or change existingIdBehavior to "overwrit
|
|
|
5770
5787
|
});
|
|
5771
5788
|
return;
|
|
5772
5789
|
}
|
|
5773
|
-
const handlerInfo = nodeHandlerAttributeInfo(element);
|
|
5774
5790
|
if (handlerInfo) {
|
|
5775
5791
|
const testId = getHandlerAttributeValueDataTestId(handlerInfo.semanticNameHint);
|
|
5776
5792
|
applyResolvedDataTestIdForElement({
|
|
@@ -5879,6 +5895,7 @@ function createBuildProcessorPlugin(options) {
|
|
|
5879
5895
|
customPomImportNameCollisionBehavior,
|
|
5880
5896
|
testIdAttribute,
|
|
5881
5897
|
nameCollisionBehavior,
|
|
5898
|
+
missingSemanticNameBehavior,
|
|
5882
5899
|
existingIdBehavior,
|
|
5883
5900
|
nativeWrappers,
|
|
5884
5901
|
excludedComponents,
|
|
@@ -5989,6 +6006,7 @@ function createBuildProcessorPlugin(options) {
|
|
|
5989
6006
|
existingIdBehavior: existingIdBehavior ?? "preserve",
|
|
5990
6007
|
testIdAttribute,
|
|
5991
6008
|
nameCollisionBehavior,
|
|
6009
|
+
missingSemanticNameBehavior,
|
|
5992
6010
|
warn: (message) => loggerRef.current.warn(message),
|
|
5993
6011
|
vueFilesPathMap,
|
|
5994
6012
|
wrapperSearchRoots: getWrapperSearchRoots()
|
|
@@ -6113,6 +6131,7 @@ function createDevProcessorPlugin(options) {
|
|
|
6113
6131
|
customPomImportAliases,
|
|
6114
6132
|
customPomImportNameCollisionBehavior,
|
|
6115
6133
|
nameCollisionBehavior = "suffix",
|
|
6134
|
+
missingSemanticNameBehavior,
|
|
6116
6135
|
existingIdBehavior,
|
|
6117
6136
|
testIdAttribute,
|
|
6118
6137
|
routerAwarePoms,
|
|
@@ -6277,6 +6296,7 @@ function createDevProcessorPlugin(options) {
|
|
|
6277
6296
|
{
|
|
6278
6297
|
existingIdBehavior: existingIdBehavior ?? "preserve",
|
|
6279
6298
|
nameCollisionBehavior,
|
|
6299
|
+
missingSemanticNameBehavior,
|
|
6280
6300
|
testIdAttribute,
|
|
6281
6301
|
warn: (message) => loggerRef.current.warn(message),
|
|
6282
6302
|
vueFilesPathMap: targetVuePathMap,
|
|
@@ -6517,6 +6537,7 @@ function createSupportPlugins(options) {
|
|
|
6517
6537
|
scanDirs,
|
|
6518
6538
|
getWrapperSearchRoots,
|
|
6519
6539
|
nameCollisionBehavior = "suffix",
|
|
6540
|
+
missingSemanticNameBehavior,
|
|
6520
6541
|
existingIdBehavior,
|
|
6521
6542
|
outDir,
|
|
6522
6543
|
emitLanguages,
|
|
@@ -6572,6 +6593,7 @@ function createSupportPlugins(options) {
|
|
|
6572
6593
|
customPomImportNameCollisionBehavior,
|
|
6573
6594
|
testIdAttribute,
|
|
6574
6595
|
nameCollisionBehavior,
|
|
6596
|
+
missingSemanticNameBehavior,
|
|
6575
6597
|
existingIdBehavior,
|
|
6576
6598
|
nativeWrappers,
|
|
6577
6599
|
excludedComponents,
|
|
@@ -6600,6 +6622,7 @@ function createSupportPlugins(options) {
|
|
|
6600
6622
|
customPomImportAliases,
|
|
6601
6623
|
customPomImportNameCollisionBehavior,
|
|
6602
6624
|
nameCollisionBehavior,
|
|
6625
|
+
missingSemanticNameBehavior,
|
|
6603
6626
|
existingIdBehavior,
|
|
6604
6627
|
testIdAttribute,
|
|
6605
6628
|
routerAwarePoms,
|
|
@@ -6974,6 +6997,41 @@ function assertNonEmptyStringArray(value, name) {
|
|
|
6974
6997
|
assertNonEmptyString(entry, `${name}[${index}]`);
|
|
6975
6998
|
}
|
|
6976
6999
|
}
|
|
7000
|
+
function assertOneOf(value, allowed, name) {
|
|
7001
|
+
if (!value)
|
|
7002
|
+
return;
|
|
7003
|
+
if (allowed.includes(value)) {
|
|
7004
|
+
return;
|
|
7005
|
+
}
|
|
7006
|
+
throw new TypeError(`${name} must be one of: ${allowed.join(", ")}.`);
|
|
7007
|
+
}
|
|
7008
|
+
function assertErrorBehavior(value, name) {
|
|
7009
|
+
if (!value) {
|
|
7010
|
+
return;
|
|
7011
|
+
}
|
|
7012
|
+
if (value === "ignore" || value === "error") {
|
|
7013
|
+
return;
|
|
7014
|
+
}
|
|
7015
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
7016
|
+
throw new TypeError(`${name} must be "ignore", "error", or an object.`);
|
|
7017
|
+
}
|
|
7018
|
+
const supportedKeys = /* @__PURE__ */ new Set(["missingSemanticNameBehavior"]);
|
|
7019
|
+
for (const key of Object.keys(value)) {
|
|
7020
|
+
if (!supportedKeys.has(key)) {
|
|
7021
|
+
throw new TypeError(`${name} contains unsupported key "${key}".`);
|
|
7022
|
+
}
|
|
7023
|
+
}
|
|
7024
|
+
assertOneOf(value.missingSemanticNameBehavior, ["ignore", "error"], `${name}.missingSemanticNameBehavior`);
|
|
7025
|
+
}
|
|
7026
|
+
function resolveMissingSemanticNameBehavior(value) {
|
|
7027
|
+
if (!value) {
|
|
7028
|
+
return "ignore";
|
|
7029
|
+
}
|
|
7030
|
+
if (value === "ignore" || value === "error") {
|
|
7031
|
+
return value;
|
|
7032
|
+
}
|
|
7033
|
+
return value.missingSemanticNameBehavior ?? "ignore";
|
|
7034
|
+
}
|
|
6977
7035
|
function assertRouterModuleShims(value, name) {
|
|
6978
7036
|
if (!value)
|
|
6979
7037
|
return;
|
|
@@ -7106,6 +7164,8 @@ function createVuePomGeneratorPlugins(options = {}) {
|
|
|
7106
7164
|
const vuePluginOwnership = isNuxt ? "external" : options.vuePluginOwnership ?? "internal";
|
|
7107
7165
|
const usesExternalVuePlugin = vuePluginOwnership === "external";
|
|
7108
7166
|
const csharp = generationOptions?.csharp;
|
|
7167
|
+
const errorBehavior = options.errorBehavior;
|
|
7168
|
+
const missingSemanticNameBehavior = resolveMissingSemanticNameBehavior(errorBehavior);
|
|
7109
7169
|
const generateFixtures = generationOptions?.playwright?.fixtures;
|
|
7110
7170
|
const customPoms = generationOptions?.playwright?.customPoms;
|
|
7111
7171
|
const resolvedCustomPomAttachments = customPoms?.attachments ?? [];
|
|
@@ -7137,6 +7197,7 @@ function createVuePomGeneratorPlugins(options = {}) {
|
|
|
7137
7197
|
assertNonEmptyString(testIdAttribute, "[vue-pom-generator] injection.attribute");
|
|
7138
7198
|
assertNonEmptyString(viewsDir, "[vue-pom-generator] injection.viewsDir");
|
|
7139
7199
|
assertNonEmptyStringArray(wrapperSearchRoots, "[vue-pom-generator] injection.wrapperSearchRoots");
|
|
7200
|
+
assertErrorBehavior(errorBehavior, "[vue-pom-generator] errorBehavior");
|
|
7140
7201
|
if (generationEnabled) {
|
|
7141
7202
|
assertNonEmptyString(outDir, "[vue-pom-generator] generation.outDir");
|
|
7142
7203
|
assertRouterModuleShims(routerModuleShims, "[vue-pom-generator] generation.router.moduleShims");
|
|
@@ -7148,7 +7209,7 @@ function createVuePomGeneratorPlugins(options = {}) {
|
|
|
7148
7209
|
applyTemplateCompilerOptionsToResolvedVuePlugin(config, templateCompilerOptions, isNuxt ? "nuxt" : vuePluginOwnership);
|
|
7149
7210
|
}
|
|
7150
7211
|
loggerRef.current.info(`projectRoot=${projectRootRef.current}`);
|
|
7151
|
-
loggerRef.current.info(`Active plugins: ${config.plugins.map((p) => p.name).filter((n) => n.includes("vue-pom")).join(", ")}`);
|
|
7212
|
+
loggerRef.current.info(`Active plugins: ${(config.plugins ?? []).map((p) => p.name).filter((n) => n.includes("vue-pom")).join(", ")}`);
|
|
7152
7213
|
}
|
|
7153
7214
|
};
|
|
7154
7215
|
const getViewsDirAbs = () => resolveFromProjectRoot(projectRootRef.current, viewsDir);
|
|
@@ -7182,6 +7243,7 @@ function createVuePomGeneratorPlugins(options = {}) {
|
|
|
7182
7243
|
scanDirs,
|
|
7183
7244
|
getWrapperSearchRoots: getWrapperSearchRootsAbs,
|
|
7184
7245
|
nameCollisionBehavior,
|
|
7246
|
+
missingSemanticNameBehavior,
|
|
7185
7247
|
existingIdBehavior,
|
|
7186
7248
|
outDir,
|
|
7187
7249
|
emitLanguages,
|