mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 14:57:42 +00:00
test: teach MCP hook mocks about useMCPServerNames
Three specs mock ~/hooks/MCP with a hand-listed factory, so adding the hook to ToolCall made useMCPServerNames undefined under test and every render threw. Returns a stable array so the mock cannot perturb render counts.
This commit is contained in:
parent
f6fbf08687
commit
28131fed03
3 changed files with 22 additions and 10 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import React from 'react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
import { ContentTypes } from 'librechat-data-provider';
|
||||
import type { TAttachment, TMessageContentParts } from 'librechat-data-provider';
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import type { TAttachment, TMessageContentParts } from 'librechat-data-provider';
|
||||
import ContentParts from '../ContentParts';
|
||||
|
||||
jest.mock('~/hooks', () => ({
|
||||
|
|
@ -20,9 +20,13 @@ jest.mock('~/hooks', () => ({
|
|||
scheduleMessageContentLayoutReconcile: jest.fn(() => jest.fn()),
|
||||
}));
|
||||
|
||||
jest.mock('~/hooks/MCP', () => ({
|
||||
useMCPIconMap: () => new Map(),
|
||||
}));
|
||||
jest.mock('~/hooks/MCP', () => {
|
||||
const mcpServerNames: string[] = [];
|
||||
return {
|
||||
useMCPIconMap: () => new Map(),
|
||||
useMCPServerNames: () => mcpServerNames,
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('../ToolOutput', () => ({
|
||||
StackedToolIcons: () => <span data-testid="stacked-icons" />,
|
||||
|
|
|
|||
|
|
@ -33,9 +33,13 @@ jest.mock('~/hooks', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
jest.mock('~/hooks/MCP', () => ({
|
||||
useMCPIconMap: () => new Map(),
|
||||
}));
|
||||
jest.mock('~/hooks/MCP', () => {
|
||||
const mcpServerNames: string[] = [];
|
||||
return {
|
||||
useMCPIconMap: () => new Map(),
|
||||
useMCPServerNames: () => mcpServerNames,
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('~/components/Chat/Messages/Content/MessageContent', () => ({
|
||||
__esModule: true,
|
||||
|
|
|
|||
|
|
@ -32,9 +32,13 @@ jest.mock('~/hooks', () => ({
|
|||
scheduleMessageContentLayoutReconcile: jest.fn(() => jest.fn()),
|
||||
}));
|
||||
|
||||
jest.mock('~/hooks/MCP', () => ({
|
||||
useMCPIconMap: () => new Map(),
|
||||
}));
|
||||
jest.mock('~/hooks/MCP', () => {
|
||||
const mcpServerNames: string[] = [];
|
||||
return {
|
||||
useMCPIconMap: () => new Map(),
|
||||
useMCPServerNames: () => mcpServerNames,
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('../ToolOutput', () => ({
|
||||
StackedToolIcons: ({ toolNames }: { toolNames: string[] }) => (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue