mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 14:57:42 +00:00
test: Cover grouped text preview clamp
This commit is contained in:
parent
d0f6881544
commit
2e34c7ec2f
1 changed files with 36 additions and 0 deletions
|
|
@ -222,4 +222,40 @@ describe('AttachmentGroup', () => {
|
|||
expect(container.querySelector('pre')?.textContent).toBe('{"ok":true}');
|
||||
expect(screen.getByTestId('file-container')).toHaveTextContent('output.json');
|
||||
});
|
||||
|
||||
it('keeps long grouped text previews clamped until the nested preview is expanded', () => {
|
||||
setScrollHeight(800);
|
||||
const longJson = Array.from({ length: 1000 }, (_, index) => `{"line":${index}}`).join('\n');
|
||||
const attachments = [
|
||||
textAttachment({
|
||||
file_id: 'archive',
|
||||
filename: 'archive.zip',
|
||||
type: 'application/zip',
|
||||
text: undefined as unknown as string,
|
||||
}),
|
||||
textAttachment({
|
||||
file_id: 'json',
|
||||
filename: 'output.json',
|
||||
filepath: '/files/output.json',
|
||||
text: longJson,
|
||||
}),
|
||||
] as TAttachment[];
|
||||
|
||||
const { container } = render(<AttachmentGroup attachments={attachments} />);
|
||||
const groupToggle = screen.getByRole('button', { name: 'com_ui_show_n_files' });
|
||||
fireEvent.click(groupToggle);
|
||||
|
||||
expect(screen.getByText('output.json')).toBeInTheDocument();
|
||||
const pre = container.querySelector('pre');
|
||||
expect(pre).not.toBeNull();
|
||||
expect(pre).toHaveStyle({ maxHeight: '320px' });
|
||||
const previewToggle = screen.getByRole('button', { name: 'Show all' });
|
||||
expect(previewToggle).toHaveAttribute('aria-expanded', 'false');
|
||||
|
||||
fireEvent.click(previewToggle);
|
||||
expect(screen.getByRole('button', { name: 'Collapse' })).toHaveAttribute(
|
||||
'aria-expanded',
|
||||
'true',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue