LibreChat/client/test/messagesHost.tsx
Marco Beretta e714aba067
⏳ refactor: Render the Pending Turn and Steers From @librechat/chat by Default (#18134)
- refactor: Render Pending Turn and Steers from the Package
- refactor: Keep Package Pending Rows Inert Without a Steer Host
- fix: Read the Host Thread Mode on Every Render
- fix: Point the Hosts Guard at the Messages Loader
- fix: Follow the Moved Pending Rows in the Guard and Lazy Chunk Specs
- fix: Ship Message Body Typography With the Shared Theme Styles
- fix: Keep the App Message Typography Cascade With the Shared Styles
2026-11-14 17:01:27 +01:00

59 lines
2.1 KiB
TypeScript

import React from 'react';
import { MessagesHostProvider } from '@librechat/chat/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import type { MessagesHost } from '@librechat/chat/react';
/** A messages host for specs whose subject is not the rows: inert scrolling, no forking,
* copying or read-aloud, and rows that render nothing. */
export const testMessagesHost: MessagesHost = {
useHour12: () => undefined,
renderFiles: () => null,
useForkPreferences: () => ({
option: '',
setOption: () => undefined,
splitAtTarget: false,
setSplitAtTarget: () => undefined,
rememberOption: false,
setRememberOption: () => undefined,
}),
useForkConversation: () => null,
useMessageCopy: () => ({ copyToClipboard: () => undefined, canCopy: false }),
useGetMessages: () => () => undefined,
useHasPendingTurn: () => false,
renderMessageAudio: () => null,
useScreenshotTarget: () => undefined,
useAutoScroll: () => false,
useConversationMessages: () => undefined,
useAssistant: () => undefined,
useGetAddedConvo: () => () => null,
useStreamedAttachments: () => undefined,
useMessageFeedback: () => () => undefined,
useSeenSource: () => ({
readReply: () => undefined,
hasReplyProof: () => false,
markSeen: () => undefined,
consumeFocusSuppression: () => false,
}),
renderMessageIcon: () => null,
useMaximizeChatSpace: () => false,
useFlatThread: () => true,
useHideSelectedAuthor: () => false,
useAgentsMap: () => undefined,
renderMessageBody: () => null,
renderWakeup: () => null,
renderPrivateText: () => null,
renderActivity: () => null,
useFileMap: () => undefined,
};
const queryClient = new QueryClient();
/** Mounts `testMessagesHost` for specs that render a chat pane's message list, with the query
* client its seen reporting reads. */
export function MessagesHostTestProvider({ children }: { children?: React.ReactNode }) {
return (
<QueryClientProvider client={queryClient}>
<MessagesHostProvider host={testMessagesHost}>{children}</MessagesHostProvider>
</QueryClientProvider>
);
}