fix: failed rjsf test

This commit is contained in:
lin onetwo 2025-11-23 03:02:08 +08:00
parent 407dfefe7a
commit 1fea03027f
3 changed files with 25 additions and 16 deletions

View file

@ -387,7 +387,7 @@ export const CreateNewAgentContent: React.FC<CreateNewAgentContentProps> = ({ ta
)
: (
<Typography variant='body2' color='text.secondary'>
{t('CreateAgent.LoadingSchema')}
{t('CreateAgent.NoTemplateSelected')}
</Typography>
)}
</StepContainer>

View file

@ -219,22 +219,27 @@ describe('CreateNewAgentContent', () => {
it('should show correct step content based on currentStep', () => {
// Test step 1 (currentStep: 0) - Setup Agent (name + template)
const step1Tab = { ...mockTab, currentStep: 0 };
const { rerender } = render(<TestComponent tab={step1Tab} />);
const { unmount } = render(<TestComponent tab={step1Tab} />);
expect(screen.getByRole('heading', { name: '设置智能体' })).toBeInTheDocument();
expect(screen.getByLabelText('智能体名称')).toBeInTheDocument();
expect(screen.getByTestId('template-search-input')).toBeInTheDocument();
// Clean up before next render
unmount();
// Test step 2 (currentStep: 1) - Edit Prompt
const step2Tab = { ...mockTab, currentStep: 1 };
rerender(<TestComponent tab={step2Tab} />);
const { unmount: unmount2 } = render(<TestComponent tab={step2Tab} />);
// Should show editPrompt placeholder when no template selected
expect(screen.getByText('请先选择一个模板')).toBeInTheDocument();
unmount2();
// Test step 3 (currentStep: 2) - Immediate Use
const step3Tab = { ...mockTab, currentStep: 2 };
rerender(<TestComponent tab={step3Tab} />);
render(<TestComponent tab={step3Tab} />);
expect(screen.getByRole('heading', { name: '测试并使用' })).toBeInTheDocument();
});

View file

@ -1,8 +1,7 @@
import { Helmet } from '@dr.pogodin/react-helmet';
import { styled, Theme } from '@mui/material/styles';
import { styled } from '@mui/material/styles';
import { lazy } from 'react';
import { useTranslation } from 'react-i18next';
import is, { isNot } from 'typescript-styled-is';
import { Route, Switch } from 'wouter';
import { PageType } from '@/constants/pageTypes';
@ -42,20 +41,25 @@ const Root = styled('div')`
}
`;
const ContentRoot = styled('div')<{ $sidebar: boolean }>`
const ContentRoot = styled('div')<{ $sidebar: boolean }>(
({ theme, $sidebar }) => `
flex: 1;
display: flex;
flex-direction: column;
${is('$sidebar')`
width: calc(100% - ${({ theme }: { theme: Theme }) => theme.sidebar.width}px);
max-width: calc(100% - ${({ theme }: { theme: Theme }) => theme.sidebar.width}px);
`}
${isNot('$sidebar')`
width: 100%;
`}
height: 100%;
`;
${
$sidebar
? `
width: calc(100% - ${theme.sidebar.width}px);
max-width: calc(100% - ${theme.sidebar.width}px);
`
: `
width: 100%;
`
}
`,
);
export default function Main(): React.JSX.Element {
const { t } = useTranslation();