mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-03 00:58:50 +01:00
style: adjust icon scale, favicon, azure icon; chore: convert files to TSX; ci: unit tests for generation buttons (#987)
* some jsx to tsx and added 3 new test * test(stop) * new librechat and azure icon, small fix * fix(tsc error) * fix(tsc error) Endpoint Item
This commit is contained in:
parent
3137f467a8
commit
be71a1947b
21 changed files with 187 additions and 56 deletions
|
|
@ -27,6 +27,7 @@ export default function ModelItem({
|
|||
error: false,
|
||||
className: 'mr-2',
|
||||
message: false,
|
||||
isCreatedByUser: false,
|
||||
});
|
||||
|
||||
const userProvidesKey = endpointsConfig?.[endpoint]?.userProvide;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
import EndpointItem from './EndpointItem';
|
||||
|
||||
export default function EndpointItems({ endpoints, onSelect, selectedEndpoint }) {
|
||||
interface EndpointItemsProps {
|
||||
endpoints: string[];
|
||||
onSelect: (endpoint: string) => void;
|
||||
selectedEndpoint: string;
|
||||
}
|
||||
|
||||
export default function EndpointItems({ endpoints, selectedEndpoint }: EndpointItemsProps) {
|
||||
return (
|
||||
<>
|
||||
{endpoints.map((endpoint) => (
|
||||
|
|
@ -8,7 +14,6 @@ export default function EndpointItems({ endpoints, onSelect, selectedEndpoint })
|
|||
isSelected={selectedEndpoint === endpoint}
|
||||
key={endpoint}
|
||||
value={endpoint}
|
||||
onSelect={onSelect}
|
||||
endpoint={endpoint}
|
||||
/>
|
||||
))}
|
||||
|
|
@ -17,6 +17,7 @@ export default function PresetItem({
|
|||
model: preset?.model,
|
||||
error: false,
|
||||
className: 'mr-2',
|
||||
isCreatedByUser: false,
|
||||
});
|
||||
|
||||
const getPresetTitle = () => {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
import { render, fireEvent } from '@testing-library/react';
|
||||
import Button from '../Button';
|
||||
|
||||
describe('Button', () => {
|
||||
it('renders with the correct type and children', () => {
|
||||
const { getByTestId, getByText } = render(
|
||||
<Button
|
||||
type="regenerate"
|
||||
onClick={() => {
|
||||
('');
|
||||
}}
|
||||
>
|
||||
Regenerate
|
||||
</Button>,
|
||||
);
|
||||
expect(getByTestId('regenerate-generation-button')).toBeInTheDocument();
|
||||
expect(getByText('Regenerate')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onClick when clicked', () => {
|
||||
const handleClick = jest.fn();
|
||||
const { getByText } = render(
|
||||
<Button type="continue" onClick={handleClick}>
|
||||
Continue
|
||||
</Button>,
|
||||
);
|
||||
fireEvent.click(getByText('Continue'));
|
||||
expect(handleClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import { render, fireEvent } from '@testing-library/react';
|
||||
import Continue from '../Continue';
|
||||
|
||||
describe('Continue', () => {
|
||||
it('should render the Continue button', () => {
|
||||
const { getByText } = render(
|
||||
<Continue
|
||||
onClick={() => {
|
||||
('');
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
expect(getByText('Continue')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should call onClick when the button is clicked', () => {
|
||||
const handleClick = jest.fn();
|
||||
const { getByText } = render(<Continue onClick={handleClick} />);
|
||||
fireEvent.click(getByText('Continue'));
|
||||
expect(handleClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import { render, fireEvent } from '@testing-library/react';
|
||||
import Regenerate from '../Regenerate';
|
||||
|
||||
describe('Regenerate', () => {
|
||||
it('should render the Regenerate button', () => {
|
||||
const { getByText } = render(
|
||||
<Regenerate
|
||||
onClick={() => {
|
||||
('');
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
expect(getByText('Regenerate')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should call onClick when the button is clicked', () => {
|
||||
const handleClick = jest.fn();
|
||||
const { getByText } = render(<Regenerate onClick={handleClick} />);
|
||||
fireEvent.click(getByText('Regenerate'));
|
||||
expect(handleClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import { render, fireEvent } from '@testing-library/react';
|
||||
import Stop from '../Stop';
|
||||
|
||||
describe('Stop', () => {
|
||||
it('should render the Stop button', () => {
|
||||
const { getByText } = render(
|
||||
<Stop
|
||||
onClick={() => {
|
||||
('');
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
expect(getByText('Stop')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should call onClick when the button is clicked', () => {
|
||||
const handleClick = jest.fn();
|
||||
const { getByText } = render(<Stop onClick={handleClick} />);
|
||||
fireEvent.click(getByText('Stop'));
|
||||
expect(handleClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue