Skip to content

Commit 580ce31

Browse files
authored
Common api - Add field create input validation integration testing (#15026)
closes twentyhq/core-team-issues#1624
1 parent 23d8bbb commit 580ce31

File tree

67 files changed

+3239
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3239
-225
lines changed

packages/twenty-server/test/integration/graphql/suites/args-validation/types/field-metadata-type-to-test.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/twenty-server/test/integration/graphql/suites/args-validation/filter-validation/constants/test-object-gql-fields.constant.ts renamed to packages/twenty-server/test/integration/graphql/suites/inputs-validation/constants/test-object-gql-fields.constant.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ export const TEST_OBJECT_GQL_FIELDS = `
4646
}
4747
rawJsonField
4848
arrayField
49+
richTextField
50+
richTextV2Field {
51+
blocknote
52+
markdown
53+
}
4954
`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Create input validation - ARRAY Gql create input - failure ARRAY - should fail with : {"arrayField":1} 1`] = `"String cannot represent a non string value: 1"`;
4+
5+
exports[`Create input validation - ARRAY Gql create input - failure ARRAY - should fail with : {"arrayField":true} 1`] = `"String cannot represent a non string value: true"`;
6+
7+
exports[`Create input validation - ARRAY Rest create input - failure ARRAY - should fail with : {"arrayField":1} 1`] = `"["malformed array literal: \\"1\\""]"`;
8+
9+
exports[`Create input validation - ARRAY Rest create input - failure ARRAY - should fail with : {"arrayField":true} 1`] = `"["malformed array literal: \\"true\\""]"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Create input validation - DATE Gql create input - failure DATE - should fail with : {"dateField":"malformed-date"} 1`] = `"invalid input syntax for type date: "malformed-date""`;
4+
5+
exports[`Create input validation - DATE Gql create input - failure DATE - should fail with : {"dateField":[]} 1`] = `"invalid input syntax for type date: "{}""`;
6+
7+
exports[`Create input validation - DATE Gql create input - failure DATE - should fail with : {"dateField":{}} 1`] = `"invalid input syntax for type date: "{}""`;
8+
9+
exports[`Create input validation - DATE Gql create input - failure DATE - should fail with : {"dateField":1} 1`] = `"invalid input syntax for type date: "1""`;
10+
11+
exports[`Create input validation - DATE Gql create input - failure DATE - should fail with : {"dateField":true} 1`] = `"invalid input syntax for type date: "true""`;
12+
13+
exports[`Create input validation - DATE Rest create input - failure DATE - should fail with : {"dateField":"malformed-date"} 1`] = `"["invalid input syntax for type date: \\"malformed-date\\""]"`;
14+
15+
exports[`Create input validation - DATE Rest create input - failure DATE - should fail with : {"dateField":[]} 1`] = `"["invalid input syntax for type date: \\"{}\\""]"`;
16+
17+
exports[`Create input validation - DATE Rest create input - failure DATE - should fail with : {"dateField":{}} 1`] = `"["invalid input syntax for type date: \\"{}\\""]"`;
18+
19+
exports[`Create input validation - DATE Rest create input - failure DATE - should fail with : {"dateField":1} 1`] = `"["invalid input syntax for type date: \\"1\\""]"`;
20+
21+
exports[`Create input validation - DATE Rest create input - failure DATE - should fail with : {"dateField":true} 1`] = `"["invalid input syntax for type date: \\"true\\""]"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Create input validation - DATE_TIME Gql create input - failure DATE_TIME - should fail with : {"dateTimeField":"malformed-date"} 1`] = `"invalid input syntax for type timestamp with time zone: "malformed-date""`;
4+
5+
exports[`Create input validation - DATE_TIME Gql create input - failure DATE_TIME - should fail with : {"dateTimeField":[]} 1`] = `"invalid input syntax for type timestamp with time zone: "{}""`;
6+
7+
exports[`Create input validation - DATE_TIME Gql create input - failure DATE_TIME - should fail with : {"dateTimeField":{}} 1`] = `"invalid input syntax for type timestamp with time zone: "{}""`;
8+
9+
exports[`Create input validation - DATE_TIME Gql create input - failure DATE_TIME - should fail with : {"dateTimeField":1} 1`] = `"invalid input syntax for type timestamp with time zone: "1""`;
10+
11+
exports[`Create input validation - DATE_TIME Gql create input - failure DATE_TIME - should fail with : {"dateTimeField":true} 1`] = `"invalid input syntax for type timestamp with time zone: "true""`;
12+
13+
exports[`Create input validation - DATE_TIME Rest create input - failure DATE_TIME - should fail with : {"dateTimeField":"malformed-date"} 1`] = `"["invalid input syntax for type timestamp with time zone: \\"malformed-date\\""]"`;
14+
15+
exports[`Create input validation - DATE_TIME Rest create input - failure DATE_TIME - should fail with : {"dateTimeField":[]} 1`] = `"["invalid input syntax for type timestamp with time zone: \\"{}\\""]"`;
16+
17+
exports[`Create input validation - DATE_TIME Rest create input - failure DATE_TIME - should fail with : {"dateTimeField":{}} 1`] = `"["invalid input syntax for type timestamp with time zone: \\"{}\\""]"`;
18+
19+
exports[`Create input validation - DATE_TIME Rest create input - failure DATE_TIME - should fail with : {"dateTimeField":1} 1`] = `"["invalid input syntax for type timestamp with time zone: \\"1\\""]"`;
20+
21+
exports[`Create input validation - DATE_TIME Rest create input - failure DATE_TIME - should fail with : {"dateTimeField":true} 1`] = `"["invalid input syntax for type timestamp with time zone: \\"true\\""]"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Create input validation - MULTI_SELECT Gql create input - failure MULTI_SELECT - should fail with : {"multiSelectField":"not-a-select-option"} 1`] = `"Value "not-a-select-option" does not exist in "ApiInputValidationTestObjectMultiSelectFieldEnum" enum."`;
4+
5+
exports[`Create input validation - MULTI_SELECT Gql create input - failure MULTI_SELECT - should fail with : {"multiSelectField":1} 1`] = `"Enum "ApiInputValidationTestObjectMultiSelectFieldEnum" cannot represent non-string value: 1."`;
6+
7+
exports[`Create input validation - MULTI_SELECT Gql create input - failure MULTI_SELECT - should fail with : {"multiSelectField":true} 1`] = `"Enum "ApiInputValidationTestObjectMultiSelectFieldEnum" cannot represent non-string value: true."`;
8+
9+
exports[`Create input validation - MULTI_SELECT Rest create input - failure MULTI_SELECT - should fail with : {"multiSelectField":"not-a-select-option"} 1`] = `"["malformed array literal: \\"not-a-select-option\\""]"`;
10+
11+
exports[`Create input validation - MULTI_SELECT Rest create input - failure MULTI_SELECT - should fail with : {"multiSelectField":1} 1`] = `"["malformed array literal: \\"1\\""]"`;
12+
13+
exports[`Create input validation - MULTI_SELECT Rest create input - failure MULTI_SELECT - should fail with : {"multiSelectField":true} 1`] = `"["malformed array literal: \\"true\\""]"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Create input validation - RATING Gql create input - failure RATING - should fail with : {"ratingField":"not-a-rating"} 1`] = `"Value "not-a-rating" does not exist in "ApiInputValidationTestObjectRatingFieldEnum" enum."`;
4+
5+
exports[`Create input validation - RATING Gql create input - failure RATING - should fail with : {"ratingField":[]} 1`] = `"Enum "ApiInputValidationTestObjectRatingFieldEnum" cannot represent non-string value: []."`;
6+
7+
exports[`Create input validation - RATING Gql create input - failure RATING - should fail with : {"ratingField":{}} 1`] = `"Enum "ApiInputValidationTestObjectRatingFieldEnum" cannot represent non-string value: {}."`;
8+
9+
exports[`Create input validation - RATING Gql create input - failure RATING - should fail with : {"ratingField":1} 1`] = `"Enum "ApiInputValidationTestObjectRatingFieldEnum" cannot represent non-string value: 1."`;
10+
11+
exports[`Create input validation - RATING Gql create input - failure RATING - should fail with : {"ratingField":true} 1`] = `"Enum "ApiInputValidationTestObjectRatingFieldEnum" cannot represent non-string value: true."`;
12+
13+
exports[`Create input validation - RATING Rest create input - failure RATING - should fail with : {"ratingField":"not-a-rating"} 1`] = `"["invalid input value for enum workspace_1wgvd1injqtife6y4rvfbu3h5.\\"_apiInputValidationTestObject_ratingField_enum\\": \\"not-a-rating\\""]"`;
14+
15+
exports[`Create input validation - RATING Rest create input - failure RATING - should fail with : {"ratingField":[]} 1`] = `"["invalid input value for enum workspace_1wgvd1injqtife6y4rvfbu3h5.\\"_apiInputValidationTestObject_ratingField_enum\\": \\"\\""]"`;
16+
17+
exports[`Create input validation - RATING Rest create input - failure RATING - should fail with : {"ratingField":{}} 1`] = `"["invalid input value for enum workspace_1wgvd1injqtife6y4rvfbu3h5.\\"_apiInputValidationTestObject_ratingField_enum\\": \\"[object Object]\\""]"`;
18+
19+
exports[`Create input validation - RATING Rest create input - failure RATING - should fail with : {"ratingField":1} 1`] = `"["invalid input value for enum workspace_1wgvd1injqtife6y4rvfbu3h5.\\"_apiInputValidationTestObject_ratingField_enum\\": \\"1\\""]"`;
20+
21+
exports[`Create input validation - RATING Rest create input - failure RATING - should fail with : {"ratingField":true} 1`] = `"["invalid input value for enum workspace_1wgvd1injqtife6y4rvfbu3h5.\\"_apiInputValidationTestObject_ratingField_enum\\": \\"true\\""]"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Create input validation - RAW_JSON Gql create input - failure RAW_JSON - should fail with : {"rawJsonField":"not-a-json"} 1`] = `"Unexpected token 'o', "not-a-json" is not valid JSON"`;
4+
5+
exports[`Create input validation - RAW_JSON Rest create input - failure RAW_JSON - should fail with : {"rawJsonField":"not-a-json"} 1`] = `"["Unexpected token 'o', \\"not-a-json\\" is not valid JSON"]"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Create input validation - RELATION Gql create input - failure RELATION - should fail with : {"manyToOneRelationFieldId":"non-uuid"} 1`] = `"invalid input syntax for type uuid: "non-uuid""`;
4+
5+
exports[`Create input validation - RELATION Gql create input - failure RELATION - should fail with : {"manyToOneRelationFieldId":1} 1`] = `"invalid input syntax for type uuid: "1""`;
6+
7+
exports[`Create input validation - RELATION Gql create input - failure RELATION - should fail with : {"manyToOneRelationFieldId":true} 1`] = `"ID cannot represent value: true"`;
8+
9+
exports[`Create input validation - RELATION Gql create input - failure RELATION - should fail with : {"oneToManyRelationFieldId":"not-existing-field"} 1`] = `"Field "oneToManyRelationFieldId" is not defined by type "ApiInputValidationTestObjectCreateInput". Did you mean "manyToOneRelationFieldId" or "manyToOneRelationField"?"`;
10+
11+
exports[`Create input validation - RELATION Rest create input - failure RELATION - should fail with : {"manyToOneRelationFieldId":"non-uuid"} 1`] = `"["invalid input syntax for type uuid: \\"non-uuid\\""]"`;
12+
13+
exports[`Create input validation - RELATION Rest create input - failure RELATION - should fail with : {"manyToOneRelationFieldId":1} 1`] = `"["invalid input syntax for type uuid: \\"1\\""]"`;
14+
15+
exports[`Create input validation - RELATION Rest create input - failure RELATION - should fail with : {"manyToOneRelationFieldId":true} 1`] = `"["invalid input syntax for type uuid: \\"true\\""]"`;
16+
17+
exports[`Create input validation - RELATION Rest create input - failure RELATION - should fail with : {"oneToManyRelationFieldId":"not-existing-field"} 1`] = `"["Field metadata for field \\"oneToManyRelationFieldId\\" is missing in object metadata apiInputValidationTestObject"]"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Create input validation - RICH_TEXT Gql create input - failure RICH_TEXT - should fail with : {"richTextField":"test"} 1`] = `"Rich text is not supported, please use RICH_TEXT_V2 instead"`;
4+
5+
exports[`Create input validation - RICH_TEXT Rest create input - failure RICH_TEXT - should fail with : {"richTextField":"test"} 1`] = `"["Rich text is not supported, please use RICH_TEXT_V2 instead"]"`;

0 commit comments

Comments
 (0)