Fix storybook / chromatic tests flakyness and integration tests (#11687)

## Storybook flakyness

### Actor Display image flakyness

<img width="1512" alt="image"
src="https://github.com/user-attachments/assets/875c0738-5e31-4aba-9231-4ba5f78d1355"
/>

**Fix:** stop using a random usage

### Task Groups broken

<img width="1512" alt="image"
src="https://github.com/user-attachments/assets/c67e47a1-a027-43f1-9601-68d61a8052b4"
/>

**Fix:** add missing TabListComponentInstance

## Flaky dates

Add https://github.com/k35o/storybook-addon-mock-date

## Integration tests

Fix broken tests due to relation refactoring
This commit is contained in:
Charles Bochet
2025-04-23 01:57:36 +02:00
committed by GitHub
parent 8694840b92
commit fa5f758228
20 changed files with 153 additions and 155 deletions

View File

@ -310,17 +310,17 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
const updatedObject = await super.updateOne(inputId, inputPayload);
const isNewRelationEnabled = await this.featureFlagService.isFeatureEnabled(
FeatureFlagKey.IsNewRelationEnabled,
workspaceId,
);
await this.handleObjectNameAndLabelUpdates(
existingObjectMetadata,
existingObjectMetadataCombinedWithUpdateInput,
inputPayload,
);
const isNewRelationEnabled = await this.featureFlagService.isFeatureEnabled(
FeatureFlagKey.IsNewRelationEnabled,
workspaceId,
);
if (inputPayload.isActive !== undefined) {
// For new relation system, the active status is stitched to the field metadata
if (!isNewRelationEnabled) {

View File

@ -6,6 +6,7 @@ import { capitalize } from 'twenty-shared/utils';
import { Repository } from 'typeorm';
import { v4 as uuidV4 } from 'uuid';
import { FieldMetadataDefaultSettings } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-settings.interface';
import { RelationType } from 'src/engine/metadata-modules/field-metadata/interfaces/relation-type.interface';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
@ -165,15 +166,30 @@ export class ObjectMetadataFieldRelationService {
objectMetadataId: targetObjectMetadata.id,
workspaceId: workspaceId,
});
const isTargetFieldMetadataManyToOneRelation =
(
targetFieldMetadataToUpdate as FieldMetadataEntity<FieldMetadataType.RELATION>
).settings?.relationType === RelationType.MANY_TO_ONE;
const targetFieldMetadata = await this.fieldMetadataRepository.save({
id: targetFieldMetadataToUpdate.id,
...targetFieldMetadataUpdateData,
settings: {
...(targetFieldMetadataToUpdate.settings as FieldMetadataDefaultSettings),
...(isTargetFieldMetadataManyToOneRelation
? {
joinColumnName: `${sourceObjectMetadata.nameSingular}Id`,
}
: {}),
},
});
const sourceFieldMetadataUpdateData = this.updateSourceFieldMetadata(
sourceObjectMetadata,
targetObjectMetadata,
);
const sourceFieldMetadataToUpdate =
await this.fieldMetadataRepository.findOneByOrFail({
standardId:
@ -181,9 +197,23 @@ export class ObjectMetadataFieldRelationService {
objectMetadataId: sourceObjectMetadata.id,
workspaceId: workspaceId,
});
const isSourceFieldMetadataManyToOneRelation =
(
sourceFieldMetadataToUpdate as FieldMetadataEntity<FieldMetadataType.RELATION>
).settings?.relationType === RelationType.MANY_TO_ONE;
const sourceFieldMetadata = await this.fieldMetadataRepository.save({
id: sourceFieldMetadataToUpdate.id,
...sourceFieldMetadataUpdateData,
settings: {
...(sourceFieldMetadataToUpdate.settings as FieldMetadataDefaultSettings),
...(isSourceFieldMetadataManyToOneRelation
? {
joinColumnName: `${targetObjectMetadata.nameSingular}Id`,
}
: {}),
},
});
return {

View File

@ -276,7 +276,7 @@ export class ObjectMetadataMigrationService {
relationToDelete.toFieldMetadataId,
]);
if (relationToDelete.direction === 'from') {
if (relationToDelete.direction === 'from' && !isNewRelationEnabled) {
await this.workspaceMigrationService.createCustomMigration(
generateMigrationName(
`delete-${RELATION_MIGRATION_PRIORITY_PREFIX}-${relationToDelete.fromObjectName}-${relationToDelete.toObjectName}`,