Files
twenty/packages/twenty-server/test/integration/graphql/suites/inputs-validation/create-validation/rich-text-field-create-input-validation.integration-spec.ts
T
Charles BochetandGitHub d9eb317bb5 feat: rename RICH_TEXT_V2 → RICH_TEXT in codebase (keep DB value) (#18628)
## Summary

- Renames the `FieldMetadataType` enum key from `RICH_TEXT_V2` to
`RICH_TEXT` across the entire codebase, while keeping the underlying
string value as `'RICH_TEXT_V2'` to maintain PostgreSQL database
compatibility
- Renames all related types, guards, hooks, components, and files from
`*RichTextV2*` / `*rich-text-v2*` to `*RichText*` / `*rich-text*` (e.g.
`FormRichTextV2FieldInput` → `FormRichTextFieldInput`,
`isFieldRichTextV2` → `isFieldRichText`)
- Updates generated files (GraphQL schema, SDK types) to use the new key
while preserving the `RICH_TEXT_V2` string value for DB/API layer
- Updates i18n locale files, test snapshots, and integration tests to
reflect the rename

## Context

The legacy `RICH_TEXT` (V1) field type was deprecated and migrated to
`TEXT` in a previous PR (#18623). With V1 gone, the `RICH_TEXT_V2`
naming is no longer necessary — `RICH_TEXT` is now the canonical name.
The DB enum value stays `'RICH_TEXT_V2'` to avoid confusion with the
just-deprecated V1 type and to prevent a database migration.

## Test plan

- [x] `twenty-server` typecheck passes
- [x] `twenty-front` typecheck passes (only pre-existing Apollo client
errors remain)
- [x] `twenty-server` lint passes
- [x] `twenty-front` lint passes
- [x] `twenty-shared` build passes
- [ ] CI passes


Made with [Cursor](https://cursor.com)
2026-03-13 19:07:55 +01:00

115 lines
4.3 KiB
TypeScript

import { failingCreateInputByFieldMetadataType } from 'test/integration/graphql/suites/inputs-validation/create-validation/constants/failing-create-input-by-field-metadata-type.constant';
import { successfulCreateInputByFieldMetadataType } from 'test/integration/graphql/suites/inputs-validation/create-validation/constants/successful-create-input-by-field-metadata-type.constant';
import { expectGqlCreateInputValidationError } from 'test/integration/graphql/suites/inputs-validation/create-validation/utils/expect-gql-create-input-validation-error.util';
import { expectGqlCreateInputValidationSuccess } from 'test/integration/graphql/suites/inputs-validation/create-validation/utils/expect-gql-create-input-validation-success.util';
import { expectRestCreateInputValidationError } from 'test/integration/graphql/suites/inputs-validation/create-validation/utils/expect-rest-create-input-validation-error.util';
import { expectRestCreateInputValidationSuccess } from 'test/integration/graphql/suites/inputs-validation/create-validation/utils/expect-rest-create-input-validation-success.util';
import { destroyManyObjectsMetadata } from 'test/integration/graphql/suites/inputs-validation/utils/destroy-many-objects-metadata';
import { setupTestObjectsWithAllFieldTypes } from 'test/integration/graphql/suites/inputs-validation/utils/setup-test-objects-with-all-field-types.util';
import { FieldMetadataType } from 'twenty-shared/types';
const FIELD_METADATA_TYPE = FieldMetadataType.RICH_TEXT;
const successfulTestCases =
successfulCreateInputByFieldMetadataType[FIELD_METADATA_TYPE];
const failingTestCases =
failingCreateInputByFieldMetadataType[FIELD_METADATA_TYPE];
describe(`Create input validation - ${FIELD_METADATA_TYPE}`, () => {
let objectMetadataId: string;
let objectMetadataSingularName: string;
let objectMetadataPluralName: string;
let targetObjectMetadata1Id: string;
let targetObjectMetadata2Id: string;
beforeAll(async () => {
const setupTest = await setupTestObjectsWithAllFieldTypes();
objectMetadataId = setupTest.objectMetadataId;
objectMetadataSingularName = setupTest.objectMetadataSingularName;
objectMetadataPluralName = setupTest.objectMetadataPluralName;
targetObjectMetadata1Id = setupTest.targetObjectMetadata1Id;
targetObjectMetadata2Id = setupTest.targetObjectMetadata2Id;
});
afterAll(async () => {
await destroyManyObjectsMetadata([
objectMetadataId,
targetObjectMetadata1Id,
targetObjectMetadata2Id,
]);
});
describe('Gql create input - success', () => {
it.each(
successfulTestCases.map((testCase) => ({
...testCase,
stringifiedInput: JSON.stringify(testCase.input),
})),
)(
`${FIELD_METADATA_TYPE} - should succeed with : $stringifiedInput`,
async ({ input, validateInput }) => {
await expectGqlCreateInputValidationSuccess(
objectMetadataSingularName,
input,
validateInput,
);
},
);
});
describe('Rest create input - success', () => {
it.each(
successfulTestCases.map((testCase) => ({
...testCase,
stringifiedInput: JSON.stringify(testCase.input),
})),
)(
`${FIELD_METADATA_TYPE} - should succeed with : $stringifiedInput`,
async ({ input, validateInput }) => {
await expectRestCreateInputValidationSuccess(
objectMetadataPluralName,
objectMetadataSingularName,
input,
validateInput,
);
},
);
});
describe('Gql create input - failure', () => {
it.each(
failingTestCases.map((testCase) => ({
...testCase,
stringifiedInput: JSON.stringify(testCase.input),
})),
)(
`${FIELD_METADATA_TYPE} - should fail with : $stringifiedInput`,
async ({ input }) => {
await expectGqlCreateInputValidationError(
objectMetadataSingularName,
input,
);
},
);
});
describe('Rest create input - failure', () => {
it.each(
failingTestCases.map((testCase) => ({
...testCase,
stringifiedInput: JSON.stringify(testCase.input),
})),
)(
`${FIELD_METADATA_TYPE} - should fail with : $stringifiedInput`,
async ({ input }) => {
await expectRestCreateInputValidationError(
objectMetadataPluralName,
input,
);
},
);
});
});