Skip to content

Commit 1be71c2

Browse files
Fix:ImageFields bug temporary fix (#1478)
* hot fix * null check * test cases update * change for test --------- Co-authored-by: tusmester <tusmester@gmail.com>
1 parent fa22100 commit 1be71c2

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

packages/sn-controls-react/src/fieldcontrols/short-text.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export const ShortText: React.FC<ReactClientFieldSetting<ShortTextFieldSetting>>
5858
{props.settings.DisplayName}
5959
</Typography>
6060
<Typography variant="body1" gutterBottom={true}>
61-
{props.fieldValue || localization.noValue}
61+
{/* Temporary hot fix */}
62+
{typeof props.fieldValue !== 'string' ? '[OBJECT]' : props.fieldValue || localization.noValue}
6263
</Typography>
6364
</div>
6465
)

packages/sn-controls-react/test/__snapshots__/short-text.test.tsx.snap

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`Short text field control in browse view should show [OBJECT] when iccorect type passed 1`] = `
4+
<div>
5+
<WithStyles(ForwardRef(Typography))
6+
gutterBottom={true}
7+
variant="caption"
8+
>
9+
Display name
10+
</WithStyles(ForwardRef(Typography))>
11+
<WithStyles(ForwardRef(Typography))
12+
gutterBottom={true}
13+
variant="body1"
14+
>
15+
[OBJECT]
16+
</WithStyles(ForwardRef(Typography))>
17+
</div>
18+
`;
19+
320
exports[`Short text field control in browse view should show the displayname and fieldValue when fieldValue is provided 1`] = `
421
<div>
522
<WithStyles(ForwardRef(Typography))

packages/sn-controls-react/test/short-text.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ describe('Short text field control', () => {
2424
const wrapper = shallow(<ShortText actionName="browse" settings={defaultSettings} />)
2525
expect(wrapper.find(Typography).last().text()).toBe(defaultLocalization.shortText.noValue)
2626
})
27+
it('should show [OBJECT] when iccorect type passed', () => {
28+
const value = { url: '' }
29+
const wrapper = shallow(<ShortText fieldValue={value as any} actionName="browse" settings={defaultSettings} />)
30+
expect(wrapper.find(Typography).first().text()).toBe(defaultSettings.DisplayName)
31+
expect(wrapper.find(Typography).last().text()).toBe('[OBJECT]')
32+
expect(wrapper).toMatchSnapshot()
33+
})
2734
})
2835
describe('in edit/new view', () => {
2936
it('should set all the props', () => {

0 commit comments

Comments
 (0)