DevXP improvements on new views (#14330)
This commit is contained in:
@@ -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<string[]>(recordFilter.value);
|
||||
|
||||
if (!Array.isArray(valueArray)) {
|
||||
return '';
|
||||
|
||||
+158
-86
@@ -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,
|
||||
}
|
||||
`;
|
||||
|
||||
+8
-1
@@ -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();
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user