-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e8a7eb
commit 1e40cf4
Showing
3 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/synapse-react-client/src/components/SynapseChat/SynapseChatInteraction.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import React from 'react' | ||
import SynapseChatInteraction, { | ||
SynapseChatInteractionProps, | ||
} from './SynapseChatInteraction' | ||
|
||
const defaultProps: SynapseChatInteractionProps = { | ||
userMessage: 'hello world', | ||
} | ||
|
||
function renderComponent(props?: Partial<SynapseChatInteractionProps>) { | ||
render(<SynapseChatInteraction {...defaultProps} {...props} />) | ||
} | ||
describe('SynapseChatInteraction tests', () => { | ||
it('Chat response is rendered', async () => { | ||
renderComponent({ | ||
chatResponseText: 'here is a response', | ||
}) | ||
|
||
const text = await screen.findByText('here is a response') | ||
expect(text).toBeInTheDocument() | ||
}) | ||
|
||
it('Custom LLM ML elements are removed, and tool_name content is deleted', async () => { | ||
renderComponent({ | ||
chatResponseText: | ||
'<function_results>\n<result>\n<tool_name><REDACTED>tool-name</tool_name>\n<stdout> Content is cleaned up \n</stdout>\n</result>\n', | ||
}) | ||
|
||
const text = await screen.findByText('Content is cleaned up') | ||
expect(text).toBeInTheDocument() | ||
expect(screen.queryByText('tool-name')).not.toBeInTheDocument() | ||
// html should be removed in 2 ways (by the DOMParser cleanup in SynapseChatInteraction as well as the xss html sanitizer in MarkdownSynapse) | ||
expect(screen.queryByText('<result>')).not.toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters