mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-19 14:33:38 +00:00
⛴️ fix: Reset Agent Search and Wait for Completed Diagram Exports
This commit is contained in:
parent
84a53a4464
commit
67e4609f6a
3 changed files with 51 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import {
|
|||
messagesView,
|
||||
selectMockEndpoint,
|
||||
sendMessage,
|
||||
sendMessageAndWaitForCompletion,
|
||||
} from './helpers';
|
||||
|
||||
const isStartupConfigRequest = (request: Request) =>
|
||||
|
|
@ -157,8 +158,14 @@ test.describe('Mermaid Artifact resource boundary', () => {
|
|||
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
|
||||
await selectMockEndpoint(page, MOCK_ENDPOINTS[0]);
|
||||
|
||||
const response = await sendMessage(page, 'E2E_LARGE_MERMAID_ARTIFACT_REPLY');
|
||||
// This test exercises completed-diagram exports. Mid-stream artifacts use
|
||||
// the Code tab while their source is being generated, not a settled preview.
|
||||
const response = await sendMessageAndWaitForCompletion(
|
||||
page,
|
||||
'E2E_LARGE_MERMAID_ARTIFACT_REPLY',
|
||||
);
|
||||
expect(response.ok()).toBeTruthy();
|
||||
await expect(page.getByRole('button', { name: 'Stop generating' })).toBeHidden();
|
||||
|
||||
const messages = messagesView(page);
|
||||
await expect(messages.getByRole('img', { name: 'Mermaid diagram' })).toBeVisible();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { act, fireEvent, render, screen } from '@testing-library/react';
|
||||
import { useState } from 'react';
|
||||
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import { OGDialog, OGDialogContent, OGDialogTitle } from './OriginalDialog';
|
||||
import ControlCombobox from './ControlCombobox';
|
||||
|
||||
|
|
@ -262,6 +263,39 @@ describe('ControlCombobox dropdown caps', () => {
|
|||
expect(screen.getByRole('option', { name: 'Agent 15' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('clears a completed search when the select popover closes, retaining the chosen agent', async () => {
|
||||
function Picker() {
|
||||
const [selected, setSelected] = useState('agent-1');
|
||||
return (
|
||||
<ControlCombobox
|
||||
selectedValue={selected}
|
||||
items={manyItems}
|
||||
setValue={setSelected}
|
||||
ariaLabel="Test combobox"
|
||||
searchPlaceholder="Search agents"
|
||||
isCollapsed={false}
|
||||
unsearchedLimit={10}
|
||||
/>
|
||||
);
|
||||
}
|
||||
render(<Picker />);
|
||||
openPopover();
|
||||
fireEvent.change(screen.getByPlaceholderText('Search agents'), {
|
||||
target: { value: 'Agent 15' },
|
||||
});
|
||||
fireEvent.click(screen.getByRole('option', { name: 'Agent 15' }));
|
||||
const trigger = screen.getByRole('combobox', { name: 'Test combobox' });
|
||||
await waitFor(() => expect(trigger).toHaveAttribute('aria-expanded', 'false'));
|
||||
expect(trigger).toHaveTextContent('agent-15');
|
||||
fireEvent.click(trigger);
|
||||
await waitFor(() => expect(screen.getByPlaceholderText('Search agents')).toHaveValue(''));
|
||||
expect(screen.getAllByRole('option')[0]).toHaveAttribute('aria-setsize', '10');
|
||||
expect(screen.getByRole('option', { name: 'Agent 15' })).toHaveAttribute(
|
||||
'aria-selected',
|
||||
'true',
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps the selected option in the capped list when it ranks past the cut', () => {
|
||||
renderCapped({ selectedValue: 'agent-15' });
|
||||
openPopover();
|
||||
|
|
|
|||
|
|
@ -117,6 +117,14 @@ function ControlCombobox({
|
|||
placement,
|
||||
});
|
||||
|
||||
const selectOpen = select.useState('open');
|
||||
useEffect(() => {
|
||||
// The select owns the popover; hiding it does not hide the combobox store.
|
||||
if (!selectOpen) {
|
||||
setSearchValue('');
|
||||
}
|
||||
}, [selectOpen]);
|
||||
|
||||
const matches = useMemo(() => {
|
||||
const filteredItems = matchSorter(items, searchValue, {
|
||||
keys: ['value', 'label'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue