8a7a19f312
## Summary Unifies test mocking tooling across Jest and Storybook, replaces handcrafted mock data with auto-generated server-fetched data, and restructures the mock data generation script for maintainability. ### Mock data generation - Split `generate-mock-data.ts` into three focused modules under `scripts/mock-data/`: - `utils.ts` — shared authentication, GraphQL client, and file writer - `generate-metadata.ts` — fetches object metadata from `/metadata` - `generate-record-data.ts` — fetches record data from `/graphql` using metadata-driven dynamic queries - The orchestrator (`generate-mock-data.ts`) authenticates once and passes the token to both generators - Company records are now fetched from the actual server (limited to 10 records) instead of being handcrafted - Generated files are organized under `generated/metadata/objects/` and `generated/data/companies/` ### Unified test utilities - Consolidated Jest and MSW mocking into shared utilities that compose production code (`prefillRecord`, `getRecordNodeFromRecord`, `getRecordConnectionFromRecords`) with mock metadata - Renamed `generateEmptyJestRecordNode` → `generateMockRecordNode` and moved to `testing/utils/` - Extracted `generateMockRecordConnection` into its own file - Removed `sanitizeInputForPrefill` workaround (no longer needed with correctly shaped generated data)
19 lines
527 B
TypeScript
19 lines
527 B
TypeScript
/* eslint-disable no-console */
|
|
import { generateMetadata } from './mock-data/generate-metadata.js';
|
|
import { generateRecordData } from './mock-data/generate-record-data.js';
|
|
import { authenticate } from './mock-data/utils.js';
|
|
|
|
const main = async () => {
|
|
const token = await authenticate();
|
|
|
|
const metadata = await generateMetadata(token);
|
|
await generateRecordData(token, metadata);
|
|
|
|
console.log('All mock data generated!');
|
|
};
|
|
|
|
main().catch((error) => {
|
|
console.error('Fatal error:', error);
|
|
process.exit(1);
|
|
});
|