Files
twenty/packages/twenty-front/project.json
T
Charles BochetandGitHub 8a7a19f312 Improve test tooling (#18259)
## 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)
2026-02-26 14:31:54 +01:00

286 lines
5.8 KiB
JSON

{
"name": "twenty-front",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"tags": [
"scope:frontend"
],
"targets": {
"build": {
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "{projectRoot}/build"
},
"dependsOn": [
"^build"
]
},
"build:sourcemaps": {
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "{projectRoot}/build"
},
"dependsOn": [
"^build"
]
},
"serve": {
"executor": "nx:run-commands",
"options": {
"command": "npx serve -s {projectRoot}/build"
}
},
"start": {
"executor": "@nx/vite:dev-server",
"options": {
"buildTarget": "twenty-front:build",
"hmr": true
}
},
"preview": {
"executor": "@nx/vite:preview-server",
"options": {
"buildTarget": "twenty-front:build",
"port": 3001,
"open": true
}
},
"reset:env": {
"executor": "nx:run-commands",
"inputs": [
"{projectRoot}/.env.example"
],
"outputs": [
"{projectRoot}/.env"
],
"cache": true,
"options": {
"cwd": "{projectRoot}",
"command": "cp .env.example .env"
}
},
"typecheck": {},
"lint": {
"options": {
"maxWarnings": 0
},
"configurations": {
"ci": {},
"fix": {}
}
},
"lint:diff-with-main": {},
"fmt": {
"options": {
"files": "src"
},
"configurations": {
"fix": {}
}
},
"test": {},
"storybook:build": {
"options": {
"env": {
"NODE_OPTIONS": "--max_old_space_size=8000"
}
},
"configurations": {
"docs": {
"env": {
"STORYBOOK_SCOPE": "ui-docs"
}
},
"modules": {
"env": {
"STORYBOOK_SCOPE": "modules"
}
},
"pages": {
"env": {
"STORYBOOK_SCOPE": "pages"
}
},
"performance": {
"env": {
"STORYBOOK_SCOPE": "performance"
}
}
}
},
"storybook:serve:dev": {
"options": {
"port": 6006
},
"configurations": {
"docs": {
"env": {
"STORYBOOK_SCOPE": "ui-docs"
}
},
"modules": {
"env": {
"STORYBOOK_SCOPE": "modules"
}
},
"pages": {
"env": {
"STORYBOOK_SCOPE": "pages"
}
},
"performance": {
"env": {
"STORYBOOK_SCOPE": "performance"
}
}
}
},
"storybook:serve:static": {
"options": {
"port": 6006
},
"configurations": {
"docs": {
"env": {
"STORYBOOK_SCOPE": "ui-docs"
}
},
"modules": {
"env": {
"STORYBOOK_SCOPE": "modules"
}
},
"pages": {
"env": {
"STORYBOOK_SCOPE": "pages"
}
},
"performance": {
"env": {
"STORYBOOK_SCOPE": "performance"
}
}
}
},
"storybook:coverage": {
"configurations": {
"text": {},
"docs": {
"env": {
"STORYBOOK_SCOPE": "ui-docs"
}
},
"modules": {
"env": {
"STORYBOOK_SCOPE": "modules"
}
},
"pages": {
"env": {
"STORYBOOK_SCOPE": "pages"
}
},
"performance": {
"env": {
"STORYBOOK_SCOPE": "performance"
}
}
}
},
"storybook:test": {
"configurations": {
"docs": {
"env": {
"STORYBOOK_SCOPE": "ui-docs"
}
},
"modules": {
"env": {
"STORYBOOK_SCOPE": "modules"
}
},
"pages": {
"env": {
"STORYBOOK_SCOPE": "pages"
}
},
"performance": {
"env": {
"STORYBOOK_SCOPE": "performance"
}
}
}
},
"storybook:test:no-coverage": {
"configurations": {
"docs": {
"env": {
"STORYBOOK_SCOPE": "ui-docs"
}
},
"modules": {
"env": {
"STORYBOOK_SCOPE": "modules"
}
},
"pages": {
"env": {
"STORYBOOK_SCOPE": "pages"
}
},
"performance": {
"env": {
"STORYBOOK_SCOPE": "performance"
}
}
}
},
"graphql:generate": {
"executor": "nx:run-commands",
"defaultConfiguration": "data",
"options": {
"cwd": "{projectRoot}",
"command": "dotenv graphql-codegen -- --config={args.config}"
},
"configurations": {
"data": {
"config": "codegen.cjs"
},
"metadata": {
"config": "codegen-metadata.cjs"
}
}
},
"mock:generate": {
"executor": "nx:run-commands",
"options": {
"cwd": "{projectRoot}",
"command": "dotenv npx vite-node scripts/generate-mock-data.ts"
}
},
"chromatic": {
"configurations": {
"ci": {}
}
},
"lingui:extract": {
"executor": "nx:run-commands",
"options": {
"cwd": "{projectRoot}",
"command": "lingui extract --overwrite --clean"
}
},
"lingui:compile": {
"executor": "nx:run-commands",
"options": {
"cwd": "{projectRoot}",
"command": "lingui compile --typescript"
}
}
}
}