@immense/vue-pom-generator 1.0.117 → 1.0.119
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 +66 -3
- package/RELEASE_NOTES.md +34 -14
- package/class-generation/base-page.ts +4 -0
- package/class-generation/callout.ts +19 -1
- package/class-generation/index.ts +96 -34
- package/dist/class-generation/base-page.d.ts +2 -1
- package/dist/class-generation/base-page.d.ts.map +1 -1
- package/dist/class-generation/callout.d.ts +7 -0
- package/dist/class-generation/callout.d.ts.map +1 -1
- package/dist/class-generation/index.d.ts +5 -0
- package/dist/class-generation/index.d.ts.map +1 -1
- package/dist/index.cjs +92 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +92 -35
- package/dist/index.mjs.map +1 -1
- package/dist/playwright/runtime.cjs +6 -1
- package/dist/playwright/runtime.cjs.map +1 -1
- package/dist/playwright/runtime.mjs +7 -2
- package/dist/playwright/runtime.mjs.map +1 -1
- package/dist/plugin/create-vue-pom-generator-plugins.d.ts.map +1 -1
- package/dist/plugin/internal/build-plugin.d.ts.map +1 -1
- package/dist/plugin/internal/dev-plugin.d.ts.map +1 -1
- package/dist/plugin/resolved-generation-options.d.ts +1 -0
- package/dist/plugin/resolved-generation-options.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +8 -0
- package/dist/plugin/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -221,6 +221,7 @@ function resolveGenerationSupportOptions(options) {
|
|
|
221
221
|
requireCustomPomDir: options.requireCustomPomDir ?? false,
|
|
222
222
|
customPomImportAliases: options.customPomImportAliases,
|
|
223
223
|
customPomImportNameCollisionBehavior: options.customPomImportNameCollisionBehavior ?? "error",
|
|
224
|
+
customPomFixtures: options.customPomFixtures ?? [],
|
|
224
225
|
nameCollisionBehavior: options.nameCollisionBehavior ?? "error",
|
|
225
226
|
missingSemanticNameBehavior: options.missingSemanticNameBehavior ?? "error",
|
|
226
227
|
existingIdBehavior: options.existingIdBehavior ?? "error",
|
|
@@ -5903,6 +5904,7 @@ async function generateFiles(componentHierarchyMap, vueFilesPathMap, basePageCla
|
|
|
5903
5904
|
requireCustomPomDir,
|
|
5904
5905
|
customPomImportAliases,
|
|
5905
5906
|
customPomImportNameCollisionBehavior = "error",
|
|
5907
|
+
customPomFixtures = [],
|
|
5906
5908
|
testIdAttribute,
|
|
5907
5909
|
emitLanguages: emitLanguagesOverride,
|
|
5908
5910
|
typescriptOutputStructure = "aggregated",
|
|
@@ -5962,6 +5964,7 @@ async function generateFiles(componentHierarchyMap, vueFilesPathMap, basePageCla
|
|
|
5962
5964
|
pomOutDir: outDir,
|
|
5963
5965
|
projectRoot,
|
|
5964
5966
|
customPomDir,
|
|
5967
|
+
customPomFixtures,
|
|
5965
5968
|
elementMetadata,
|
|
5966
5969
|
testIdAttribute
|
|
5967
5970
|
});
|
|
@@ -6674,9 +6677,15 @@ function generateAggregatedCSharpFiles(componentHierarchyMap, outDir, options =
|
|
|
6674
6677
|
return [{ filePath: outputFile, content: chunks.join("\n") }];
|
|
6675
6678
|
}
|
|
6676
6679
|
function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
|
|
6677
|
-
const { generateFixtures, pomOutDir } = options;
|
|
6678
|
-
if (!generateFixtures)
|
|
6680
|
+
const { generateFixtures, pomOutDir, customPomFixtures } = options;
|
|
6681
|
+
if (!generateFixtures) {
|
|
6682
|
+
if (customPomFixtures.length > 0) {
|
|
6683
|
+
throw new VuePomGeneratorError(
|
|
6684
|
+
"generation.playwright.customPoms.fixtures requires generation.playwright.fixtures to be enabled."
|
|
6685
|
+
);
|
|
6686
|
+
}
|
|
6679
6687
|
return [];
|
|
6688
|
+
}
|
|
6680
6689
|
const defaultFixtureOutDirRel = pomOutDir;
|
|
6681
6690
|
const fixtureOutRel = typeof generateFixtures === "string" ? generateFixtures : typeof generateFixtures === "object" && generateFixtures?.outDir ? generateFixtures.outDir : defaultFixtureOutDirRel;
|
|
6682
6691
|
const looksLikeFilePath = fixtureOutRel.endsWith(".ts") || fixtureOutRel.endsWith(".tsx") || fixtureOutRel.endsWith(".mts") || fixtureOutRel.endsWith(".cts");
|
|
@@ -6735,6 +6744,42 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
|
|
|
6735
6744
|
fixtureName: lowerFirst(name),
|
|
6736
6745
|
ctorExpression: fixtureCtorExpression(name)
|
|
6737
6746
|
}));
|
|
6747
|
+
const takenFixtureNames = new Map([
|
|
6748
|
+
...[...reservedPlaywrightFixtureNames, "pomSetup", "pomFactory", "pomDiagnosticsSetup"].map((name) => [name, "a built-in Playwright or vue-pom-generator fixture"]),
|
|
6749
|
+
...fixtureClassNames.map((name) => [lowerFirst(name), `the generated fixture for "${name}"`])
|
|
6750
|
+
]);
|
|
6751
|
+
const customCtorEntries = customPomFixtures.map((className, index) => {
|
|
6752
|
+
if (customPomFixtures.indexOf(className) !== index) {
|
|
6753
|
+
throw new VuePomGeneratorError(
|
|
6754
|
+
`Custom POM fixture class "${className}" is listed more than once in generation.playwright.customPoms.fixtures.
|
|
6755
|
+
Remove the duplicate entry.`
|
|
6756
|
+
);
|
|
6757
|
+
}
|
|
6758
|
+
const filePath = path.join(customPomDirAbs, `${className}.ts`);
|
|
6759
|
+
if (!fs.existsSync(filePath)) {
|
|
6760
|
+
throw new VuePomGeneratorError(
|
|
6761
|
+
`Custom POM fixture class "${className}" was not found.
|
|
6762
|
+
Expected file: ${filePath}
|
|
6763
|
+
Add the file or remove "${className}" from generation.playwright.customPoms.fixtures.`
|
|
6764
|
+
);
|
|
6765
|
+
}
|
|
6766
|
+
const fixtureName = lowerFirst(className);
|
|
6767
|
+
const existingOwner = takenFixtureNames.get(fixtureName);
|
|
6768
|
+
if (existingOwner) {
|
|
6769
|
+
throw new VuePomGeneratorError(
|
|
6770
|
+
`Custom POM fixture "${fixtureName}" (from "${className}") collides with ${existingOwner}.
|
|
6771
|
+
Rename the class or remove it from generation.playwright.customPoms.fixtures.`
|
|
6772
|
+
);
|
|
6773
|
+
}
|
|
6774
|
+
takenFixtureNames.set(fixtureName, `the custom POM fixture for "${className}"`);
|
|
6775
|
+
return {
|
|
6776
|
+
className,
|
|
6777
|
+
fixtureName,
|
|
6778
|
+
ctorExpression: `${className}Custom`,
|
|
6779
|
+
importSpecifier: stripExtension(toPosixRelativePath(fixtureOutDirAbs, filePath))
|
|
6780
|
+
};
|
|
6781
|
+
});
|
|
6782
|
+
const hasCustomFixtures = customCtorEntries.length > 0;
|
|
6738
6783
|
const fixturesContent = renderSourceFile(fixtureFileName, (sourceFile) => {
|
|
6739
6784
|
sourceFile.addStatements("/** Generated Playwright fixtures (typed page objects). */");
|
|
6740
6785
|
addNamedImport(sourceFile, {
|
|
@@ -6774,6 +6819,12 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
|
|
|
6774
6819
|
namedImports: [{ name: entry.className, alias: entry.localIdentifier }]
|
|
6775
6820
|
});
|
|
6776
6821
|
}
|
|
6822
|
+
for (const entry of customCtorEntries) {
|
|
6823
|
+
addNamedImport(sourceFile, {
|
|
6824
|
+
moduleSpecifier: entry.importSpecifier,
|
|
6825
|
+
namedImports: [{ name: entry.className, alias: entry.ctorExpression }]
|
|
6826
|
+
});
|
|
6827
|
+
}
|
|
6777
6828
|
sourceFile.addInterface({
|
|
6778
6829
|
isExported: true,
|
|
6779
6830
|
name: "PlaywrightOptions",
|
|
@@ -6813,36 +6864,27 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
|
|
|
6813
6864
|
name: "PomDiagnosticsSetupFixture",
|
|
6814
6865
|
type: "{ pomDiagnosticsSetup: void }"
|
|
6815
6866
|
});
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
writer
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
writer.indent(() => {
|
|
6838
|
-
for (const entry of componentCtorEntries) {
|
|
6839
|
-
writer.writeLine(`${entry.fixtureName}: ${entry.ctorExpression},`);
|
|
6840
|
-
}
|
|
6841
|
-
});
|
|
6842
|
-
writer.write("} as const");
|
|
6843
|
-
}
|
|
6844
|
-
}]
|
|
6845
|
-
});
|
|
6867
|
+
const addCtorMap = (name, entries) => {
|
|
6868
|
+
sourceFile.addVariableStatement({
|
|
6869
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
6870
|
+
declarations: [{
|
|
6871
|
+
name,
|
|
6872
|
+
initializer: (writer) => {
|
|
6873
|
+
writer.write("{").newLine();
|
|
6874
|
+
writer.indent(() => {
|
|
6875
|
+
for (const entry of entries) {
|
|
6876
|
+
writer.writeLine(`${entry.fixtureName}: ${entry.ctorExpression},`);
|
|
6877
|
+
}
|
|
6878
|
+
});
|
|
6879
|
+
writer.write("} as const");
|
|
6880
|
+
}
|
|
6881
|
+
}]
|
|
6882
|
+
});
|
|
6883
|
+
};
|
|
6884
|
+
addCtorMap("pageCtors", pageCtorEntries);
|
|
6885
|
+
addCtorMap("componentCtors", componentCtorEntries);
|
|
6886
|
+
if (hasCustomFixtures)
|
|
6887
|
+
addCtorMap("customCtors", customCtorEntries);
|
|
6846
6888
|
sourceFile.addTypeAlias({
|
|
6847
6889
|
isExported: true,
|
|
6848
6890
|
name: "GeneratedPageFixtures",
|
|
@@ -6853,13 +6895,20 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
|
|
|
6853
6895
|
name: "GeneratedComponentFixtures",
|
|
6854
6896
|
type: "{ [K in keyof typeof componentCtors]: InstanceType<(typeof componentCtors)[K]> }"
|
|
6855
6897
|
});
|
|
6898
|
+
if (hasCustomFixtures) {
|
|
6899
|
+
sourceFile.addTypeAlias({
|
|
6900
|
+
isExported: true,
|
|
6901
|
+
name: "CustomPomFixtures",
|
|
6902
|
+
type: "{ [K in keyof typeof customCtors]: InstanceType<(typeof customCtors)[K]> }"
|
|
6903
|
+
});
|
|
6904
|
+
}
|
|
6856
6905
|
sourceFile.addTypeAlias({
|
|
6857
6906
|
isExported: true,
|
|
6858
6907
|
name: "PomFixtures",
|
|
6859
6908
|
docs: [{
|
|
6860
|
-
description: "Every fixture contributed by the generator: the `animation` option, the internal\n`pomSetup`/`pomFactory` fixtures, and one fixture per generated page/component POM."
|
|
6909
|
+
description: "Every fixture contributed by the generator: the `animation` option, the internal\n`pomSetup`/`pomFactory` fixtures, and one fixture per generated page/component POM" + (hasCustomFixtures ? "\nand per configured custom POM." : ".")
|
|
6861
6910
|
}],
|
|
6862
|
-
type: "PlaywrightOptions & PomSetupFixture & PomFactoryFixture & PomDiagnosticsSetupFixture & GeneratedPageFixtures & GeneratedComponentFixtures"
|
|
6911
|
+
type: "PlaywrightOptions & PomSetupFixture & PomFactoryFixture & PomDiagnosticsSetupFixture & GeneratedPageFixtures & GeneratedComponentFixtures" + (hasCustomFixtures ? " & CustomPomFixtures" : "")
|
|
6863
6912
|
});
|
|
6864
6913
|
sourceFile.addFunction({
|
|
6865
6914
|
name: "makePomFixture",
|
|
@@ -6948,6 +6997,8 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
|
|
|
6948
6997
|
writer.writeLine("},");
|
|
6949
6998
|
writer.writeLine("...createPomFixtures(pageCtors),");
|
|
6950
6999
|
writer.writeLine("...createPomFixtures(componentCtors),");
|
|
7000
|
+
if (hasCustomFixtures)
|
|
7001
|
+
writer.writeLine("...createPomFixtures(customCtors),");
|
|
6951
7002
|
});
|
|
6952
7003
|
writer.write(") as TestType<TTestArgs & PomFixtures, TWorkerArgs>;");
|
|
6953
7004
|
}
|
|
@@ -8143,6 +8194,7 @@ function createBuildProcessorPlugin(options) {
|
|
|
8143
8194
|
requireCustomPomDir,
|
|
8144
8195
|
customPomImportAliases,
|
|
8145
8196
|
customPomImportNameCollisionBehavior,
|
|
8197
|
+
customPomFixtures,
|
|
8146
8198
|
testIdAttribute,
|
|
8147
8199
|
routerAwarePoms,
|
|
8148
8200
|
routerType,
|
|
@@ -8293,6 +8345,7 @@ function createBuildProcessorPlugin(options) {
|
|
|
8293
8345
|
requireCustomPomDir,
|
|
8294
8346
|
customPomImportAliases,
|
|
8295
8347
|
customPomImportNameCollisionBehavior,
|
|
8348
|
+
customPomFixtures,
|
|
8296
8349
|
testIdAttribute,
|
|
8297
8350
|
vueRouterFluentChaining: routerAwarePoms,
|
|
8298
8351
|
routerEntry: getResolvedRouterEntry(),
|
|
@@ -10673,6 +10726,7 @@ function createDevProcessorPlugin(options) {
|
|
|
10673
10726
|
requireCustomPomDir,
|
|
10674
10727
|
customPomImportAliases,
|
|
10675
10728
|
customPomImportNameCollisionBehavior,
|
|
10729
|
+
customPomFixtures,
|
|
10676
10730
|
nameCollisionBehavior,
|
|
10677
10731
|
missingSemanticNameBehavior,
|
|
10678
10732
|
existingIdBehavior,
|
|
@@ -10935,6 +10989,7 @@ function createDevProcessorPlugin(options) {
|
|
|
10935
10989
|
requireCustomPomDir,
|
|
10936
10990
|
customPomImportAliases,
|
|
10937
10991
|
customPomImportNameCollisionBehavior,
|
|
10992
|
+
customPomFixtures,
|
|
10938
10993
|
pageDirs: getPageDirs(),
|
|
10939
10994
|
componentDirs: getComponentDirs(),
|
|
10940
10995
|
layoutDirs: getLayoutDirs(),
|
|
@@ -11570,7 +11625,8 @@ function createGeneratorPlugins(options, generationOnly, projectRoot = process.c
|
|
|
11570
11625
|
const customPoms = generationOptions?.playwright?.customPoms;
|
|
11571
11626
|
const resolvedCustomPomAttachments = customPoms?.attachments ?? [];
|
|
11572
11627
|
const resolvedCustomPomImportAliases = customPoms?.importAliases;
|
|
11573
|
-
const
|
|
11628
|
+
const resolvedCustomPomFixtures = customPoms?.fixtures ?? [];
|
|
11629
|
+
const requireCustomPomDir = customPoms?.dir !== void 0 || resolvedCustomPomAttachments.length > 0 || resolvedCustomPomFixtures.length > 0 || Object.keys(resolvedCustomPomImportAliases ?? {}).length > 0;
|
|
11574
11630
|
const resolvedGenerationOptions = resolveGenerationSupportOptions({
|
|
11575
11631
|
outDir: generationOptions?.outDir,
|
|
11576
11632
|
emitLanguages: generationOptions?.emit,
|
|
@@ -11583,6 +11639,7 @@ function createGeneratorPlugins(options, generationOnly, projectRoot = process.c
|
|
|
11583
11639
|
requireCustomPomDir,
|
|
11584
11640
|
customPomImportAliases: resolvedCustomPomImportAliases,
|
|
11585
11641
|
customPomImportNameCollisionBehavior: customPoms?.importNameCollisionBehavior,
|
|
11642
|
+
customPomFixtures: resolvedCustomPomFixtures,
|
|
11586
11643
|
nameCollisionBehavior: generationOptions?.nameCollisionBehavior,
|
|
11587
11644
|
missingSemanticNameBehavior: generationOptions?.missingSemanticNameBehavior,
|
|
11588
11645
|
existingIdBehavior: resolvedInjectionOptions.existingIdBehavior,
|