@immense/vue-pom-generator 1.0.93 → 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: {
@@ -1077,10 +1077,10 @@ The sections below follow the actual `VuePomGeneratorPluginOptions` shape from `
1077
1077
 
1078
1078
  #### `injection.nativeWrappers`
1079
1079
 
1080
- - **What it does:** Describes wrapper components so the generator can treat them like native controls.
1081
- - **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.
1082
1082
  - **Benefit:** You get stable control-specific ids and methods instead of generic component-shaped names.
1083
- - **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.
1084
1084
  - **Example:**
1085
1085
 
1086
1086
  ```ts
@@ -1096,10 +1096,10 @@ The sections below follow the actual `VuePomGeneratorPluginOptions` shape from `
1096
1096
 
1097
1097
  ##### `nativeWrappers[...].role`
1098
1098
 
1099
- - **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`).
1100
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.
1101
1101
  - **Benefit:** The generated API matches what the wrapped control actually does.
1102
- - **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.
1103
1103
  - **Without it:** wrapper components may be treated as generic tags unless they can be inferred.
1104
1104
 
1105
1105
  ##### `nativeWrappers[...].valueAttribute`
@@ -1117,24 +1117,24 @@ The sections below follow the actual `VuePomGeneratorPluginOptions` shape from `
1117
1117
  - **Without it:** option-level ids may be incomplete or ambiguous.
1118
1118
  - **Caveat:** preserving an existing manual root id on these wrappers can be unsafe, and the current implementation will throw in that case.
1119
1119
 
1120
- #### `injection.excludeComponents`
1120
+ #### `injection.skipTestIdGenerationInsideComponents`
1121
1121
 
1122
- - **What it does:** Opts specific component names out of injection/collection.
1123
- - **Why it exists:** Some components are better left alone, or are generated/third-party surfaces you do not want rewritten.
1124
- - **Benefit:** Gives you a practical escape hatch without disabling the plugin globally.
1125
- - **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.
1126
1126
  - **Example:**
1127
1127
 
1128
1128
  ```ts
1129
- injection: { excludeComponents: ["LegacyWidget"] }
1129
+ injection: { skipTestIdGenerationInsideComponents: ["LegacyWidget"] }
1130
1130
  ```
1131
1131
 
1132
1132
  #### `injection.wrapperSearchRoots`
1133
1133
 
1134
- - **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.
1135
1135
  - **Why it exists:** wrapper components often live in sibling packages or shared UI workspaces.
1136
1136
  - **Benefit:** local wrapper inference can still work across package boundaries.
1137
- - **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.
1138
1138
  - **Example:**
1139
1139
 
1140
1140
  ```ts
package/RELEASE_NOTES.md CHANGED
@@ -1,36 +1,83 @@
1
- I'll verify the actual release contents before writing notes, since the provided PR list appears
2
- much longer than the diff suggests.
1
+ I'll analyze the provided information and verify which PRs fall within the release window using the
2
+ GitHub API.
3
3
 
4
- v1.0.92's tip is #54, so only #56 is new in v1.0.93. Let me inspect the actual diff for accurate
5
- notes.
4
+ The git log confirms only one commit (#57) in the range. Let me verify PR merge times using the
5
+ GitHub API.
6
6
 
7
- Verification complete: v1.0.92 was tagged at #54's merge, so v1.0.93 contains only PR #56. Here are
8
- the release notes.
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.
9
+
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.
9
12
 
10
13
  Highlights
11
14
 
12
- - New public package entry point @immense/vue-pom-generator/playwright/runtime exposes the BasePage
13
- runtime for handwritten POMs to extend.
14
- - README documents the stable runtime contract and warns against importing from the regenerated
15
- _pom-runtime directory.
16
- - Packed smoke check now verifies the runtime entry exports BasePage and ObjectId from a packed
17
- install.
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.
18
29
 
19
30
  Changes
20
31
 
21
- - Packaging: Added the ./playwright/runtime subpath export (types/import/require) pointing at
22
- dist/class-generation/base-page.d.ts and dist/playwright/runtime.{mjs,cjs}.
23
- - Build: Registered the playwright/runtime source entry in vite.config.ts.
24
- - Docs: Documented importing BasePage from the public runtime entry for handwritten helpers, and
25
- clarified that a consumer's generated _pom-runtime directory is an implementation detail that should
26
- not be imported directly.
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.
59
+
60
+ Breaking Changes
61
+
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.
27
72
 
28
73
  Pull Requests Included
29
74
 
30
- - ]8;id=md-1g2un4x;https://github.com/immense/vue-pom-generator/pull/56#56 feat(playwright): export POM runtime]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;;
31
76
 
32
77
  Testing
33
78
 
34
- - Extended scripts/packed-smoke-check.mjs to assert the public runtime entry exports BasePage and
35
- ObjectId from a packed tarball install.
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.
36
83