-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathrealtime-transcript.tsx
More file actions
64 lines (58 loc) · 2.06 KB
/
Copy pathrealtime-transcript.tsx
File metadata and controls
64 lines (58 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from 'react';
import {render, screen} from '@testing-library/react';
import '@testing-library/jest-dom';
import RealTimeTranscriptComponent from '../../../../src/components/task/RealTimeTranscript/real-time-transcript';
import {RealTimeTranscriptComponentProps} from '../../../../src/components/task/task.types';
describe('RealTimeTranscriptComponent', () => {
const defaultProps: RealTimeTranscriptComponentProps = {
liveTranscriptEntries: [
{
id: '2',
speaker: '%Customer%',
message: 'Customer message',
timestamp: 2,
displayTime: '00:02',
isCustomer: true,
},
{
id: '1',
speaker: '%You%',
message: 'Agent message',
timestamp: 1,
displayTime: '00:01',
},
],
};
it('renders live transcript entries and sorts by timestamp', () => {
render(<RealTimeTranscriptComponent {...defaultProps} />);
const messages = screen.getAllByTestId('real-time-transcript:item');
expect(messages).toHaveLength(2);
expect(messages[0]).toHaveTextContent('Agent message');
expect(messages[0]).toHaveAttribute('data-speaker-role', 'agent');
expect(messages[1]).toHaveTextContent('Customer message');
expect(messages[1]).toHaveAttribute('data-speaker-role', 'customer');
});
it('renders transcript event inline with timestamp', () => {
render(
<RealTimeTranscriptComponent
liveTranscriptEntries={[
{
id: 'event-1',
speaker: '%You%',
message: 'Agent message',
timestamp: 1,
displayTime: '11:26 AM',
event: '%Tombstone - action occurred%',
},
]}
/>
);
expect(screen.getByTestId('real-time-transcript:event')).toHaveTextContent(
'%Tombstone - action occurred%. 11:26 AM'
);
});
it('renders empty state when there are no transcript entries', () => {
render(<RealTimeTranscriptComponent liveTranscriptEntries={[]} />);
expect(screen.getByText('No live transcript available.')).toBeInTheDocument();
});
});