Workspace migration v2 testing (#13136)
# Introduction Introduced `EachTesting` pattern for the builder unit tests. As always any suggestions are more than welcomed ! Still need to: - [x] implem basic tests for field - [x] create `get-flat-index-field-metadata.mock.ts` - [x] Implement basic tests for index and index-fields - [ ] Implem standard edges cases tests TDD style ## Misc - was https://github.com/twentyhq/twenty/pull/13132 closed due to mess to rebase on main
This commit is contained in:
+16
@@ -2,6 +2,7 @@ import diff from 'microdiff';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { isRelationFieldMetadataType } from 'src/engine/utils/is-relation-field-metadata-type.util';
|
||||
import { FlatFieldMetadata } from 'src/engine/workspace-manager/workspace-migration-v2/types/flat-field-metadata';
|
||||
import { FromTo } from 'src/engine/workspace-manager/workspace-migration-v2/types/from-to.type';
|
||||
import { UpdateFieldAction } from 'src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/types/workspace-migration-field-action-v2';
|
||||
@@ -18,6 +19,11 @@ const flatFieldMetadataPropertiesToCompare = [
|
||||
'name',
|
||||
'options',
|
||||
'standardOverrides',
|
||||
'settings',
|
||||
// To reactivate once we authorize relation edition, see https://github.com/twentyhq/twenty/commit/39f6f3c4bb101272a9014e142a842d0801a3c33b
|
||||
// 'relationTargetFieldMetadataId',
|
||||
// 'relationTargetObjectMetadataId',
|
||||
///
|
||||
] as const satisfies (keyof FlatFieldMetadata)[];
|
||||
|
||||
export type FlatFieldMetadataPropertiesToCompare =
|
||||
@@ -26,6 +32,7 @@ export type FlatFieldMetadataPropertiesToCompare =
|
||||
const fieldMetadataPropertiesToStringify = [
|
||||
'defaultValue',
|
||||
'standardOverrides',
|
||||
'settings',
|
||||
] as const satisfies FlatFieldMetadataPropertiesToCompare[];
|
||||
|
||||
const shouldNotOverrideDefaultValue = (type: FieldMetadataType) => {
|
||||
@@ -65,6 +72,15 @@ export const compareTwoFlatFieldMetadata = ({
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove below assertion when we authorize relation edition, see https://github.com/twentyhq/twenty/commit/39f6f3c4bb101272a9014e142a842d0801a3c33b
|
||||
if (
|
||||
isDefined(fieldMetadata.type) &&
|
||||
isRelationFieldMetadataType(fieldMetadata.type) &&
|
||||
!['label', 'description', 'isActive'].includes(property)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
propertiesToStringify: fieldMetadataPropertiesToStringify,
|
||||
|
||||
Reference in New Issue
Block a user