From 286682c1974529aaefc35b7f834bfa6a662f5a01 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Fri, 5 Sep 2025 18:49:20 +0200 Subject: [PATCH] DevXP improvements on new views (#14330) --- .../views/utils/getRecordFilterLabelValue.ts | 3 +- ...ta-related-record.integration-spec.ts.snap | 244 ++++++++++++------ ...etadata-related-record.integration-spec.ts | 9 +- 3 files changed, 168 insertions(+), 88 deletions(-) diff --git a/packages/twenty-front/src/modules/views/utils/getRecordFilterLabelValue.ts b/packages/twenty-front/src/modules/views/utils/getRecordFilterLabelValue.ts index 55894e1d04..f524700ad5 100644 --- a/packages/twenty-front/src/modules/views/utils/getRecordFilterLabelValue.ts +++ b/packages/twenty-front/src/modules/views/utils/getRecordFilterLabelValue.ts @@ -4,6 +4,7 @@ import { type RecordFilter } from '@/object-record/record-filter/types/RecordFil import { RecordFilterOperand } from '@/object-record/record-filter/types/RecordFilterOperand'; import { isEmptinessOperand } from '@/object-record/record-filter/utils/isEmptinessOperand'; import { isRecordFilterConsideredEmpty } from '@/object-record/record-filter/utils/isRecordFilterConsideredEmpty'; +import { parseJson } from 'twenty-shared/utils'; export const getRecordFilterLabelValue = ({ recordFilter, @@ -30,7 +31,7 @@ export const getRecordFilterLabelValue = ({ } } if (recordFilter.type === 'SELECT' || recordFilter.type === 'MULTI_SELECT') { - const valueArray = JSON.parse(recordFilter.value); + const valueArray = parseJson(recordFilter.value); if (!Array.isArray(valueArray)) { return ''; diff --git a/packages/twenty-server/test/integration/metadata/suites/field-metadata/__snapshots__/update-one-field-metadata-related-record.integration-spec.ts.snap b/packages/twenty-server/test/integration/metadata/suites/field-metadata/__snapshots__/update-one-field-metadata-related-record.integration-spec.ts.snap index 11d46e533d..68c702d4a9 100644 --- a/packages/twenty-server/test/integration/metadata/suites/field-metadata/__snapshots__/update-one-field-metadata-related-record.integration-spec.ts.snap +++ b/packages/twenty-server/test/integration/metadata/suites/field-metadata/__snapshots__/update-one-field-metadata-related-record.integration-spec.ts.snap @@ -1,43 +1,67 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`update-one-field-metadata-related-record MULTI_SELECT should handle adding new options while maintaining existing view filter 1`] = ` -[ - "OPTION_0", - "OPTION_1", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_0", + "OPTION_1", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record MULTI_SELECT should handle no changes update of options while maintaining existing view filter values 1`] = ` -[ - "OPTION_0", - "OPTION_1", - "OPTION_2", - "OPTION_3", - "OPTION_4", - "OPTION_5", - "OPTION_6", - "OPTION_7", - "OPTION_8", - "OPTION_9", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_0", + "OPTION_1", + "OPTION_2", + "OPTION_3", + "OPTION_4", + "OPTION_5", + "OPTION_6", + "OPTION_7", + "OPTION_8", + "OPTION_9", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record MULTI_SELECT should handle partial deletion of selected options in view filter 1`] = ` -[ - "OPTION_4", - "OPTION_5", - "OPTION_6", - "OPTION_7", - "OPTION_8", - "OPTION_9", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_4", + "OPTION_5", + "OPTION_6", + "OPTION_7", + "OPTION_8", + "OPTION_9", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record MULTI_SELECT should handle reordering of options while maintaining view filter values 1`] = ` -[ - "OPTION_0", - "OPTION_1", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_0", + "OPTION_1", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record MULTI_SELECT should throw error if view filter value is not a stringified JSON array 1`] = ` @@ -54,64 +78,100 @@ exports[`update-one-field-metadata-related-record MULTI_SELECT should throw erro `; exports[`update-one-field-metadata-related-record MULTI_SELECT should update related multi selected options view filter 1`] = ` -[ - "OPTION_0_UPDATED", - "OPTION_1", - "OPTION_2_UPDATED", - "OPTION_3", - "OPTION_4_UPDATED", - "OPTION_5", - "OPTION_6_UPDATED", - "OPTION_7", - "OPTION_8_UPDATED", - "OPTION_9", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_0_UPDATED", + "OPTION_1", + "OPTION_2_UPDATED", + "OPTION_3", + "OPTION_4_UPDATED", + "OPTION_5", + "OPTION_6_UPDATED", + "OPTION_7", + "OPTION_8_UPDATED", + "OPTION_9", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record MULTI_SELECT should update related solo selected option view filter 1`] = ` -[ - "OPTION_5_UPDATED", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_5_UPDATED", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record SELECT should handle adding new options while maintaining existing view filter 1`] = ` -[ - "OPTION_0", - "OPTION_1", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_0", + "OPTION_1", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record SELECT should handle no changes update of options while maintaining existing view filter values 1`] = ` -[ - "OPTION_0", - "OPTION_1", - "OPTION_2", - "OPTION_3", - "OPTION_4", - "OPTION_5", - "OPTION_6", - "OPTION_7", - "OPTION_8", - "OPTION_9", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_0", + "OPTION_1", + "OPTION_2", + "OPTION_3", + "OPTION_4", + "OPTION_5", + "OPTION_6", + "OPTION_7", + "OPTION_8", + "OPTION_9", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record SELECT should handle partial deletion of selected options in view filter 1`] = ` -[ - "OPTION_4", - "OPTION_5", - "OPTION_6", - "OPTION_7", - "OPTION_8", - "OPTION_9", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_4", + "OPTION_5", + "OPTION_6", + "OPTION_7", + "OPTION_8", + "OPTION_9", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record SELECT should handle reordering of options while maintaining view filter values 1`] = ` -[ - "OPTION_0", - "OPTION_1", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_0", + "OPTION_1", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record SELECT should throw error if view filter value is not a stringified JSON array 1`] = ` @@ -128,22 +188,34 @@ exports[`update-one-field-metadata-related-record SELECT should throw error if v `; exports[`update-one-field-metadata-related-record SELECT should update related multi selected options view filter 1`] = ` -[ - "OPTION_0_UPDATED", - "OPTION_1", - "OPTION_2_UPDATED", - "OPTION_3", - "OPTION_4_UPDATED", - "OPTION_5", - "OPTION_6_UPDATED", - "OPTION_7", - "OPTION_8_UPDATED", - "OPTION_9", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_0_UPDATED", + "OPTION_1", + "OPTION_2_UPDATED", + "OPTION_3", + "OPTION_4_UPDATED", + "OPTION_5", + "OPTION_6_UPDATED", + "OPTION_7", + "OPTION_8_UPDATED", + "OPTION_9", + ], + "viewFilterGroupId": null, +} `; exports[`update-one-field-metadata-related-record SELECT should update related solo selected option view filter 1`] = ` -[ - "OPTION_5_UPDATED", -] +{ + "operand": "IS", + "positionInViewFilterGroup": null, + "subFieldName": null, + "value": [ + "OPTION_5_UPDATED", + ], + "viewFilterGroupId": null, +} `; diff --git a/packages/twenty-server/test/integration/metadata/suites/field-metadata/update-one-field-metadata-related-record.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/field-metadata/update-one-field-metadata-related-record.integration-spec.ts index bd6da339b9..9a95492481 100644 --- a/packages/twenty-server/test/integration/metadata/suites/field-metadata/update-one-field-metadata-related-record.integration-spec.ts +++ b/packages/twenty-server/test/integration/metadata/suites/field-metadata/update-one-field-metadata-related-record.integration-spec.ts @@ -261,7 +261,14 @@ describe('update-one-field-metadata-related-record', () => { expect.arrayContaining(updatedViewFilter.value as string[]), ); - expect(updatedViewFilter.value).toMatchSnapshot(); + expect({ + value: updatedViewFilter.value, + operand: updatedViewFilter.operand, + viewFilterGroupId: updatedViewFilter.viewFilterGroupId, + positionInViewFilterGroup: + updatedViewFilter.positionInViewFilterGroup, + subFieldName: updatedViewFilter.subFieldName, + }).toMatchSnapshot(); }, );