4fbdfb6abc
## Introduction After enabling flag by default got following errors: ```ts Test Suites: 48 failed, 1 skipped, 97 passed, 145 of 146 total Tests: 499 failed, 1 skipped, 644 passed, 1144 total Snapshots: 61 failed, 133 passed, 194 total Time: 363.226 s Ran all test suites. ``` ## From <img width="2952" height="1510" alt="image" src="https://github.com/user-attachments/assets/7e3b20c6-2552-40a7-90bb-2d7b3002c895" /> ## To <img width="3134" height="1510" alt="image" src="https://github.com/user-attachments/assets/4fc9ada4-3c14-4333-a1db-11daf87db8d6" /> There's a huge test bundle in the latest shard that we could split up ## Notes - Set as failing morph relation field rename as for the moment we do not handle relation field mutation - fixed the object update and creation validation adding label identifier field metadata id checks - and more Some integrations tests are still on the v1 ( they have before and after all disabling and re-enabling the flat ) but mainly we now have more coverage on the v2 than the v1. Mainly related records, uniqueness have to be migrated the v2 and so tests too
127 lines
3.7 KiB
TypeScript
127 lines
3.7 KiB
TypeScript
import { createOneFieldMetadata } from 'test/integration/metadata/suites/field-metadata/utils/create-one-field-metadata.util';
|
|
import { deleteOneObjectMetadata } from 'test/integration/metadata/suites/object-metadata/utils/delete-one-object-metadata.util';
|
|
import { updateOneObjectMetadata } from 'test/integration/metadata/suites/object-metadata/utils/update-one-object-metadata.util';
|
|
import {
|
|
eachTestingContextFilter,
|
|
type EachTestingContext,
|
|
} from 'twenty-shared/testing';
|
|
import { FieldMetadataType } from 'twenty-shared/types';
|
|
import { createOneObjectMetadata } from 'test/integration/metadata/suites/object-metadata/utils/create-one-object-metadata.util';
|
|
import { extractRecordIdsAndDatesAsExpectAny } from 'test/utils/extract-record-ids-and-dates-as-expect-any';
|
|
|
|
import { type UpdateObjectPayload } from 'src/engine/metadata-modules/object-metadata/dtos/update-object.input';
|
|
|
|
type TestingRuntimeContext = {
|
|
objectMetadataId: string;
|
|
numberFieldMetadataId: string;
|
|
};
|
|
|
|
type CreateOneObjectMetadataItemTestingContext = EachTestingContext<
|
|
| ((args: TestingRuntimeContext) => Partial<UpdateObjectPayload>)
|
|
| Partial<UpdateObjectPayload>
|
|
>[];
|
|
|
|
const labelIdentifierFailingTestsUseCase: CreateOneObjectMetadataItemTestingContext =
|
|
[
|
|
{
|
|
title: 'when labelIdentifier is not a uuid',
|
|
context: {
|
|
labelIdentifierFieldMetadataId: 'not-a-uuid',
|
|
},
|
|
},
|
|
{
|
|
title: 'when labelIdentifier is not a known field metadata id',
|
|
context: {
|
|
labelIdentifierFieldMetadataId: '42422020-f49c-4159-8751-76a24f47b360',
|
|
},
|
|
},
|
|
{
|
|
title: 'when labelIdentifier is null',
|
|
context: {
|
|
labelIdentifierFieldMetadataId: null as any,
|
|
},
|
|
},
|
|
{
|
|
title: 'when labelIdentifier is not a TEXT or NAME field',
|
|
context: ({ numberFieldMetadataId }) => ({
|
|
labelIdentifierFieldMetadataId: numberFieldMetadataId,
|
|
}),
|
|
},
|
|
];
|
|
|
|
const allTestsUseCases = [...labelIdentifierFailingTestsUseCase];
|
|
|
|
describe('Object metadata update should fail', () => {
|
|
let objectMetadataId: string;
|
|
let numberFieldMetadataId: string;
|
|
|
|
beforeAll(async () => {
|
|
const { data } = await createOneObjectMetadata({
|
|
expectToFail: false,
|
|
input: {
|
|
labelPlural: 'whatevers',
|
|
labelSingular: 'whatever',
|
|
namePlural: 'whatevers',
|
|
nameSingular: 'whatever',
|
|
},
|
|
});
|
|
|
|
objectMetadataId = data.createOneObject.id;
|
|
|
|
const {
|
|
data: { createOneField },
|
|
} = await createOneFieldMetadata({
|
|
expectToFail: false,
|
|
input: {
|
|
objectMetadataId: objectMetadataId,
|
|
name: 'testName',
|
|
label: 'Test name',
|
|
isLabelSyncedWithName: true,
|
|
type: FieldMetadataType.NUMBER,
|
|
},
|
|
});
|
|
|
|
numberFieldMetadataId = createOneField.id;
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await updateOneObjectMetadata({
|
|
expectToFail: false,
|
|
input: {
|
|
idToUpdate: objectMetadataId,
|
|
updatePayload: {
|
|
isActive: false,
|
|
},
|
|
},
|
|
});
|
|
await deleteOneObjectMetadata({
|
|
input: {
|
|
idToDelete: objectMetadataId,
|
|
},
|
|
});
|
|
});
|
|
|
|
it.each(eachTestingContextFilter(allTestsUseCases))(
|
|
'$title',
|
|
async ({ context }) => {
|
|
const updatePayload =
|
|
typeof context === 'function'
|
|
? context({ numberFieldMetadataId, objectMetadataId })
|
|
: context;
|
|
|
|
const { errors } = await updateOneObjectMetadata({
|
|
input: {
|
|
idToUpdate: objectMetadataId,
|
|
updatePayload,
|
|
},
|
|
expectToFail: true,
|
|
});
|
|
|
|
expect(errors).toBeDefined();
|
|
expect(errors).toMatchSnapshot(
|
|
extractRecordIdsAndDatesAsExpectAny(errors),
|
|
);
|
|
},
|
|
);
|
|
});
|