@immense/vue-pom-generator 1.0.118 → 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 CHANGED
@@ -667,6 +667,46 @@ What it is not:
667
667
  - a magic auto-discovery system that wires every helper into every page
668
668
  - a replacement for `attachments`
669
669
 
670
+ ### Registering custom POMs as fixtures (`customPoms.fixtures`)
671
+
672
+ Handwritten page-level POMs can be injected like generated ones. List their class names in `customPoms.fixtures`:
673
+
674
+ ```ts
675
+ generation: {
676
+ playwright: {
677
+ fixtures: true,
678
+ customPoms: {
679
+ dir: "tests/playwright/pom/custom",
680
+ fixtures: ["SettingsPanel"],
681
+ },
682
+ },
683
+ },
684
+ ```
685
+
686
+ ```ts
687
+ // tests/playwright/pom/custom/SettingsPanel.ts
688
+ import type { Page } from "@playwright/test";
689
+
690
+ export class SettingsPanel {
691
+ constructor(private readonly page: Page) {}
692
+
693
+ async open() {
694
+ await this.page.getByRole("button", { name: "Settings" }).click();
695
+ }
696
+ }
697
+
698
+ // any spec
699
+ test("opens settings", async ({ settingsPanel }) => {
700
+ await settingsPanel.open();
701
+ });
702
+ ```
703
+
704
+ - each listed class must live in `<dir>/<ClassName>.ts` and be constructible as `new ClassName(page)`
705
+ - the fixture name follows the generated convention (`SettingsPanel` → `settingsPanel`), with the same per-test lifecycle
706
+ - the fixture is typed on `PomFixtures` (and `CustomPomFixtures`), so specs get autocomplete
707
+ - generation fails when a listed class has no file, is listed twice, when its fixture name collides with a generated or built-in fixture, or when `fixtures` is disabled
708
+ - helpers that are not listed (for example attachment helpers) are not registered
709
+
670
710
  ### `pom/overrides`
671
711
 
672
712
  Default convention: sibling `overrides/` next to `customPoms.dir`
@@ -995,13 +1035,14 @@ export { expect };
995
1035
  ```
996
1036
 
997
1037
  The module also exports the fixture types (`PomFixtures`, `GeneratedPageFixtures`,
998
- `GeneratedComponentFixtures`, `PlaywrightOptions`, `PomFactory`) and re-exports `expect`
999
- for convenience.
1038
+ `GeneratedComponentFixtures`, `PlaywrightOptions`, `PomFactory`, plus `CustomPomFixtures`
1039
+ when `customPoms.fixtures` is set) and re-exports `expect` for convenience.
1000
1040
 
1001
1041
  What it gives you:
1002
1042
 
1003
1043
  - lower-camel-case fixtures for views (`UserListPage` → `userListPage`)
1004
1044
  - lower-camel-case fixtures for component classes too
1045
+ - lower-camel-case fixtures for handwritten classes listed in `customPoms.fixtures`
1005
1046
  - `pomFactory.create(Ctor)` for ad-hoc page-object construction inside tests
1006
1047
  - an `animation` option that wires the generated runtime's pointer settings
1007
1048
  - per-page `renderers` overrides so you can keep the simple default callout or swap in a custom pointer / callout overlay implementation such as the bundled `floating-ui-callout.ts` renderer
package/RELEASE_NOTES.md CHANGED
@@ -1,39 +1,49 @@
1
+ PR search worked. Now let me verify the tag contents and what v1.0.118 included, to reconcile the
2
+ compare range with the window.
3
+
1
4
  Highlights
2
5
 
3
- - Process-wide default callout renderer — callout class generation now supports a single default
4
- renderer registered for the whole process, so apps no longer wire a renderer into each generated
5
- callout (#85)
6
- - BasePage class generation updated to consume the new default renderer
7
- - README documents the new behavior; new test coverage added
6
+ - Handwritten POM classes in customPoms.dir can now be registered as Playwright fixtures via the
7
+ new opt-in generation.playwright.customPoms.fixtures list — inject them in specs just like generated
8
+ fixtures (test("opens settings", async ({ settingsPanel }) => ...)) (#86)
9
+ - Custom fixtures follow the same naming and lifecycle rules as generated ones: SettingsPanel →
10
+ settingsPanel, with a fresh instance per test
11
+ - New exported CustomPomFixtures type on PomFixtures gives specs autocomplete for custom fixtures
12
+ - Generation fails fast with clear errors for misconfiguration; when the option is unset, generated
13
+ output is unchanged (byte-identical fixtures.g.ts verified)
8
14
 
9
15
  Changes
10
16
 
11
- Callouts
12
-
13
- - Added process-wide default callout renderer support to callout class generation
14
- (class-generation/callout.ts)
15
- - Base-page class generation now applies the default renderer when emitting callout accessors
16
- (class-generation/base-page.ts)
17
-
18
- Docs & tooling
17
+ Fixtures
19
18
 
20
- - README updated with usage and behavior of the default callout renderer
21
- - scripts/packed-smoke-check.mjs updated for the packed-package check
19
+ - Added opt-in fixtures list under playwright.customPoms; each listed class (sourced from
20
+ customPoms.dir) is registered alongside generated page/component fixtures and built with new
21
+ ClassName(page) (plugin/types.ts, plugin/resolved-generation-options.ts,
22
+ plugin/create-vue-pom-generator-plugins.ts, plugin/internal/build-plugin.ts,
23
+ plugin/internal/dev-plugin.ts, class-generation/index.ts)
24
+ - Unlisted helpers in customPoms.dir are not registered — attachment helpers that take (page,
25
+ owner) can't be built from page alone
26
+ - Fail-fast errors for: a class listed more than once, a listed class with no file, a fixture name
27
+ colliding with a built-in, generated, or other custom fixture (the message names the conflicting
28
+ owner), and fixtures disabled
22
29
 
23
- Tests
30
+ Docs
24
31
 
25
- - Added base-page tests covering default-renderer resolution in generated pages
26
- (tests/base-page.test.ts)
32
+ - README documents the new customPoms.fixtures option and usage
27
33
 
28
34
  Pull Requests Included
29
35
 
30
- - ]8;id=md-1bvr715;https://github.com/immense/vue-pom-generator/pull/85#85]8;;]8;; — feat(callout): add process-wide default callout renderer (@dkattan)]8;;
36
+ - ]8;id=md-1b1sdy8;https://github.com/immense/vue-pom-generator/pull/86#86]8;;]8;; — feat(fixtures): register configured custom POMs as Playwright fixtures (@dkattan)]8;;
31
37
 
32
- Only #85 falls within the v1.0.117..HEAD compare range (5 files, +109/−4); other PRs in the merge
38
+ Only #86 falls within the v1.0.118..HEAD compare range (9 files, +273/−36); other PRs in the merge
33
39
  window were already shipped in prior releases.
34
40
 
35
41
  Testing
36
42
 
37
- - New base-page.test.ts cases cover the default callout renderer; packed smoke check adjusted
38
- accordingly. No other test changes in this release.
43
+ - tests/generated-tsc.test.ts: runs tsc on a spec-style file using PomFixtures.settingsPanel,
44
+ asserts unlisted helpers are rejected via @ts-expect-error, and covers all fail-fast error cases
45
+ (duplicate listing, missing file, reserved/colliding names with owner in the message, fixtures off)
46
+ - tests/generate-vue-poms.test.ts: end-to-end coverage through the public plugin option
47
+ - Local runs: npm run lint -- --max-warnings 0, npm run typecheck, npm run knip, npm test (519
48
+ passed), and npm run build all passed
39
49
 
@@ -800,6 +800,12 @@ export interface GenerateFilesOptions {
800
800
  */
801
801
  customPomImportNameCollisionBehavior?: "error" | "alias";
802
802
 
803
+ /**
804
+ * Handwritten POM classes (by file/export name under customPomDir) to register as
805
+ * Playwright fixtures next to the generated ones. Requires `generateFixtures`.
806
+ */
807
+ customPomFixtures?: string[];
808
+
803
809
  /**
804
810
  * Handwritten POM helper attachments. These helpers are assumed to be present in the
805
811
  * aggregated output (e.g. via `tests/playwright/pom/custom/*.ts` inlining), but we only attach them to
@@ -893,6 +899,7 @@ export async function generateFiles(
893
899
  requireCustomPomDir,
894
900
  customPomImportAliases,
895
901
  customPomImportNameCollisionBehavior = "error",
902
+ customPomFixtures = [],
896
903
  testIdAttribute,
897
904
  emitLanguages: emitLanguagesOverride,
898
905
  typescriptOutputStructure = "aggregated",
@@ -965,6 +972,7 @@ export async function generateFiles(
965
972
  pomOutDir: outDir,
966
973
  projectRoot,
967
974
  customPomDir,
975
+ customPomFixtures,
968
976
  elementMetadata,
969
977
  testIdAttribute,
970
978
  });
@@ -1872,13 +1880,20 @@ function maybeGenerateFixtureRegistry(
1872
1880
  pomOutDir: string;
1873
1881
  projectRoot?: string;
1874
1882
  customPomDir?: string;
1883
+ customPomFixtures: string[];
1875
1884
  elementMetadata: Map<string, Map<string, ElementMetadata>>;
1876
1885
  testIdAttribute?: string;
1877
1886
  },
1878
1887
  ): GeneratedFileOutput[] {
1879
- const { generateFixtures, pomOutDir } = options;
1880
- if (!generateFixtures)
1888
+ const { generateFixtures, pomOutDir, customPomFixtures } = options;
1889
+ if (!generateFixtures) {
1890
+ if (customPomFixtures.length > 0) {
1891
+ throw new VuePomGeneratorError(
1892
+ "generation.playwright.customPoms.fixtures requires generation.playwright.fixtures to be enabled.",
1893
+ );
1894
+ }
1881
1895
  return [];
1896
+ }
1882
1897
 
1883
1898
  // generateFixtures accepts:
1884
1899
  // - true: enable fixtures with defaults
@@ -1973,6 +1988,45 @@ function maybeGenerateFixtureRegistry(
1973
1988
  ctorExpression: fixtureCtorExpression(name),
1974
1989
  }));
1975
1990
 
1991
+ // Fixture name -> what already owns it, so collision errors can name the source.
1992
+ const takenFixtureNames = new Map<string, string>([
1993
+ ...[...reservedPlaywrightFixtureNames, "pomSetup", "pomFactory", "pomDiagnosticsSetup"]
1994
+ .map(name => [name, "a built-in Playwright or vue-pom-generator fixture"] as const),
1995
+ ...fixtureClassNames.map(name => [lowerFirst(name), `the generated fixture for "${name}"`] as const),
1996
+ ]);
1997
+ const customCtorEntries = customPomFixtures.map((className, index) => {
1998
+ if (customPomFixtures.indexOf(className) !== index) {
1999
+ throw new VuePomGeneratorError(
2000
+ `Custom POM fixture class "${className}" is listed more than once in generation.playwright.customPoms.fixtures.\n`
2001
+ + "Remove the duplicate entry.",
2002
+ );
2003
+ }
2004
+ const filePath = path.join(customPomDirAbs, `${className}.ts`);
2005
+ if (!fs.existsSync(filePath)) {
2006
+ throw new VuePomGeneratorError(
2007
+ `Custom POM fixture class "${className}" was not found.\n`
2008
+ + `Expected file: ${filePath}\n`
2009
+ + `Add the file or remove "${className}" from generation.playwright.customPoms.fixtures.`,
2010
+ );
2011
+ }
2012
+ const fixtureName = lowerFirst(className);
2013
+ const existingOwner = takenFixtureNames.get(fixtureName);
2014
+ if (existingOwner) {
2015
+ throw new VuePomGeneratorError(
2016
+ `Custom POM fixture "${fixtureName}" (from "${className}") collides with ${existingOwner}.\n`
2017
+ + `Rename the class or remove it from generation.playwright.customPoms.fixtures.`,
2018
+ );
2019
+ }
2020
+ takenFixtureNames.set(fixtureName, `the custom POM fixture for "${className}"`);
2021
+ return {
2022
+ className,
2023
+ fixtureName,
2024
+ ctorExpression: `${className}Custom`,
2025
+ importSpecifier: stripExtension(toPosixRelativePath(fixtureOutDirAbs, filePath)),
2026
+ };
2027
+ });
2028
+ const hasCustomFixtures = customCtorEntries.length > 0;
2029
+
1976
2030
  const fixturesContent = renderSourceFile(fixtureFileName, (sourceFile) => {
1977
2031
  sourceFile.addStatements("/** Generated Playwright fixtures (typed page objects). */");
1978
2032
 
@@ -2019,6 +2073,12 @@ function maybeGenerateFixtureRegistry(
2019
2073
  namedImports: [{ name: entry.className, alias: entry.localIdentifier }],
2020
2074
  });
2021
2075
  }
2076
+ for (const entry of customCtorEntries) {
2077
+ addNamedImport(sourceFile, {
2078
+ moduleSpecifier: entry.importSpecifier,
2079
+ namedImports: [{ name: entry.className, alias: entry.ctorExpression }],
2080
+ });
2081
+ }
2022
2082
 
2023
2083
  sourceFile.addInterface({
2024
2084
  isExported: true,
@@ -2060,36 +2120,27 @@ function maybeGenerateFixtureRegistry(
2060
2120
  type: "{ pomDiagnosticsSetup: void }",
2061
2121
  });
2062
2122
 
2063
- sourceFile.addVariableStatement({
2064
- declarationKind: VariableDeclarationKind.Const,
2065
- declarations: [{
2066
- name: "pageCtors",
2067
- initializer: (writer) => {
2068
- writer.write("{").newLine();
2069
- writer.indent(() => {
2070
- for (const entry of pageCtorEntries) {
2071
- writer.writeLine(`${entry.fixtureName}: ${entry.ctorExpression},`);
2072
- }
2073
- });
2074
- writer.write("} as const");
2075
- },
2076
- }],
2077
- });
2078
- sourceFile.addVariableStatement({
2079
- declarationKind: VariableDeclarationKind.Const,
2080
- declarations: [{
2081
- name: "componentCtors",
2082
- initializer: (writer) => {
2083
- writer.write("{").newLine();
2084
- writer.indent(() => {
2085
- for (const entry of componentCtorEntries) {
2086
- writer.writeLine(`${entry.fixtureName}: ${entry.ctorExpression},`);
2087
- }
2088
- });
2089
- writer.write("} as const");
2090
- },
2091
- }],
2092
- });
2123
+ const addCtorMap = (name: string, entries: ReadonlyArray<{ fixtureName: string; ctorExpression: string }>) => {
2124
+ sourceFile.addVariableStatement({
2125
+ declarationKind: VariableDeclarationKind.Const,
2126
+ declarations: [{
2127
+ name,
2128
+ initializer: (writer) => {
2129
+ writer.write("{").newLine();
2130
+ writer.indent(() => {
2131
+ for (const entry of entries) {
2132
+ writer.writeLine(`${entry.fixtureName}: ${entry.ctorExpression},`);
2133
+ }
2134
+ });
2135
+ writer.write("} as const");
2136
+ },
2137
+ }],
2138
+ });
2139
+ };
2140
+ addCtorMap("pageCtors", pageCtorEntries);
2141
+ addCtorMap("componentCtors", componentCtorEntries);
2142
+ if (hasCustomFixtures)
2143
+ addCtorMap("customCtors", customCtorEntries);
2093
2144
 
2094
2145
  sourceFile.addTypeAlias({
2095
2146
  isExported: true,
@@ -2101,14 +2152,23 @@ function maybeGenerateFixtureRegistry(
2101
2152
  name: "GeneratedComponentFixtures",
2102
2153
  type: "{ [K in keyof typeof componentCtors]: InstanceType<(typeof componentCtors)[K]> }",
2103
2154
  });
2155
+ if (hasCustomFixtures) {
2156
+ sourceFile.addTypeAlias({
2157
+ isExported: true,
2158
+ name: "CustomPomFixtures",
2159
+ type: "{ [K in keyof typeof customCtors]: InstanceType<(typeof customCtors)[K]> }",
2160
+ });
2161
+ }
2104
2162
  sourceFile.addTypeAlias({
2105
2163
  isExported: true,
2106
2164
  name: "PomFixtures",
2107
2165
  docs: [{
2108
2166
  description: "Every fixture contributed by the generator: the `animation` option, the internal\n"
2109
- + "`pomSetup`/`pomFactory` fixtures, and one fixture per generated page/component POM.",
2167
+ + "`pomSetup`/`pomFactory` fixtures, and one fixture per generated page/component POM"
2168
+ + (hasCustomFixtures ? "\nand per configured custom POM." : "."),
2110
2169
  }],
2111
- type: "PlaywrightOptions & PomSetupFixture & PomFactoryFixture & PomDiagnosticsSetupFixture & GeneratedPageFixtures & GeneratedComponentFixtures",
2170
+ type: "PlaywrightOptions & PomSetupFixture & PomFactoryFixture & PomDiagnosticsSetupFixture & GeneratedPageFixtures & GeneratedComponentFixtures"
2171
+ + (hasCustomFixtures ? " & CustomPomFixtures" : ""),
2112
2172
  });
2113
2173
 
2114
2174
  sourceFile.addFunction({
@@ -2203,6 +2263,8 @@ function maybeGenerateFixtureRegistry(
2203
2263
  writer.writeLine("},");
2204
2264
  writer.writeLine("...createPomFixtures(pageCtors),");
2205
2265
  writer.writeLine("...createPomFixtures(componentCtors),");
2266
+ if (hasCustomFixtures)
2267
+ writer.writeLine("...createPomFixtures(customCtors),");
2206
2268
  });
2207
2269
  writer.write(") as TestType<TTestArgs & PomFixtures, TWorkerArgs>;");
2208
2270
  },
@@ -86,6 +86,11 @@ export interface GenerateFilesOptions {
86
86
  * - "alias": auto-alias colliding custom imports (e.g. PersonListPage -> PersonListPageCustom)
87
87
  */
88
88
  customPomImportNameCollisionBehavior?: "error" | "alias";
89
+ /**
90
+ * Handwritten POM classes (by file/export name under customPomDir) to register as
91
+ * Playwright fixtures next to the generated ones. Requires `generateFixtures`.
92
+ */
93
+ customPomFixtures?: string[];
89
94
  /**
90
95
  * Handwritten POM helper attachments. These helpers are assumed to be present in the
91
96
  * aggregated output (e.g. via `tests/playwright/pom/custom/*.ts` inlining), but we only attach them to
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../class-generation/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkC,oCAAoC,EAAE,MAAM,sBAAsB,CAAC;AAE5G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAuB7D,OAAO,EAeL,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,sBAAsB,EASvB,MAAM,UAAU,CAAC;AAuBlB,OAAO,EAAE,oCAAoC,EAAE,CAAC;AA2ChD,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,UAAU;IAClB,+FAA+F;IAC/F,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,UAAU,SAAS;IACjB,sEAAsE;IACtE,QAAQ,EAAE,MA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MAAM,EAAE,CAAC;IAE7B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAE7C,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,uDAAuD;IACvD,aAAa,CAAC,EAAE,KAAK,CAAC,IAAI,GAAG,QAAQ,CAAC,CAAC;IAEvC;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;IAEtD,6BAA6B;IAC7B,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF,6EAA6E;IAC7E,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC,2FAA2F;IAC3F,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,mDAAmD;IACnD,UAAU,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IAEnC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAEjD,mFAAmF;IACnF,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;CAC7D;AAkCD,wBAAsB,aAAa,CACjC,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,EAC1D,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,iBAAiB,EAAE,MAAM,EACzB,OAAO,GAAE,oBAAyB,iBAiHnC"}
package/dist/index.cjs CHANGED
@@ -262,6 +262,7 @@ function resolveGenerationSupportOptions(options) {
262
262
  requireCustomPomDir: options.requireCustomPomDir ?? false,
263
263
  customPomImportAliases: options.customPomImportAliases,
264
264
  customPomImportNameCollisionBehavior: options.customPomImportNameCollisionBehavior ?? "error",
265
+ customPomFixtures: options.customPomFixtures ?? [],
265
266
  nameCollisionBehavior: options.nameCollisionBehavior ?? "error",
266
267
  missingSemanticNameBehavior: options.missingSemanticNameBehavior ?? "error",
267
268
  existingIdBehavior: options.existingIdBehavior ?? "error",
@@ -5944,6 +5945,7 @@ async function generateFiles(componentHierarchyMap, vueFilesPathMap, basePageCla
5944
5945
  requireCustomPomDir,
5945
5946
  customPomImportAliases,
5946
5947
  customPomImportNameCollisionBehavior = "error",
5948
+ customPomFixtures = [],
5947
5949
  testIdAttribute,
5948
5950
  emitLanguages: emitLanguagesOverride,
5949
5951
  typescriptOutputStructure = "aggregated",
@@ -6003,6 +6005,7 @@ async function generateFiles(componentHierarchyMap, vueFilesPathMap, basePageCla
6003
6005
  pomOutDir: outDir,
6004
6006
  projectRoot,
6005
6007
  customPomDir,
6008
+ customPomFixtures,
6006
6009
  elementMetadata,
6007
6010
  testIdAttribute
6008
6011
  });
@@ -6715,9 +6718,15 @@ function generateAggregatedCSharpFiles(componentHierarchyMap, outDir, options =
6715
6718
  return [{ filePath: outputFile, content: chunks.join("\n") }];
6716
6719
  }
6717
6720
  function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
6718
- const { generateFixtures, pomOutDir } = options;
6719
- if (!generateFixtures)
6721
+ const { generateFixtures, pomOutDir, customPomFixtures } = options;
6722
+ if (!generateFixtures) {
6723
+ if (customPomFixtures.length > 0) {
6724
+ throw new VuePomGeneratorError(
6725
+ "generation.playwright.customPoms.fixtures requires generation.playwright.fixtures to be enabled."
6726
+ );
6727
+ }
6720
6728
  return [];
6729
+ }
6721
6730
  const defaultFixtureOutDirRel = pomOutDir;
6722
6731
  const fixtureOutRel = typeof generateFixtures === "string" ? generateFixtures : typeof generateFixtures === "object" && generateFixtures?.outDir ? generateFixtures.outDir : defaultFixtureOutDirRel;
6723
6732
  const looksLikeFilePath = fixtureOutRel.endsWith(".ts") || fixtureOutRel.endsWith(".tsx") || fixtureOutRel.endsWith(".mts") || fixtureOutRel.endsWith(".cts");
@@ -6776,6 +6785,42 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
6776
6785
  fixtureName: lowerFirst(name),
6777
6786
  ctorExpression: fixtureCtorExpression(name)
6778
6787
  }));
6788
+ const takenFixtureNames = new Map([
6789
+ ...[...reservedPlaywrightFixtureNames, "pomSetup", "pomFactory", "pomDiagnosticsSetup"].map((name) => [name, "a built-in Playwright or vue-pom-generator fixture"]),
6790
+ ...fixtureClassNames.map((name) => [lowerFirst(name), `the generated fixture for "${name}"`])
6791
+ ]);
6792
+ const customCtorEntries = customPomFixtures.map((className, index) => {
6793
+ if (customPomFixtures.indexOf(className) !== index) {
6794
+ throw new VuePomGeneratorError(
6795
+ `Custom POM fixture class "${className}" is listed more than once in generation.playwright.customPoms.fixtures.
6796
+ Remove the duplicate entry.`
6797
+ );
6798
+ }
6799
+ const filePath = path.join(customPomDirAbs, `${className}.ts`);
6800
+ if (!fs.existsSync(filePath)) {
6801
+ throw new VuePomGeneratorError(
6802
+ `Custom POM fixture class "${className}" was not found.
6803
+ Expected file: ${filePath}
6804
+ Add the file or remove "${className}" from generation.playwright.customPoms.fixtures.`
6805
+ );
6806
+ }
6807
+ const fixtureName = lowerFirst(className);
6808
+ const existingOwner = takenFixtureNames.get(fixtureName);
6809
+ if (existingOwner) {
6810
+ throw new VuePomGeneratorError(
6811
+ `Custom POM fixture "${fixtureName}" (from "${className}") collides with ${existingOwner}.
6812
+ Rename the class or remove it from generation.playwright.customPoms.fixtures.`
6813
+ );
6814
+ }
6815
+ takenFixtureNames.set(fixtureName, `the custom POM fixture for "${className}"`);
6816
+ return {
6817
+ className,
6818
+ fixtureName,
6819
+ ctorExpression: `${className}Custom`,
6820
+ importSpecifier: stripExtension(toPosixRelativePath(fixtureOutDirAbs, filePath))
6821
+ };
6822
+ });
6823
+ const hasCustomFixtures = customCtorEntries.length > 0;
6779
6824
  const fixturesContent = renderSourceFile(fixtureFileName, (sourceFile) => {
6780
6825
  sourceFile.addStatements("/** Generated Playwright fixtures (typed page objects). */");
6781
6826
  addNamedImport(sourceFile, {
@@ -6815,6 +6860,12 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
6815
6860
  namedImports: [{ name: entry.className, alias: entry.localIdentifier }]
6816
6861
  });
6817
6862
  }
6863
+ for (const entry of customCtorEntries) {
6864
+ addNamedImport(sourceFile, {
6865
+ moduleSpecifier: entry.importSpecifier,
6866
+ namedImports: [{ name: entry.className, alias: entry.ctorExpression }]
6867
+ });
6868
+ }
6818
6869
  sourceFile.addInterface({
6819
6870
  isExported: true,
6820
6871
  name: "PlaywrightOptions",
@@ -6854,36 +6905,27 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
6854
6905
  name: "PomDiagnosticsSetupFixture",
6855
6906
  type: "{ pomDiagnosticsSetup: void }"
6856
6907
  });
6857
- sourceFile.addVariableStatement({
6858
- declarationKind: tsMorph.VariableDeclarationKind.Const,
6859
- declarations: [{
6860
- name: "pageCtors",
6861
- initializer: (writer) => {
6862
- writer.write("{").newLine();
6863
- writer.indent(() => {
6864
- for (const entry of pageCtorEntries) {
6865
- writer.writeLine(`${entry.fixtureName}: ${entry.ctorExpression},`);
6866
- }
6867
- });
6868
- writer.write("} as const");
6869
- }
6870
- }]
6871
- });
6872
- sourceFile.addVariableStatement({
6873
- declarationKind: tsMorph.VariableDeclarationKind.Const,
6874
- declarations: [{
6875
- name: "componentCtors",
6876
- initializer: (writer) => {
6877
- writer.write("{").newLine();
6878
- writer.indent(() => {
6879
- for (const entry of componentCtorEntries) {
6880
- writer.writeLine(`${entry.fixtureName}: ${entry.ctorExpression},`);
6881
- }
6882
- });
6883
- writer.write("} as const");
6884
- }
6885
- }]
6886
- });
6908
+ const addCtorMap = (name, entries) => {
6909
+ sourceFile.addVariableStatement({
6910
+ declarationKind: tsMorph.VariableDeclarationKind.Const,
6911
+ declarations: [{
6912
+ name,
6913
+ initializer: (writer) => {
6914
+ writer.write("{").newLine();
6915
+ writer.indent(() => {
6916
+ for (const entry of entries) {
6917
+ writer.writeLine(`${entry.fixtureName}: ${entry.ctorExpression},`);
6918
+ }
6919
+ });
6920
+ writer.write("} as const");
6921
+ }
6922
+ }]
6923
+ });
6924
+ };
6925
+ addCtorMap("pageCtors", pageCtorEntries);
6926
+ addCtorMap("componentCtors", componentCtorEntries);
6927
+ if (hasCustomFixtures)
6928
+ addCtorMap("customCtors", customCtorEntries);
6887
6929
  sourceFile.addTypeAlias({
6888
6930
  isExported: true,
6889
6931
  name: "GeneratedPageFixtures",
@@ -6894,13 +6936,20 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
6894
6936
  name: "GeneratedComponentFixtures",
6895
6937
  type: "{ [K in keyof typeof componentCtors]: InstanceType<(typeof componentCtors)[K]> }"
6896
6938
  });
6939
+ if (hasCustomFixtures) {
6940
+ sourceFile.addTypeAlias({
6941
+ isExported: true,
6942
+ name: "CustomPomFixtures",
6943
+ type: "{ [K in keyof typeof customCtors]: InstanceType<(typeof customCtors)[K]> }"
6944
+ });
6945
+ }
6897
6946
  sourceFile.addTypeAlias({
6898
6947
  isExported: true,
6899
6948
  name: "PomFixtures",
6900
6949
  docs: [{
6901
- description: "Every fixture contributed by the generator: the `animation` option, the internal\n`pomSetup`/`pomFactory` fixtures, and one fixture per generated page/component POM."
6950
+ 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." : ".")
6902
6951
  }],
6903
- type: "PlaywrightOptions & PomSetupFixture & PomFactoryFixture & PomDiagnosticsSetupFixture & GeneratedPageFixtures & GeneratedComponentFixtures"
6952
+ type: "PlaywrightOptions & PomSetupFixture & PomFactoryFixture & PomDiagnosticsSetupFixture & GeneratedPageFixtures & GeneratedComponentFixtures" + (hasCustomFixtures ? " & CustomPomFixtures" : "")
6904
6953
  });
6905
6954
  sourceFile.addFunction({
6906
6955
  name: "makePomFixture",
@@ -6989,6 +7038,8 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
6989
7038
  writer.writeLine("},");
6990
7039
  writer.writeLine("...createPomFixtures(pageCtors),");
6991
7040
  writer.writeLine("...createPomFixtures(componentCtors),");
7041
+ if (hasCustomFixtures)
7042
+ writer.writeLine("...createPomFixtures(customCtors),");
6992
7043
  });
6993
7044
  writer.write(") as TestType<TTestArgs & PomFixtures, TWorkerArgs>;");
6994
7045
  }
@@ -8184,6 +8235,7 @@ function createBuildProcessorPlugin(options) {
8184
8235
  requireCustomPomDir,
8185
8236
  customPomImportAliases,
8186
8237
  customPomImportNameCollisionBehavior,
8238
+ customPomFixtures,
8187
8239
  testIdAttribute,
8188
8240
  routerAwarePoms,
8189
8241
  routerType,
@@ -8334,6 +8386,7 @@ function createBuildProcessorPlugin(options) {
8334
8386
  requireCustomPomDir,
8335
8387
  customPomImportAliases,
8336
8388
  customPomImportNameCollisionBehavior,
8389
+ customPomFixtures,
8337
8390
  testIdAttribute,
8338
8391
  vueRouterFluentChaining: routerAwarePoms,
8339
8392
  routerEntry: getResolvedRouterEntry(),
@@ -10714,6 +10767,7 @@ function createDevProcessorPlugin(options) {
10714
10767
  requireCustomPomDir,
10715
10768
  customPomImportAliases,
10716
10769
  customPomImportNameCollisionBehavior,
10770
+ customPomFixtures,
10717
10771
  nameCollisionBehavior,
10718
10772
  missingSemanticNameBehavior,
10719
10773
  existingIdBehavior,
@@ -10976,6 +11030,7 @@ function createDevProcessorPlugin(options) {
10976
11030
  requireCustomPomDir,
10977
11031
  customPomImportAliases,
10978
11032
  customPomImportNameCollisionBehavior,
11033
+ customPomFixtures,
10979
11034
  pageDirs: getPageDirs(),
10980
11035
  componentDirs: getComponentDirs(),
10981
11036
  layoutDirs: getLayoutDirs(),
@@ -11611,7 +11666,8 @@ function createGeneratorPlugins(options, generationOnly, projectRoot = process.c
11611
11666
  const customPoms = generationOptions?.playwright?.customPoms;
11612
11667
  const resolvedCustomPomAttachments = customPoms?.attachments ?? [];
11613
11668
  const resolvedCustomPomImportAliases = customPoms?.importAliases;
11614
- const requireCustomPomDir = customPoms?.dir !== void 0 || resolvedCustomPomAttachments.length > 0 || Object.keys(resolvedCustomPomImportAliases ?? {}).length > 0;
11669
+ const resolvedCustomPomFixtures = customPoms?.fixtures ?? [];
11670
+ const requireCustomPomDir = customPoms?.dir !== void 0 || resolvedCustomPomAttachments.length > 0 || resolvedCustomPomFixtures.length > 0 || Object.keys(resolvedCustomPomImportAliases ?? {}).length > 0;
11615
11671
  const resolvedGenerationOptions = resolveGenerationSupportOptions({
11616
11672
  outDir: generationOptions?.outDir,
11617
11673
  emitLanguages: generationOptions?.emit,
@@ -11624,6 +11680,7 @@ function createGeneratorPlugins(options, generationOnly, projectRoot = process.c
11624
11680
  requireCustomPomDir,
11625
11681
  customPomImportAliases: resolvedCustomPomImportAliases,
11626
11682
  customPomImportNameCollisionBehavior: customPoms?.importNameCollisionBehavior,
11683
+ customPomFixtures: resolvedCustomPomFixtures,
11627
11684
  nameCollisionBehavior: generationOptions?.nameCollisionBehavior,
11628
11685
  missingSemanticNameBehavior: generationOptions?.missingSemanticNameBehavior,
11629
11686
  existingIdBehavior: resolvedInjectionOptions.existingIdBehavior,