@immense/vue-pom-generator 1.0.37 → 1.0.38

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
@@ -3478,7 +3478,8 @@ async function generateFiles(componentHierarchyMap, vueFilesPathMap, basePageCla
3478
3478
  const fixtureRegistryFile = maybeGenerateFixtureRegistry(componentHierarchyMap, {
3479
3479
  generateFixtures,
3480
3480
  pomOutDir: outDir,
3481
- projectRoot
3481
+ projectRoot,
3482
+ customPomDir
3482
3483
  });
3483
3484
  if (fixtureRegistryFile) {
3484
3485
  writeGeneratedFile(fixtureRegistryFile);
@@ -3877,6 +3878,9 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
3877
3878
  const fixtureFileName = looksLikeFilePath ? path.basename(fixtureOutRel) : "fixtures.g.ts";
3878
3879
  const root = options.projectRoot ?? process.cwd();
3879
3880
  const fixtureOutDirAbs = path.isAbsolute(fixtureOutDirRel) ? fixtureOutDirRel : path.resolve(root, fixtureOutDirRel);
3881
+ const customPomDirRel = options.customPomDir ?? "tests/playwright/pom/custom";
3882
+ const customPomDirAbs = path.isAbsolute(customPomDirRel) ? customPomDirRel : path.resolve(root, customPomDirRel);
3883
+ const overridePomDirAbs = path.resolve(path.dirname(customPomDirAbs), "overrides");
3880
3884
  const pomDirAbs = path.isAbsolute(pomOutDir) ? pomOutDir : path.resolve(root, pomOutDir);
3881
3885
  const pomImport = toPosixRelativePath(fixtureOutDirAbs, pomDirAbs);
3882
3886
  const viewClassNames = Array.from(componentHierarchyMap.entries()).filter(([, deps]) => !!deps.isView).map(([name]) => name).sort((a, b) => a.localeCompare(b));
@@ -3899,6 +3903,22 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
3899
3903
  return false;
3900
3904
  return true;
3901
3905
  }).sort((a, b) => a.localeCompare(b));
3906
+ const fixtureClassNames = [...viewClassNames, ...componentClassNames];
3907
+ const overrideCtorEntries = fixtureClassNames.map((name) => {
3908
+ const overrideFilePath = path.join(overridePomDirAbs, `${name}.ts`);
3909
+ if (!fs.existsSync(overrideFilePath))
3910
+ return null;
3911
+ return {
3912
+ className: name,
3913
+ localIdentifier: `${name}Override`,
3914
+ importSpecifier: stripExtension(toPosixRelativePath(fixtureOutDirAbs, overrideFilePath))
3915
+ };
3916
+ }).filter((entry) => !!entry);
3917
+ const overrideCtorByClassName = new Map(overrideCtorEntries.map((entry) => [entry.className, entry.localIdentifier]));
3918
+ const overrideImports = overrideCtorEntries.length ? `${overrideCtorEntries.map((entry) => `import { ${entry.className} as ${entry.localIdentifier} } from "${entry.importSpecifier}";`).join("\n")}
3919
+
3920
+ ` : "";
3921
+ const fixtureCtorExpression = (name) => overrideCtorByClassName.get(name) ?? `Pom.${name}`;
3902
3922
  const header = `${eslintSuppressionHeader}/**
3903
3923
  * DO NOT MODIFY BY HAND
3904
3924
  *
@@ -3907,8 +3927,8 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
3907
3927
  */
3908
3928
 
3909
3929
  `;
3910
- const fixturesTypeEntries = viewClassNames.map((name) => ` ${lowerFirst(name)}: Pom.${name},`).join("\n");
3911
- const componentFixturesTypeEntries = componentClassNames.map((name) => ` ${lowerFirst(name)}: Pom.${name},`).join("\n");
3930
+ const fixturesTypeEntries = viewClassNames.map((name) => ` ${lowerFirst(name)}: ${fixtureCtorExpression(name)},`).join("\n");
3931
+ const componentFixturesTypeEntries = componentClassNames.map((name) => ` ${lowerFirst(name)}: ${fixtureCtorExpression(name)},`).join("\n");
3912
3932
  const pomFactoryType = `export type PomConstructor<T> = new (page: PwPage) => T;
3913
3933
 
3914
3934
  export interface PomFactory {
@@ -3921,8 +3941,7 @@ export interface PomFactory {
3921
3941
  import { expect, test as base } from "@playwright/test";
3922
3942
  import type { Page as PwPage } from "@playwright/test";
3923
3943
  import * as Pom from "${pomImport}";
3924
-
3925
- export interface PlaywrightOptions {
3944
+ ${overrideImports}export interface PlaywrightOptions {
3926
3945
  animation: Pom.PlaywrightAnimationOptions;
3927
3946
  }
3928
3947