@immense/vue-pom-generator 1.0.8 → 1.0.10

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/RELEASE_NOTES.md CHANGED
@@ -1,38 +1,28 @@
1
1
  ● ## Highlights
2
- - Added Nuxt pages introspection to router introspection.
3
- - Major overhaul of Vue plugin with expanded support/dev/build plugins and types.
4
- - Introduced Playwright types and updated class generation pipeline.
5
- - Significant updates to transform and utility modules to support new features.
6
- - CI improvements: release on main without gate and a pre-push up-to-date guard.
2
+ - Adopt native Playwright Page and Locator types for PwPage and PwLocator.
3
+ - Add test for existingIdBehavior error handling.
4
+ - Improve type safety in tests by replacing any with specific types.
5
+ - Fix type error in existing-id-error.test.ts.
6
+ - Updates across class-generation and plugin modules.
7
7
 
8
8
  ## Changes
9
- - Router Introspection
10
- - Enhanced router-introspection.ts to add Nuxt pages introspection functionality.
11
- - Plugin System
12
- - Overhauled plugin/vue-plugin.ts (+286/- changes) with expanded capabilities.
13
- - Updated support plugins: dev-plugin, build-plugin, support-plugins, path-utils, logger, and
14
- types.
15
- - Improved create-vue-pom-generator-plugins.ts for plugin creation.
16
- - Class Generation
17
- - Added class-generation/playwright-types.ts.
18
- - Updated BasePage, Pointer, index.ts, and method-generation.ts for generation flow.
19
- - Transform & Utilities
20
- - Refactored transform.ts and utils.ts with substantial changes.
21
- - Minor eslint.config.ts adjustments.
22
- - CI & Tooling
23
- - Updated .github/workflows/release.yml and agentic-release-notes.lock.yml.
24
- - Added scripts/git-hooks/pre-push.sh pre-push guard.
25
- - Cleaned up .gitignore; updated package.json and package-lock.json for git hooks.
26
- - Documentation & Logs
27
- - Linted README.md.
28
- - Added build_v5.log and build_web_v5.log.
9
+ - Types
10
+ - Use native Playwright Page/Locator for PwPage/PwLocator (class-generation/index.ts,
11
+ class-generation/playwright-types.ts)
12
+ - Tests
13
+ - Add tests/existing-id-error.test.ts for existingIdBehavior error handling
14
+ - Fix type error in tests/existing-id-error.test.ts
15
+ - Update tests/utils-coverage.test.ts
16
+ - Plugin
17
+ - Update plugin/vue-plugin.ts
18
+ - Tooling/Config
19
+ - Update eslint.config.ts
20
+ - Update package.json
29
21
 
30
22
  ## Pull Requests Included
31
- - #1 Add PR release-notes preview comments (https://github.com/immense/vue-pom-generator/pull/1)
32
- by @dkattan
23
+ - #1 Add PR release-notes preview comments https://github.com/immense/vue-pom-generator/pull/1
24
+ (by @dkattan)
33
25
 
34
26
  ## Testing
35
- - Updated tests in tests/options.test.ts and tests/utils-coverage.test.ts; adjusted fixture
36
- MyComp_CancelButtons_InnerText.vue.
37
- - No new test suites added.
27
+ - New test added and existing tests updated; type errors addressed.
38
28
 
@@ -1193,6 +1193,12 @@ async function generateAggregatedFiles(
1193
1193
  throw new Error(`Failed to read playwright-types.ts at ${typesPath}`);
1194
1194
  }
1195
1195
 
1196
+ // Strip the import from the inlined types.
1197
+ typesSource = typesSource.replace(
1198
+ /import\s+type\s*\{\s*Locator\s+as\s+PwLocator\s*,\s*Page\s+as\s+PwPage\s*\}\s*from\s*["']@playwright\/test["'];?\s*/,
1199
+ "",
1200
+ );
1201
+
1196
1202
  return typesSource.trim();
1197
1203
  };
1198
1204
 
@@ -1555,7 +1561,7 @@ async function generateAggregatedFiles(
1555
1561
 
1556
1562
  const base = ensureDir(outDir);
1557
1563
  const outputFile = path.join(base, "page-object-models.g.ts");
1558
- const header = `/// <reference lib="es2015" />\n${eslintSuppressionHeader}/**\n * Aggregated generated POMs\n${AUTO_GENERATED_COMMENT}`;
1564
+ const header = `/// <reference lib="es2015" />\n${eslintSuppressionHeader}import type { Locator as PwLocator, Page as PwPage } from "@playwright/test";\n/**\n * Aggregated generated POMs\n${AUTO_GENERATED_COMMENT}`;
1559
1565
  const content = makeAggregatedContent(header, path.dirname(outputFile), [...views, ...components]);
1560
1566
 
1561
1567
  const indexFile = path.join(base, "index.ts");
@@ -1,23 +1,5 @@
1
- export interface PwLocator {
2
- locator: (selector: string) => PwLocator;
3
- first: () => PwLocator;
4
- count: () => Promise<number>;
5
- click: (options?: { force?: boolean }) => Promise<void>;
6
- fill: (value: string, options?: { force?: boolean; timeout?: number }) => Promise<void>;
7
- getAttribute: (name: string) => Promise<string | null>;
8
- scrollIntoViewIfNeeded: (options?: { timeout?: number }) => Promise<void>;
9
- }
1
+ import type { Locator as PwLocator, Page as PwPage } from "@playwright/test";
10
2
 
11
- export type PwSelectOption = string | { value?: string; label?: string; index?: number };
3
+ export type { PwLocator, PwPage };
12
4
 
13
- export interface PwPage {
14
- locator: (selector: string) => PwLocator;
15
- url: () => string;
16
- waitForTimeout: (timeout: number) => Promise<void>;
17
- evaluate: <R, Arg>(pageFunction: (arg: Arg) => R | Promise<R>, arg: Arg) => Promise<R>;
18
- isVisible: (selector: string, options?: { timeout?: number }) => Promise<boolean>;
19
- textContent: (selector: string, options?: { timeout?: number }) => Promise<string | null>;
20
- waitForSelector: (selector: string, options?: { timeout?: number }) => Promise<object | null>;
21
- hover: (selector: string, options?: { timeout?: number }) => Promise<void>;
22
- selectOption: (selector: string, values: PwSelectOption | PwSelectOption[], options?: { timeout?: number }) => Promise<string[]>;
23
- }
5
+ export type PwSelectOption = string | { value?: string; label?: string; index?: number };
package/dist/index.cjs CHANGED
@@ -3462,6 +3462,10 @@ async function generateAggregatedFiles(componentHierarchyMap, vueFilesPathMap, b
3462
3462
  } catch {
3463
3463
  throw new Error(`Failed to read playwright-types.ts at ${typesPath}`);
3464
3464
  }
3465
+ typesSource = typesSource.replace(
3466
+ /import\s+type\s*\{\s*Locator\s+as\s+PwLocator\s*,\s*Page\s+as\s+PwPage\s*\}\s*from\s*["']@playwright\/test["'];?\s*/,
3467
+ ""
3468
+ );
3465
3469
  return typesSource.trim();
3466
3470
  };
3467
3471
  const inlinePointerModule = () => {
@@ -3727,7 +3731,8 @@ async function generateAggregatedFiles(componentHierarchyMap, vueFilesPathMap, b
3727
3731
  const base = ensureDir(outDir);
3728
3732
  const outputFile = path.join(base, "page-object-models.g.ts");
3729
3733
  const header = `/// <reference lib="es2015" />
3730
- ${eslintSuppressionHeader}/**
3734
+ ${eslintSuppressionHeader}import type { Locator as PwLocator, Page as PwPage } from "@playwright/test";
3735
+ /**
3731
3736
  * Aggregated generated POMs
3732
3737
  ${AUTO_GENERATED_COMMENT}`;
3733
3738
  const content = makeAggregatedContent(header, path.dirname(outputFile), [...views, ...components]);
@@ -5365,8 +5370,16 @@ function createVuePluginWithTestIds(options) {
5365
5370
  ...userCompilerOptions,
5366
5371
  prefixIdentifiers: true,
5367
5372
  nodeTransforms: [
5368
- // This will be used if the user uses the returned vue plugin.
5369
- // We'll populate it via the hook below for better compatibility.
5373
+ ...userNodeTransforms,
5374
+ (node, context) => {
5375
+ const filename = context.filename;
5376
+ if (!filename || !filename.endsWith(".vue") || !isFileInScope(filename)) {
5377
+ return;
5378
+ }
5379
+ const transforms = getNodeTransforms(filename);
5380
+ const ourTransform = transforms[transforms.length - 1];
5381
+ return ourTransform(node, context);
5382
+ }
5370
5383
  ]
5371
5384
  };
5372
5385
  const metadataCollectorPlugin = {
@@ -5382,21 +5395,17 @@ function createVuePluginWithTestIds(options) {
5382
5395
  }
5383
5396
  const componentName = getComponentNameFromPath(cleanPath);
5384
5397
  loggerRef.current.debug(`Collecting metadata for ${cleanPath} (component: ${componentName})`);
5385
- try {
5386
- const { parse } = await import("@vue/compiler-sfc");
5387
- const compilerDom2 = await import("@vue/compiler-dom");
5388
- const compile = compilerDom2.compile;
5389
- const { descriptor } = parse(code, { filename: cleanPath });
5390
- if (descriptor.template) {
5391
- compile(descriptor.template.content, {
5392
- ...userCompilerOptions,
5393
- filename: cleanPath,
5394
- nodeTransforms: getNodeTransforms(cleanPath, componentName)
5395
- });
5396
- loggerRef.current.debug(`Metadata collected for ${cleanPath}`);
5397
- }
5398
- } catch (e) {
5399
- loggerRef.current.warn(`Metadata collection failed for ${cleanPath}: ${e}`);
5398
+ const { parse } = await import("@vue/compiler-sfc");
5399
+ const compilerDom2 = await import("@vue/compiler-dom");
5400
+ const compile = compilerDom2.compile;
5401
+ const { descriptor } = parse(code, { filename: cleanPath });
5402
+ if (descriptor.template) {
5403
+ compile(descriptor.template.content, {
5404
+ ...userCompilerOptions,
5405
+ filename: cleanPath,
5406
+ nodeTransforms: getNodeTransforms(cleanPath, componentName)
5407
+ });
5408
+ loggerRef.current.debug(`Metadata collected for ${cleanPath}`);
5400
5409
  }
5401
5410
  return null;
5402
5411
  }