fix: fix Select field preview (#4507)
* fix: fix Select field preview Closes #4084 * fix: fix field preview utils tests
This commit is contained in:
@ -37,7 +37,7 @@ describe('getFieldDefaultPreviewValue', () => {
|
||||
});
|
||||
|
||||
// Then
|
||||
expect(result).toEqual(selectOptions[1]);
|
||||
expect(result).toEqual(selectOptions[1].value);
|
||||
});
|
||||
|
||||
it('returns the first select option if no default option was found', () => {
|
||||
@ -46,7 +46,7 @@ describe('getFieldDefaultPreviewValue', () => {
|
||||
const fieldMetadataItem = mockedCompanyObjectMetadataItem.fields.find(
|
||||
({ name }) => name === 'industry',
|
||||
)!;
|
||||
const selectOptions = [
|
||||
const selectOptions: SettingsObjectFieldSelectFormValues = [
|
||||
{
|
||||
color: 'purple' as const,
|
||||
label: '🏭 Industry',
|
||||
@ -67,7 +67,7 @@ describe('getFieldDefaultPreviewValue', () => {
|
||||
});
|
||||
|
||||
// Then
|
||||
expect(result).toEqual(selectOptions[0]);
|
||||
expect(result).toEqual(selectOptions[0].value);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ describe('getFieldPreviewValueFromRecord', () => {
|
||||
});
|
||||
|
||||
// Then
|
||||
expect(result).toEqual(selectOptions[2]);
|
||||
expect(result).toEqual(selectOptions[2].value);
|
||||
});
|
||||
|
||||
it('returns undefined if the select option was not found', () => {
|
||||
|
||||
@ -26,7 +26,9 @@ export const getFieldDefaultPreviewValue = ({
|
||||
fieldMetadataItem.type === FieldMetadataType.Select &&
|
||||
isDefined(selectOptions)
|
||||
) {
|
||||
return selectOptions.find(({ isDefault }) => isDefault) || selectOptions[0];
|
||||
const defaultSelectOption =
|
||||
selectOptions.find(({ isDefault }) => isDefault) || selectOptions[0];
|
||||
return defaultSelectOption.value;
|
||||
}
|
||||
|
||||
// Relation field
|
||||
|
||||
@ -18,7 +18,7 @@ export const getFieldPreviewValueFromRecord = ({
|
||||
if (fieldMetadataItem.type === FieldMetadataType.Select) {
|
||||
return selectOptions?.find(
|
||||
(selectOption) => selectOption.value === recordFieldValue,
|
||||
);
|
||||
)?.value;
|
||||
}
|
||||
|
||||
// Relation fields (to many)
|
||||
|
||||
Reference in New Issue
Block a user