From d80f7f030e8d6b5783ab2668c60ced0e7ca46057 Mon Sep 17 00:00:00 2001
From: Dustin Healy <54083382+dustinhealy@users.noreply.github.com>
Date: Mon, 18 May 2026 16:26:50 -0700
Subject: [PATCH] =?UTF-8?q?=F0=9F=95=B5=F0=9F=8F=BB=20ci:=20Improve=20Flak?=
=?UTF-8?q?y=20Subagents=20Test=20(#13185)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Parts/__tests__/SubagentCall.test.tsx | 51 ++++++++++---------
1 file changed, 26 insertions(+), 25 deletions(-)
diff --git a/client/src/components/Chat/Messages/Content/Parts/__tests__/SubagentCall.test.tsx b/client/src/components/Chat/Messages/Content/Parts/__tests__/SubagentCall.test.tsx
index 38a82682a2..f78f71d75b 100644
--- a/client/src/components/Chat/Messages/Content/Parts/__tests__/SubagentCall.test.tsx
+++ b/client/src/components/Chat/Messages/Content/Parts/__tests__/SubagentCall.test.tsx
@@ -83,22 +83,19 @@ jest.mock('../Attachment', () => ({
),
}));
-jest.mock(
- '@librechat/client',
- () => ({
- OGDialog: ({ children }: { children: React.ReactNode }) => <>{children}>,
- OGDialogContent: ({ children }: { children: React.ReactNode }) => (
-
{children}
- ),
- OGDialogTitle: ({ children }: { children: React.ReactNode }) => (
- {children}
- ),
- OGDialogDescription: ({ children }: { children: React.ReactNode }) => (
- {children}
- ),
- }),
- { virtual: true },
-);
+jest.mock('@librechat/client', () => ({
+ __esModule: true,
+ OGDialog: ({ children }: { children: React.ReactNode }) => <>{children}>,
+ OGDialogContent: ({ children }: { children: React.ReactNode }) => (
+ {children}
+ ),
+ OGDialogTitle: ({ children }: { children: React.ReactNode }) => (
+ {children}
+ ),
+ OGDialogDescription: ({ children }: { children: React.ReactNode }) => (
+ {children}
+ ),
+}));
jest.mock('lucide-react', () => ({
// eslint-disable-next-line i18next/no-literal-string
@@ -246,6 +243,13 @@ function renderWithState(args: {
return { ...rendered, setProgress };
}
+/** Open the subagent dialog. Required when another test file in the same Jest
+ * worker has already loaded the real `@librechat/client` module; Radix only
+ * mounts dialog content while `open` is true. */
+function openSubagentDialog(headerLabel = 'Ran agent') {
+ fireEvent.click(screen.getByRole('button', { name: headerLabel }));
+}
+
describe('SubagentCall — status resolution', () => {
it('renders "Running agent" while streaming and no terminal envelope has arrived', () => {
renderWithState({
@@ -519,6 +523,7 @@ describe('SubagentCall — dialog content', () => {
,
);
+ openSubagentDialog();
expect(screen.getByTestId('prompt-markdown')).toHaveTextContent('# Review prompt');
expect(screen.getByText('final answer')).toBeInTheDocument();
@@ -594,8 +599,7 @@ describe('SubagentCall — dialog content', () => {
}),
});
- /** The mocked `OGDialog` always renders children, so dialog content is
- * inspectable without simulating a click. */
+ openSubagentDialog();
expect(screen.getByTestId('reasoning-part')).toHaveTextContent('Let me compute.');
expect(screen.getByTestId('tool-call-part')).toHaveAttribute('data-name', 'calculator');
expect(screen.getByTestId('tool-call-part')).toHaveTextContent('4');
@@ -603,15 +607,9 @@ describe('SubagentCall — dialog content', () => {
});
it('falls back to the raw tool output when no content parts were recorded', () => {
- renderWithState({
- toolCallId: 'call_fallback',
- initialProgress: 1,
- isSubmitting: false,
- progress: null,
- });
/** No events → no aggregated parts. The SubagentCall should still
* render the raw final `output` that came back in the parent's
- * tool_call (we pass it explicitly below). */
+ * tool_call. */
const { rerender } = render(
{
/>
,
);
+ openSubagentDialog();
expect(screen.getByText('raw final text')).toBeInTheDocument();
rerender();
});
@@ -661,6 +660,7 @@ describe('SubagentCall — dialog content', () => {
,
);
+ openSubagentDialog();
expect(screen.getByTestId('reasoning-part')).toHaveTextContent('Prior thinking.');
expect(screen.getByTestId('tool-call-part')).toHaveAttribute('data-name', 'calculator');
expect(screen.getByTestId('tool-call-part')).toHaveTextContent('2436');
@@ -694,6 +694,7 @@ describe('SubagentCall — dialog content', () => {
/>
,
);
+ openSubagentDialog();
expect(screen.getByText('Persisted answer.')).toBeInTheDocument();
});