Field metadata relation edge cases exceptions coverage (#12866)
# Introduction Following https://github.com/twentyhq/twenty/pull/12852 Discovered that: - `relationCreationPayload` does not seem to be validated through the input decorators ```ts // TODO @prastoin implement validation for this with validate nested and dedicated class instance @IsOptional() @Field(() => GraphQLJSON, { nullable: true }) relationCreationPayload?: { targetObjectMetadataId: string; targetFieldLabel: string; targetFieldIcon: string; type: RelationType; }; ``` - Sending an unknown `targetObjectMetadataId` generates an `internal_server_error` `500` @guillim on the go ## Coverage ```ts PASS test/integration/metadata/suites/object-metadata/failing-field-metadata-relation-creation.integration-spec.ts Field metadata relation creation should fail ✓ relation when targetFieldLabel is empty (109 ms) ✓ relation when targetFieldLabel exceeds maximum length (100 ms) ✓ relation when targetObjectMetadataId is unknown (97 ms) ✓ relation when targetFieldLabel contains only whitespace (103 ms) ✓ relation when targetFieldLabel conflicts with an existing field on target object metadata id (108 ms) Test Suites: 1 passed, 1 total Tests: 5 passed, 5 total Snapshots: 5 passed, 5 total Time: 2.629 s, estimated 3 s ```
This commit is contained in:
@ -22,6 +22,7 @@ export class CreateFieldInput extends OmitType(
|
||||
@IsOptional()
|
||||
isRemoteCreation?: boolean;
|
||||
|
||||
// TODO @prastoin implement validation for this with validate nested and dedicated class instance
|
||||
@IsOptional()
|
||||
@Field(() => GraphQLJSON, { nullable: true })
|
||||
relationCreationPayload?: {
|
||||
|
||||
Reference in New Issue
Block a user