Introduce npx nx mock:generate twenty-front (#18237)

## Add codegen script for frontend test mock data

### Summary

- Adds a new `npx nx mock:generate twenty-front` and
`generate-mock-data.ts` script that fetches object metadata from a
running server's `/metadata` endpoint, authenticates with default seeds,
and writes the result to a generated TypeScript file
(`src/testing/mock-data/generated/mock-metadata-query-result.ts`). This
replaces hand-maintained mock metadata with server-sourced data,
ensuring tests always reflect the real schema.
- Updates all frontend tests to be compatible with the newly generated
metadata, fixing hard-coded GraphQL queries, Zod validation schemas,
snapshot expectations, and Apollo mock mismatches.

### What changed

**New files**
- `scripts/generate-mock-data.ts` — codegen script that authenticates
against the server, queries `/metadata` for all object metadata (with
explicit `__typename` at every level), and writes a typed `.ts` file.
- `project.json` — added `mock:generate` Nx target (`dotenv npx tsx
scripts/generate-mock-data.ts`).

**Schema validation updates**
- `objectMetadataItemSchema.ts` — added `universalIdentifier`, made
`duplicateCriteria` nullable.
- `fieldMetadataItemSchema.ts` — added `universalIdentifier`, `morphId`,
`morphRelations`, restructured relation schema.
- `indexMetadataItemSchema.ts` — added optional `isCustom` field.
This commit is contained in:
Charles Bochet
2026-02-25 21:40:05 +01:00
committed by GitHub
parent 50be97422d
commit e01b641a05
25 changed files with 24997 additions and 18246 deletions
@@ -25,10 +25,8 @@ export const mapPaginatedObjectMetadataItemsToObjectMetadataItems = ({
object.node;
return {
universalIdentifier: object.node.id,
...objectWithoutFieldsList,
fields: fieldsList.map((field) => ({
universalIdentifier: field.id,
...field,
})),
labelIdentifierFieldMetadataId,