feat(mocks): ship mock engine — HealthcheckMockBuilder + 7 scenario fixtures#31
feat(mocks): ship mock engine — HealthcheckMockBuilder + 7 scenario fixtures#31comnam90 wants to merge 2 commits into
Conversation
Move src/scripts/generate-mocks.ts to the root-level scripts/ directory to keep Node.js APIs (fs, path, process) out of src/. Fix TS1484 in generator.ts by adding the missing 'type' keyword to the HealthcheckRoot import. Extend tsconfig.node.json to cover scripts/ with the @/* path alias so imports chain correctly through src/ types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… fixtures Builder-pattern generator covering all validation scenarios: passing v12, legacy v11 (version blocker), AWS blocker, unencrypted job (warning), community edition, low retention, and advanced cloud (GFS + archive tier). Pre-generated JSON fixtures committed to mocks/ for developer convenience. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deploying vdc-vault-readiness with
|
| Latest commit: |
859a75f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://573110bd.vdc-vault-readiness.pages.dev |
| Branch Preview URL: | https://feature-mock-engine.vdc-vault-readiness.pages.dev |
There was a problem hiding this comment.
Pull request overview
This PR introduces a mock data generation system for creating synthetic Veeam healthcheck JSON files to support testing and development. The implementation moves the generator script from src/scripts/ to scripts/ (root level) to properly separate Node.js tooling from browser code, adds TypeScript path alias support to tsconfig.node.json, and commits 7 pre-generated JSON fixtures covering various validation scenarios.
Changes:
- Adds
HealthcheckMockBuilderclass with factory methods for generating realistic healthcheck data across 7 validation scenarios - Relocates mock generation script from
src/scripts/toscripts/following project architecture constraints - Configures
tsconfig.node.jsonwith path aliases and scripts inclusion to support TypeScript tooling
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/lib/mocks/generator.ts |
New mock builder class with 7 static factory methods and fluent API for constructing healthcheck data |
scripts/generate-mocks.ts |
Mock generation script relocated from src/ to maintain separation of Node.js and browser code |
tsconfig.node.json |
Added baseUrl, paths config for @/* alias, and scripts directory to include list |
package.json |
Added generate-mocks script and tsx ^4.21.0 dev dependency |
package-lock.json |
Lock file updates for tsx and its dependencies (get-tsconfig, resolve-pkg-maps) |
mocks/*.json |
7 pre-generated fixture files for perfect, legacy, blocker, warning, community, retention, and advanced cloud scenarios |
| @@ -0,0 +1,579 @@ | |||
| import type { HealthcheckRoot } from "../../types/healthcheck"; | |||
There was a problem hiding this comment.
The HealthcheckMockBuilder class lacks test coverage. Consider adding tests that verify each static factory method (createPassingV12, createLegacyV11, etc.) generates valid HealthcheckRoot objects that successfully pass through the analyzeHealthcheck pipeline. This would ensure the mock generator produces realistic test data that aligns with the actual validation logic. The existing test infrastructure in src/tests/pipeline.test.ts provides a good pattern to follow.
| @@ -0,0 +1,29 @@ | |||
| import { HealthcheckMockBuilder } from "../src/lib/mocks/generator"; | |||
There was a problem hiding this comment.
Consider using the path alias import instead of a relative path to align with the tsconfig.node.json configuration added in this PR. Change to: import { HealthcheckMockBuilder } from "@/lib/mocks/generator";
This would be consistent with the PR's stated goal of adding the @/* path alias to tsconfig.node.json for improved import resolution.
| import { HealthcheckMockBuilder } from "../src/lib/mocks/generator"; | |
| import { HealthcheckMockBuilder } from "@/lib/mocks/generator"; |
| @@ -0,0 +1,579 @@ | |||
| import type { HealthcheckRoot } from "../../types/healthcheck"; | |||
There was a problem hiding this comment.
Consider using the path alias import instead of a relative path for consistency with the newly added tsconfig.node.json configuration. Change to: import type { HealthcheckRoot } from "@/types/healthcheck";
This aligns with the project's path alias configuration and improves maintainability as the file structure changes.
| import type { HealthcheckRoot } from "../../types/healthcheck"; | |
| import type { HealthcheckRoot } from "@/types/healthcheck"; |
Summary
src/scripts/generate-mocks.tstoscripts/(root level) to keep Node.js APIs out ofsrc/per project constraints; adds@/*path alias totsconfig.node.jsonso import chains fromscripts/resolve correctly throughsrc/typestypekeyword toHealthcheckRootimport ingenerator.ts(TS1484 /verbatimModuleSyntax)src/lib/mocks/generator.tsand 7 pre-generated JSON fixtures inmocks/What's included
src/lib/mocks/generator.tsimport→import type(TS1484 fix)scripts/generate-mocks.tssrc/scripts/; import path updatedtsconfig.node.json"scripts"toinclude; added@/*path aliaspackage.jsongenerate-mocksscript updated totsx scripts/generate-mocks.tsmocks/*.jsonScenarios covered by the builder
perfect-v12.jsonlegacy-v11.jsonblocker-aws.jsonwarning-unencrypted.jsoncommunity-edition.jsonlow-retention.jsonadvanced-cloud.jsonTest plan
npm run build— clean (0 errors)npm run test:run— 718/718 tests passnpm run generate-mocks— executes from new location, writes all 7 files🤖 Generated with Claude Code