Skip to content

Commit 6fd5b5e

Browse files
committed
fix: minor updates to elementRenderer
1 parent bd11a0c commit 6fd5b5e

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

src/components/elementRenderer/elementRenderer.cy.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react'
2+
import { v4 as getUUID } from 'uuid'
23

34
import {
45
supportedViewports,
@@ -89,25 +90,45 @@ describe('ElementRenderer', () => {
8990
messages={[
9091
{
9192
...sampleMessage,
92-
data: { text: 'Test' },
93+
data: { text: 'This' },
9394
format: 'streamingText',
9495
},
9596
{
96-
id: '2',
97+
id: getUUID(),
9798
timestamp: '2020-01-02T00:00:00.000Z',
9899
sender: testUser,
99100
conversationId: 'lkd9vc',
100101
topic: 'default',
101102
threadId: '1',
102-
data: { text: ' Text' },
103+
data: { text: ' is' },
104+
format: 'streamingText',
105+
},
106+
{
107+
id: getUUID(),
108+
timestamp: '2020-01-02T00:00:00.000Z',
109+
sender: testUser,
110+
conversationId: 'lkd9vc',
111+
topic: 'default',
112+
threadId: '1',
113+
data: { text: ' streaming' },
114+
format: 'streamingText',
115+
},
116+
{
117+
id: getUUID(),
118+
timestamp: '2020-01-02T00:00:00.000Z',
119+
sender: testUser,
120+
conversationId: 'lkd9vc',
121+
topic: 'default',
122+
threadId: '1',
123+
data: { text: ' text.' },
103124
format: 'streamingText',
104125
},
105126
]}
106127
{...commonProps}
107128
ws={mockWsClient}
108129
/>
109130
)
110-
cy.get('p').should('contain.text', 'Test Text')
131+
cy.get('p').should('contain.text', 'This is streaming text.')
111132
})
112133

113134
it(`renders a message for an unsupported format on ${viewport} screen`, () => {

src/components/elementRenderer/elementRenderer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ const ElementRenderer = (props: ElementRendererProps) => {
2424
messageId: rootMessage.id,
2525
conversationId: rootMessage.conversationId,
2626
...rootMessage.data,
27-
updatedData: updateMessages.map((message) => message.data),
27+
...(updateMessages.length > 0 && {
28+
updatedData: updateMessages.map((message) => message.data),
29+
}),
2830
})
2931
) : (
3032
<Typography variant="body2">

0 commit comments

Comments
 (0)