09de762285
## FILES Field update interface
```
mutation {
updateCompany(
id: "company-uuid"
data: {
filesfield: [
{ fileId: "new-file-uuid", label: "new-document.pdf" }
]
}
) {
id
filesfield {
fileId
label
extension
}
}
}
```
93 lines
3.5 KiB
TypeScript
93 lines
3.5 KiB
TypeScript
import { failingCreateInputByFieldMetadataType } from 'test/integration/graphql/suites/inputs-validation/create-validation/constants/failing-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 { expectRestCreateInputValidationError } from 'test/integration/graphql/suites/inputs-validation/create-validation/utils/expect-rest-create-input-validation-error.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 { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
|
import { updateFeatureFlagFactory } from 'test/integration/graphql/utils/update-feature-flag-factory.util';
|
|
import { FieldMetadataType } from 'twenty-shared/types';
|
|
|
|
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
|
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
|
|
|
|
const FIELD_METADATA_TYPE = FieldMetadataType.FILES;
|
|
|
|
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 () => {
|
|
await makeGraphqlAPIRequest(
|
|
updateFeatureFlagFactory(
|
|
SEED_APPLE_WORKSPACE_ID,
|
|
FeatureFlagKey.IS_FILES_FIELD_ENABLED,
|
|
true,
|
|
),
|
|
);
|
|
|
|
const setupTest = await setupTestObjectsWithAllFieldTypes(true);
|
|
|
|
objectMetadataId = setupTest.objectMetadataId;
|
|
objectMetadataSingularName = setupTest.objectMetadataSingularName;
|
|
objectMetadataPluralName = setupTest.objectMetadataPluralName;
|
|
targetObjectMetadata1Id = setupTest.targetObjectMetadata1Id;
|
|
targetObjectMetadata2Id = setupTest.targetObjectMetadata2Id;
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await destroyManyObjectsMetadata([
|
|
objectMetadataId,
|
|
targetObjectMetadata1Id,
|
|
targetObjectMetadata2Id,
|
|
]);
|
|
|
|
await makeGraphqlAPIRequest(
|
|
updateFeatureFlagFactory(
|
|
SEED_APPLE_WORKSPACE_ID,
|
|
FeatureFlagKey.IS_FILES_FIELD_ENABLED,
|
|
false,
|
|
),
|
|
);
|
|
});
|
|
|
|
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,
|
|
);
|
|
},
|
|
);
|
|
});
|
|
});
|