forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatTranscript.evidence.test.tsx
More file actions
81 lines (74 loc) · 2.27 KB
/
Copy pathChatTranscript.evidence.test.tsx
File metadata and controls
81 lines (74 loc) · 2.27 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { render, screen } from '@testing-library/react';
import { beforeEach, describe, expect, it } from 'vitest';
import { ChatTranscript } from '@/components/chat/ChatTranscript';
import type { ClientMessage } from '@/types/conversation';
function aiMessage(evidence?: ClientMessage['evidence']): ClientMessage {
return {
id: 'message-1',
created_at: '2026-08-23T12:00:00Z',
sender: 'ai',
text: 'The answer remains authoritative.',
type: 'text',
evidence,
};
}
function renderTranscript(messages: ClientMessage[]) {
return render(
<ChatTranscript
messages={messages}
isLoading={false}
isStreaming={false}
streamingText=""
currentThinking=""
autoScroll={false}
/>,
);
}
beforeEach(() => {
Element.prototype.scrollIntoView = () => undefined;
});
describe('ChatTranscript evidence', () => {
it('keeps answer text authoritative and renders admitted conversation evidence after it', () => {
renderTranscript([
aiMessage({
schema_version: 1,
references: [
{
id: 'summary-1',
kind: 'conversation_summary',
state: 'available',
title: 'Supporting conversation',
summary: 'This is supplemental context.',
conversation_id: 'conversation-1',
},
],
}),
]);
expect(screen.getByText('The answer remains authoritative.')).toBeInTheDocument();
expect(screen.getByText('Supporting conversation')).toBeInTheDocument();
expect(
screen.getByRole('region', { name: 'Supporting evidence' }),
).toBeInTheDocument();
});
it('keeps unsupported and future evidence inert while still rendering the answer', () => {
renderTranscript([
aiMessage({
schema_version: 99,
references: [
{
id: 'screen-1',
kind: 'screen',
state: 'available',
frame_id: 'frame-1',
title: 'Current screen',
},
],
}),
]);
expect(screen.getByText('The answer remains authoritative.')).toBeInTheDocument();
expect(
screen.queryByRole('region', { name: 'Supporting evidence' }),
).not.toBeInTheDocument();
expect(screen.queryByText('Current screen')).not.toBeInTheDocument();
});
});