@immense/vue-pom-generator 1.0.47 → 1.0.48

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
@@ -3,7 +3,7 @@
3
3
  `@immense/vue-pom-generator` is a Vite plugin for Vue 3 that does two compile-time jobs:
4
4
 
5
5
  1. it injects a test-id attribute into interactive elements in `.vue` templates
6
- 2. it turns the collected ids into an aggregated Page Object Model library for Playwright, with optional Playwright fixtures and optional C# output
6
+ 2. it turns the collected ids into a Page Object Model library for Playwright, with aggregated or split TypeScript output, optional Playwright fixtures, and optional C# output
7
7
 
8
8
  If you already use Playwright with `getByTestId`, the point is simple: this package removes the repetitive work of keeping test ids in sync with Vue templates and then hand-writing page objects around those ids.
9
9
 
@@ -11,7 +11,7 @@ If you already use Playwright with `getByTestId`, the point is simple: this pack
11
11
 
12
12
  - **Injects test ids during Vue compilation, not at runtime.** It hooks into the Vue template compiler and rewrites the compiled template output.
13
13
  - **Uses real template signals to name ids and methods.** Click handlers, `v-model`, `id`/`name`, `:to`, wrapper configuration, and a few targeted fallbacks all feed the generated API.
14
- - **Generates one aggregated TypeScript POM file** plus a stable `index.ts` barrel.
14
+ - **Generates TypeScript POM output as either one aggregate or split per class, always with a stable `index.ts` barrel.**
15
15
  - **Can generate Playwright fixtures** so tests can request `userListPage` instead of constructing `new UserListPage(page)` manually.
16
16
  - **Can fail fast on unnameable wrapper-button actions** so complex inline handlers do not silently degrade into low-signal generated APIs.
17
17
  - **Can emit a single C# POM file** for Playwright .NET consumers.
@@ -234,6 +234,7 @@ const pomConfig = defineVuePomGeneratorConfig({
234
234
  },
235
235
  playwright: {
236
236
  fixtures: true,
237
+ outputStructure: "split",
237
238
  customPoms: {
238
239
  dir: "tests/playwright/pom/custom",
239
240
  importAliases: {
@@ -294,9 +295,13 @@ By default, generation writes to `tests/playwright/__generated__`.
294
295
 
295
296
  TypeScript output:
296
297
 
297
- - `page-object-models.g.ts` aggregated generated classes
298
- - `index.ts` — stable barrel re-exporting `page-object-models.g`
299
- - `_pom-runtime/`copied runtime support files used by the aggregated output
298
+ - default (`generation.playwright.outputStructure: "aggregated"`):
299
+ - `page-object-models.g.ts` — aggregated generated classes
300
+ - `index.ts`stable barrel re-exporting `page-object-models.g`
301
+ - split mode (`generation.playwright.outputStructure: "split"`):
302
+ - one `*.g.ts` file per generated class
303
+ - `index.ts` — stable barrel re-exporting the split files
304
+ - `_pom-runtime/` — copied runtime support files used by the generated TypeScript output in either mode
300
305
 
301
306
  Optional Playwright fixture output:
302
307
 
@@ -313,7 +318,7 @@ If you emit outside a `__generated__` path, the generator also manages `.gitattr
313
318
 
314
319
  This is important if you are deciding whether the tool will fit into a real codebase.
315
320
 
316
- - **Dev server:** on startup, it scans the configured `scanDirs`, compiles each `.vue` file into a snapshot, writes the aggregated outputs once, then batches add/change/delete events and regenerates incrementally.
321
+ - **Dev server:** on startup, it scans the configured `scanDirs`, compiles each `.vue` file into a snapshot, writes the configured TypeScript outputs once, then batches add/change/delete events and regenerates incrementally.
317
322
  - **Build:** it generates from the richest build pass it sees, which matters because Vite can run multiple passes (for example SSR plus client). The generator avoids letting a thinner pass clobber a richer one.
318
323
  - **Always-on virtual module:** `virtual:testids` is registered whether generation is enabled or disabled.
319
324
  - **Generation can be disabled:** `generation: false` still keeps compile-time test-id injection and the virtual module, but skips emitted POM files.
@@ -383,7 +388,7 @@ These two directories solve different problems.
383
388
 
384
389
  Default: `tests/playwright/pom/custom`
385
390
 
386
- This directory is for handwritten helper classes that the aggregated TypeScript output can import.
391
+ This directory is for handwritten helper classes that the generated TypeScript output can import.
387
392
 
388
393
  It is the default helper directory even if you omit `generation.playwright.customPoms` entirely.
389
394
 
@@ -392,7 +397,7 @@ Actual current behavior:
392
397
  - the generator scans the directory **non-recursively**
393
398
  - it imports top-level `.ts` files only
394
399
  - it expects the file basename to match the exported class name (`Grid.ts` → `export class Grid {}`)
395
- - the helper files are imported into the generated aggregate; they are **not** automatically attached everywhere
400
+ - the helper files are available to generated output; they are **not** automatically attached everywhere
396
401
 
397
402
  What it is for:
398
403
 
@@ -434,7 +439,7 @@ A typical override looks like this:
434
439
 
435
440
  ```ts
436
441
  // tests/playwright/pom/overrides/UserListPage.ts
437
- import { UserListPage as GeneratedUserListPage } from "../../__generated__/page-object-models.g";
442
+ import { UserListPage as GeneratedUserListPage } from "../../__generated__";
438
443
 
439
444
  export class UserListPage extends GeneratedUserListPage {
440
445
  async openFirstUser() {
@@ -449,7 +454,10 @@ This is where most people need precision.
449
454
 
450
455
  ### Helper imports
451
456
 
452
- Every `.ts` file in `customPoms.dir` becomes an import in the aggregated TypeScript output.
457
+ Every `.ts` file in `customPoms.dir` is available for import from the generated TypeScript output.
458
+
459
+ - in aggregated mode, helper files become imports in the shared aggregate
460
+ - in split mode, each generated file imports only the helpers it actually needs
453
461
 
454
462
  Benefits:
455
463
 
@@ -1037,6 +1045,17 @@ This object holds Playwright-specific additions on top of the generated TypeScri
1037
1045
  - `"path"` — if the string ends in `.ts` / `.tsx` / `.mts` / `.cts`, it is treated as a file path; otherwise as an output directory
1038
1046
  - `{ outDir }` — emit to a custom directory
1039
1047
 
1048
+ #### `generation.playwright.outputStructure`
1049
+
1050
+ - **What it does:** Chooses whether generated TypeScript POMs are emitted as one aggregate or split per class.
1051
+ - **Why it exists:** very large generated files are harder to browse, inspect, and discover in editors.
1052
+ - **Benefit:** `"split"` keeps the same stable barrel and fixtures surface while making individual classes and methods easier to find.
1053
+ - **Without it:** the default is `"aggregated"`.
1054
+ - **Accepted values:**
1055
+ - `"aggregated"` — emit `page-object-models.g.ts` plus `index.ts`
1056
+ - `"split"` — emit one `*.g.ts` file per class plus `index.ts`
1057
+ - **Current limit:** this setting only affects the generated TypeScript Playwright output; C# output remains a single aggregated file.
1058
+
1040
1059
  #### `generation.playwright.customPoms`
1041
1060
 
1042
1061
  - **What it does:** Configures handwritten helper imports and attachments.
@@ -1063,7 +1082,7 @@ This object holds Playwright-specific additions on top of the generated TypeScri
1063
1082
  #### `customPoms.importNameCollisionBehavior`
1064
1083
 
1065
1084
  - **What it does:** Controls how helper import names behave when they collide with generated class names.
1066
- - **Why it exists:** aggregated output shares one import namespace.
1085
+ - **Why it exists:** generated files still need a conflict-free local import namespace.
1067
1086
  - **Benefit:** lets you fail hard or auto-alias based on team preference.
1068
1087
  - **Without it:** the default is `"error"`.
1069
1088
 
package/RELEASE_NOTES.md CHANGED
@@ -1,49 +1,53 @@
1
- ## Highlights
1
+ # Release Notes: v1.0.48
2
2
 
3
- - **Fail-fast validation** for wrapper handlers that cannot be named, improving error detection
4
- at build time
5
- - Added comprehensive validation logic across plugin lifecycle (dev and build modes)
6
- - Expanded test coverage with 54+ new test cases for handler naming scenarios
7
- - Enhanced error reporting when anonymous or unnameable handlers are detected
8
- - Updated documentation with new validation requirements and best practices
3
+ ## Highlights
9
4
 
10
- ## Changes
5
+ - **Split Playwright POM Output**: Added new option to generate split/modular Page Object Models
6
+ for improved discoverability and maintainability
7
+ - **ts-morph Integration**: Migrated TypeScript code generation to use ts-morph library for more
8
+ robust and maintainable type emission
9
+ - **Fail-Fast Error Handling**: Now fails immediately when encountering unnameable wrapper
10
+ handlers instead of generating invalid code
11
+ - **Enhanced Type Safety**: Improved TypeScript code generation structure with dedicated
12
+ emitters and better type definitions
11
13
 
12
- **Core Validation**
13
- - Added fail-fast validation in `transform.ts` to detect unnameable wrapper handlers before
14
- runtime
15
- - Implemented handler name validation in `create-vue-pom-generator-plugins.ts` with detailed
16
- error messages
17
- - Added validation hooks in both `build-plugin.ts` and `dev-plugin.ts` for consistency across
18
- modes
14
+ ## Changes
19
15
 
20
- **Type System & API**
21
- - Extended plugin types with new validation options and error handling interfaces
22
- - Added support for configurable validation behavior in plugin options
16
+ ### Features
17
+ - Add split Playwright POM output for improved discoverability (#12)
18
+ - Fail fast on unnameable wrapper handlers instead of silently generating invalid code (#11)
23
19
 
24
- **Testing**
25
- - Added 54 new test cases in `options.test.ts` covering edge cases for handler naming
26
- - Added 23 new tests in `transform.test.ts` for transformation validation
27
- - Added 9 coverage tests in `utils-coverage.test.ts`
28
- - Enhanced `dev-plugin-options.test.ts` with validation scenario tests
20
+ ### Refactoring & Code Quality
21
+ - Migrate to ts-morph for TypeScript code generation
22
+ - Structure ts-morph emitters into dedicated modules
23
+ - Clean up split stub generation logic
24
+ - Address PR feedback on split output implementation
25
+ - Remove duplicate rebase leftovers
29
26
 
30
- **Documentation**
31
- - Updated README.md with guidance on handler naming requirements and validation behavior
27
+ ### Configuration & Types
28
+ - Add ts-morph dependency to package.json
29
+ - Update plugin types to support split output options
30
+ - Enhance manifest generator for split POM structure
32
31
 
33
- ## Breaking Changes
32
+ ### Testing
33
+ - Add comprehensive tests for generated TypeScript output
34
+ - Add test fixtures for BasePage (full/minimal), Pointer, and playwright-test declarations
35
+ - Update class generation coverage tests
36
+ - Add option tests for new split output configuration
34
37
 
35
- - **Handler naming validation**: The plugin now throws errors when wrapper handlers cannot be
36
- named (anonymous functions, computed property names, etc.). Code that previously compiled with
37
- unnameable handlers will now fail at build time. Ensure all wrapper handlers have statically
38
- determinable names.
38
+ ### Documentation
39
+ - Update README with split output documentation and usage examples
39
40
 
40
41
  ## Pull Requests Included
41
42
 
42
- - #11: feat: fail fast on unnameable wrapper handlers
43
- (https://github.com/immense/vue-pom-generator/pull/11) by @dkattan
43
+ - #12 feat: add split Playwright POM output for discoverability
44
+ (https://github.com/immense/vue-pom-generator/pull/12)
45
+ - #11 feat: fail fast on unnameable wrapper handlers
46
+ (https://github.com/immense/vue-pom-generator/pull/11)
44
47
 
45
48
  ## Testing
46
49
 
47
- Comprehensive test coverage added with 80+ new test cases spanning handler naming validation,
48
- transformation scenarios, plugin options, and edge case coverage.
50
+ Added 173+ lines of new tests for TypeScript code generation, including fixtures for BasePage
51
+ and Pointer types. Updated existing test suites to cover split output scenarios and plugin
52
+ options.
49
53