@immense/vue-pom-generator 1.0.92 → 1.0.94

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
@@ -23,7 +23,7 @@ If you already use Playwright with `getByTestId`, the point is simple: this pack
23
23
  ## What this does not do
24
24
 
25
25
  - **It is not a runtime DOM crawler.** It only knows what it can learn from Vue SFC templates and router introspection.
26
- - **It does not fully understand arbitrary wrapper components automatically.** There is some wrapper inference for simple local SFCs and some naming conventions, but serious design-system components still need `injection.nativeWrappers`.
26
+ - **It does not execute arbitrary wrapper data flow.** It understands Vue's normal fallthrough patterns, direct `useAttrs()` aliases, explicit configured-test-id forwarding, and simple helpers that omit named attributes. Polymorphic or third-party controls can still need `injection.nativeWrappers` overrides.
27
27
  - **It cannot infer query-value types from arbitrary route-props code.** Generated `goTo()` accepts discovered query keys as optional `string | number` values; callers still choose and supply the values appropriate for their application.
28
28
  - **It does not auto-attach every file in `pom/custom`.** Custom helpers are imported, but they only affect generated classes when you explicitly configure attachments, or when they match the built-in `Toggle` / `Checkbox` widget conventions.
29
29
  - **It does not make override classes globally replace generated classes.** `pom/overrides` only changes generated fixture instantiation. Direct imports from the generated barrel still give you the generated class unless you import your override yourself.
@@ -75,11 +75,11 @@ The generator does not use one naming trick. It layers several signals.
75
75
  - **Inputs and wrapper components** prefer `v-model`, wrapper `valueAttribute`, or related model-like bindings.
76
76
  - **Native elements** also consider `id` / `name` attributes.
77
77
  - **Router links / `:to` bindings** can contribute route-based naming and typed navigation return types when the target can be resolved.
78
- - **Wrapper components** can be explicit (`nativeWrappers`) or inferred from simple local SFC templates.
78
+ - **Wrapper components** are inferred from the rendered element that actually receives Vue fallthrough attributes; `nativeWrappers` supplies exceptional overrides.
79
79
  - **Fallback naming exists, but it is intentionally conservative.** That is why `generation.nameCollisionBehavior` exists.
80
80
  - **Wrapper-action generation fails fast.** The generator blocks button-like wrapper `:handler` expressions that it cannot turn into a semantic action name.
81
81
 
82
- Important limit: wrapper inference is helpful, not magical. The current implementation recursively inspects simple local SFC templates for the first inferable primitive (`input`, `textarea`, `select`, `button`, `vselect`, radio/checkbox inputs, and `a` *with `href`*/`RouterLink` → `link`). It also recognizes some naming patterns like `*Button`. For anything more complex, configure `nativeWrappers` explicitly.
82
+ Wrapper inference follows the public attribute contract instead of scanning for an arbitrary interactive descendant. It recognizes automatic single-root fallthrough, `v-bind="$attrs"`, aliases returned by `useAttrs()`, explicit forwarding such as `:data-testid="$attrs['data-testid']"`, and simple helpers that copy all attributes except named keys. The role comes from that target's explicit static ARIA role first, then its native HTML semantics. This means `<button role="tab">` is a tab, while `<div><button>...</button></div>` is not misclassified as a button wrapper because the caller's test id lands on the `<div>`. Nested wrappers are followed recursively. Polymorphic targets with different roles are deliberately left unresolved; configure `nativeWrappers` when one stable generated role is still appropriate.
83
83
 
84
84
  ## Playwright before/after examples
85
85
 
@@ -241,7 +241,7 @@ const pomConfig = defineVuePomGeneratorConfig({
241
241
  AppTextField: { role: "input" },
242
242
  AppRadioGroup: { role: "radio", requiresOptionDataTestIdPrefix: true },
243
243
  },
244
- excludeComponents: ["LegacyWidget"],
244
+ skipTestIdGenerationInsideComponents: ["LegacyWidget"],
245
245
  existingIdBehavior: "error",
246
246
  },
247
247
  generation: {
@@ -594,6 +594,22 @@ This is where most people need precision.
594
594
 
595
595
  Every `.ts` file in `customPoms.dir` is available for import from the generated TypeScript output.
596
596
 
597
+ Handwritten helpers that extend the generator runtime should use its public entry point:
598
+
599
+ ```ts
600
+ import { BasePage } from "@immense/vue-pom-generator/playwright/runtime";
601
+
602
+ export class DataGrid extends BasePage {
603
+ async selectFirstRow(): Promise<void> {
604
+ await this.page.getByRole("row").nth(1).click();
605
+ }
606
+ }
607
+ ```
608
+
609
+ Do not import from a consumer's generated `_pom-runtime` directory. That directory is regenerated
610
+ and is an implementation detail of the emitted files; the package export is the stable contract for
611
+ handwritten POMs.
612
+
597
613
  - in aggregated mode, helper files become imports in the shared aggregate
598
614
  - in split mode, each generated file imports only the helpers it actually needs
599
615
 
@@ -1061,10 +1077,10 @@ The sections below follow the actual `VuePomGeneratorPluginOptions` shape from `
1061
1077
 
1062
1078
  #### `injection.nativeWrappers`
1063
1079
 
1064
- - **What it does:** Describes wrapper components so the generator can treat them like native controls.
1065
- - **Why it exists:** Many Vue apps wrap buttons, inputs, selects, radio groups, or third-party widgets behind design-system components.
1080
+ - **What it does:** Overrides or augments source-derived wrapper contracts.
1081
+ - **Why it exists:** Polymorphic controls, third-party components without local SFC source, and domain-specific option widgets cannot always expose one role/value contract through static Vue source.
1066
1082
  - **Benefit:** You get stable control-specific ids and methods instead of generic component-shaped names.
1067
- - **Without it:** the generator relies on native elements, limited wrapper inference, and a few naming conventions.
1083
+ - **Without it:** ordinary local wrappers are inferred from Vue fallthrough targets and their native/ARIA semantics.
1068
1084
  - **Example:**
1069
1085
 
1070
1086
  ```ts
@@ -1080,10 +1096,10 @@ The sections below follow the actual `VuePomGeneratorPluginOptions` shape from `
1080
1096
 
1081
1097
  ##### `nativeWrappers[...].role`
1082
1098
 
1083
- - **What it does:** Chooses the native behavior to emulate (`button`, `input`, `select`, `vselect`, `checkbox`, `toggle`, `radio`, `grid`, `link`).
1099
+ - **What it does:** Chooses the native behavior to emulate (`button`, `input`, `select`, `vselect`, `checkbox`, `toggle`, `radio`, `grid`, `link`, `tab`).
1084
1100
  - **Why it exists:** Role drives both test-id suffixes and generated POM method families (`click...`, `type...`, `select...`, etc.). `link` is the role for anchor-rendering wrappers (components that render an `<a>`/`RouterLink`); it produces `...Link` accessors and `-link` test-id suffixes, with `goTo...` navigation methods when a `:to` route target is resolvable.
1085
1101
  - **Benefit:** The generated API matches what the wrapped control actually does.
1086
- - **Optional / inferred:** `role` may be omitted. When omitted, the generator infers it from the wrapper's rendered template — a component rendering an `<a>` *with an `href`* (or a `RouterLink`, directly or through nested wrapper components like a shared `AppLink`) infers `link`, an `<input>` infers `input`, and so on. Recursion follows `wrapperSearchRoots`. A bare `<a>` without an `href` is **not** a link (it has no implicit ARIA role) and won't be classified as `link`. If no native role can be inferred, the generator **throws** rather than guessing — declare `role` explicitly for wrappers that don't render a recognized native control. Declaring `role` explicitly always takes precedence over inference.
1102
+ - **Optional / inferred:** `role` may be omitted. The generator resolves the element that receives the configured test-id, honors a static ARIA `role` before implicit tag semantics, and follows nested wrapper contracts. A bare `<a>` without `href` is not a link. If the target is non-interactive or multiple forwarding targets have different roles, the generator throws for a configured wrapper with no role rather than guessing. Declaring `role` explicitly always takes precedence.
1087
1103
  - **Without it:** wrapper components may be treated as generic tags unless they can be inferred.
1088
1104
 
1089
1105
  ##### `nativeWrappers[...].valueAttribute`
@@ -1101,24 +1117,24 @@ The sections below follow the actual `VuePomGeneratorPluginOptions` shape from `
1101
1117
  - **Without it:** option-level ids may be incomplete or ambiguous.
1102
1118
  - **Caveat:** preserving an existing manual root id on these wrappers can be unsafe, and the current implementation will throw in that case.
1103
1119
 
1104
- #### `injection.excludeComponents`
1120
+ #### `injection.skipTestIdGenerationInsideComponents`
1105
1121
 
1106
- - **What it does:** Opts specific component names out of injection/collection.
1107
- - **Why it exists:** Some components are better left alone, or are generated/third-party surfaces you do not want rewritten.
1108
- - **Benefit:** Gives you a practical escape hatch without disabling the plugin globally.
1109
- - **Without it:** all in-scope Vue components are eligible for injection.
1122
+ - **What it does:** Prevents generated test ids and POM members anywhere inside the named component implementations.
1123
+ - **Why it exists:** It is a last-resort escape hatch for generated, third-party, or otherwise untransformable SFC templates.
1124
+ - **Wrapper components usually do not need it:** When a wrapper explicitly forwards fallthrough attributes, the generator suppresses generation only on the forwarding target. Other interactive controls inside the wrapper still receive generated ids and methods.
1125
+ - **Tradeoff:** This skips the entire component implementation, so use it only when target-level fallthrough analysis cannot describe the source.
1110
1126
  - **Example:**
1111
1127
 
1112
1128
  ```ts
1113
- injection: { excludeComponents: ["LegacyWidget"] }
1129
+ injection: { skipTestIdGenerationInsideComponents: ["LegacyWidget"] }
1114
1130
  ```
1115
1131
 
1116
1132
  #### `injection.wrapperSearchRoots`
1117
1133
 
1118
- - **What it does:** Adds extra roots for wrapper inference outside the configured page/component/layout directories.
1134
+ - **What it does:** Adds extra roots for wrapper inference outside the page/component/layout directories, which are searched automatically.
1119
1135
  - **Why it exists:** wrapper components often live in sibling packages or shared UI workspaces.
1120
1136
  - **Benefit:** local wrapper inference can still work across package boundaries.
1121
- - **Without it:** no extra wrapper lookup is done outside the configured app directories.
1137
+ - **Without it:** wrapper lookup is limited to the configured app directories.
1122
1138
  - **Example:**
1123
1139
 
1124
1140
  ```ts
package/RELEASE_NOTES.md CHANGED
@@ -1,119 +1,83 @@
1
- I'll verify the actual merged PRs in the release window by querying the repository directly, and
2
- check the git log between the tags.
1
+ I'll analyze the provided information and verify which PRs fall within the release window using the
2
+ GitHub API.
3
3
 
4
- Let me check the v1.0.91 tag to understand the boundary, and verify the PR merge details.
4
+ The git log confirms only one commit (#57) in the range. Let me verify PR merge times using the
5
+ GitHub API.
5
6
 
6
- Let me retry those queries.
7
+ Good — v1.0.93..HEAD contains only #57 (v1.0.93 points at #56). Let me get PR #57's details and diff
8
+ for accurate notes.
7
9
 
8
- Now I understand the picture. The v1.0.91 tag is at commit #53, so v1.0.92 contains only PR #54. Let
9
- me examine the key changed files to write accurate release notes.
10
-
11
- Let me check the diagnostics module and README changes to round out the picture.
12
-
13
- I now have a complete picture. v1.0.91 was tagged at PR #53's commit, so v1.0.92 contains only PR
14
- #54. Let me write the release notes.
10
+ Now I have all the information needed. Only PR #57 is in this release (v1.0.93 points at #56's
11
+ commit). Let me verify the test files were updated.
15
12
 
16
13
  Highlights
17
14
 
18
- - Fast, actionable Playwright failure diagnostics — generated fixtures now capture the full failure
19
- state (URL, rendered test IDs, accessibility snapshot, console errors, failed requests, HTTP
20
- response bodies, active action, and POM method catalog) before the browser context is destroyed,
21
- within a five-second budget.
22
- - Bundled Playwright reporter — a new @immense/vue-pom-generator/playwright/reporter subpath prints
23
- diagnostics as one bounded, LLM-friendly stdout block and emits a structured JSON attachment.
24
- - Generated POM manifest — a new pom-manifest.g.ts artifact maps Vue source/test IDs to their
25
- generated methods, consumable at runtime by the diagnostics layer.
26
- - Composable recommended ESLint config — recommendedPlaywrightConfig composes generator-specific
27
- rules with eslint-plugin-playwright, banning manual waits, networkidle, selector waits, forced
28
- actions, and non-web-first assertions.
29
- - Five-second action failure budget — generated actions now fail fast instead of waiting out
30
- Playwright's default timeout, and redundant runtime waits have been removed.
31
- - Finite-animation awareness — generated clicks await finite CSS animations on the target's
32
- ancestor chain (bounded to five seconds); infinite decorative animations are ignored.
15
+ - New wrapper-contract inference engine (wrapper-contract.ts, 1,009 lines) replaces heuristic
16
+ template scanning with Vue's actual attribute-fallthrough contract — it follows automatic
17
+ single-root fallthrough, v-bind="$attrs", useAttrs() aliases, explicit :data-testid forwarding, and
18
+ simple copy-all-except helpers.
19
+ - Role resolution honors ARIA first. The target element's static ARIA role is checked before native
20
+ tag semantics, so <button role="tab"> is correctly classified as a tab while a <div> wrapping a
21
+ <button> is no longer misclassified as a button wrapper.
22
+ - Polymorphic targets fail fast. When multiple forwarding targets expose different roles, the
23
+ generator throws rather than guessing — you declare role explicitly when a single stable role is
24
+ appropriate.
25
+ - New tab role added to NativeRole, enabling tab-pattern wrapper components to generate correct
26
+ accessors and test-id suffixes.
27
+ - Inferred wrappers auto-derive valueAttribute from common semantic attributes (aria-label, name,
28
+ id, title, label) when none is configured.
33
29
 
34
30
  Changes
35
31
 
36
- Diagnostics & Reporting
37
-
38
- - Added class-generation/diagnostics.ts — installs a failure-capture wrapper around the browser
39
- page that gathers URL/title, rendered test IDs with visible/enabled state, the best-matching POM and
40
- its method catalog, the most recent generated action and expected test-id candidates, an
41
- accessibility snapshot, buffered console/page errors, failed requests, bounded HTTP failure bodies,
42
- a screenshot, and a JSON attachment.
43
- - Added playwright/reporter.ts — a Playwright reporter that reads the diagnostics attachment and
44
- prints a single bounded stdout block; ends with a file-and-line-targeted rerun command including
45
- --max-failures=1.
46
- - Exported a new package subpath @immense/vue-pom-generator/playwright/reporter.
47
- - Method availability is reported descriptively (absent, hidden, disabled) rather than as errors,
48
- so conditional UI states remain obvious without false failures.
49
-
50
- POM Manifest
51
-
52
- - Added pom-manifest.g.ts — a Node-importable map from Vue source/test IDs to generated methods,
53
- consumed by the diagnostics layer to report method availability.
54
- - Introduced manifest types (PomManifest, PomManifestComponent, PomManifestMethod,
55
- PomManifestEntry) in the diagnostics module.
56
- - Updated manifest-generator.ts to emit the new manifest artifact alongside existing POM output.
57
-
58
- ESLint
59
-
60
- - Added recommendedPlaywrightConfig — a composable flat config that merges
61
- eslint-plugin-playwright's recommended rules with the generator's own rules.
62
- - Enabled playwright/no-wait-for-timeout, playwright/no-networkidle,
63
- playwright/no-wait-for-selector, playwright/no-force-option, and
64
- playwright/prefer-web-first-assertions as errors.
65
- - Banned low-level POM action helpers (clickByTestId, clickLocator) via the no-raw-locator-action
66
- rule.
67
- - Added scrollIntoViewIfNeeded to the recognized locator-action set.
68
- - Restructured the plugin export to include a configs record alongside rules.
69
- - Added eslint-plugin-playwright (^2.11.0) as a runtime dependency.
70
-
71
- Action & Animation Behavior
72
-
73
- - Generated actions now fail within a five-second total budget; redundant runtime waits removed.
74
- - Generated clicks await finite CSS animations on the target's ancestor chain before proceeding,
75
- bounded to five seconds; infinite decorative animations are ignored.
76
- - Animations and presentation delays are disabled by default; recording/demo projects opt in via
77
- the generated animation fixture option.
78
-
79
- Codegen & Navigation
80
-
81
- - Centralized router navigation emission in route-navigation-codegen.ts; cold pages now boot the
82
- application, wait for Vue Router's initial navigation to settle, then use router.push, while warm
83
- pages use the same awaited push without re-booting.
84
- - Tightened fragment, wrapper, radio, checkbox, pointer, and transitive-POM codegen behavior
85
- uncovered by consumer testing.
86
- - Updated class-generation/base-page.ts, class-generation/index.ts, class-generation/pointer.ts,
87
- class-generation/playwright-types.ts, method-generation.ts, transform.ts, and router-bridge.ts to
88
- support the above.
89
-
90
- Plugin & Build
91
-
92
- - Updated plugin/internal-plugins.ts, plugin/internal/build-plugin.ts, and
93
- plugin/internal/dev-plugin.ts for manifest and reporter integration.
94
- - Updated vite.config.ts and scripts/packed-smoke-check.mjs accordingly.
95
-
96
- Documentation
97
-
98
- - Expanded README.md with sections on fast Playwright failures, the bundled reporter, the POM
99
- manifest, recommended lint rules, and animation handling.
32
+ Wrapper Contract Inference
33
+
34
+ - Extracted all wrapper-inference logic from transform.ts into a dedicated wrapper-contract.ts
35
+ module, reducing transform.ts by ~500 lines.
36
+ - getNativeHtmlControlRole and toKebabCaseTag moved into wrapper-contract.ts; transform.ts now
37
+ imports resolved contracts via resolveWrapperContractForTag.
38
+ - Nested wrappers are followed recursively; the contract tracks per-target roles, forwarded test-id
39
+ offsets, and explicit-vs-implicit forwarding distinctions.
40
+ - nativeWrappers is now an override/augmentation layer on top of source-derived contracts rather
41
+ than the primary configuration mechanism.
42
+ - getNativeWrapperTransformInfo in utils.ts now resolves valueAttribute from inferred semantic
43
+ attributes when an explicit value is absent.
44
+
45
+ Plugin Options
46
+
47
+ - wrapperSearchRoots now automatically includes configured page, component, and layout directories
48
+ — no manual duplication needed.
49
+ - README updated to document the new fallthrough-based inference model, the tab role, and the
50
+ revised nativeWrappers semantics.
51
+
52
+ Tests
53
+
54
+ - New tests/wrapper-contract.test.ts (222 lines) covering fallthrough detection, useAttrs()
55
+ aliases, explicit forwarding, ARIA-role precedence, polymorphic-target errors, and recursive
56
+ nesting.
57
+ - Existing tests (build-serve-parity, dev-plugin-options, resolved-injection-options, transform,
58
+ vue-plugin-state) updated for the renamed option.
100
59
 
101
60
  Breaking Changes
102
61
 
103
- - New peer dependency — @playwright/test (>=1.61.0 <2) is now a required peer dependency.
104
- - Five-second action budget — generated actions fail within five seconds instead of relying on
105
- Playwright's default timeout; tests depending on longer timeouts will fail sooner.
106
- - Animations disabled by default — presentation delays are off unless explicitly opted in via the
107
- generated animation fixture option.
62
+ - injection.excludeComponents → injection.skipTestIdGenerationInsideComponents: The option is
63
+ renamed and semantically narrowed. Normal wrapper components no longer need it — fallthrough targets
64
+ are suppressed at the element level while internal controls remain generated. Use it only as a
65
+ last-resort escape hatch for untransformable SFC templates.
66
+ - nativeWrappers without role now errors when no single role can be proven from the source.
67
+ Previously it silently defaulted to button; now it throws so misclassified wrappers surface
68
+ immediately.
69
+ - wrapperSearchRoots auto-includes source directories. If you previously listed your
70
+ component/page/layout dirs in wrapperSearchRoots, they are now searched automatically and can be
71
+ removed from the list.
108
72
 
109
73
  Pull Requests Included
110
74
 
111
- - ]8;id=md-1fivfqz;https://github.com/immense/vue-pom-generator/pull/54#54 — Add fast, actionable Playwright diagnostics]8;;]8;; (@dkattan)]8;;
75
+ - ]8;id=md-1fsv1fy;https://github.com/immense/vue-pom-generator/pull/57#57 — Infer Vue wrapper contracts from fallthrough targets]8;;]8;; (@dkattan)]8;;
112
76
 
113
77
  Testing
114
78
 
115
- Validated per the PR: npm test (401 passed), npm run typecheck, npm run lint, npm run smoke:pack,
116
- and a full Immy Aspire-backed Playwright suite with --max-failures=1 (passed in 4m37s). New test
117
- suites added for diagnostics (tests/playwright-diagnostics.test.ts) and the reporter
118
- (tests/playwright-reporter.test.ts), plus tests/method-generation.test.ts.
79
+ - New tests/wrapper-contract.test.ts suite added covering the full fallthrough-contract inference
80
+ model.
81
+ - Existing test suites updated and passing with the renamed skipTestIdGenerationInsideComponents
82
+ option and revised wrapper-resolution behavior.
119
83