diff --git a/src/pages/Agent/TabContent/TabTypes/CreateNewAgentContent.tsx b/src/pages/Agent/TabContent/TabTypes/CreateNewAgentContent.tsx index fb96a815..e4482b98 100644 --- a/src/pages/Agent/TabContent/TabTypes/CreateNewAgentContent.tsx +++ b/src/pages/Agent/TabContent/TabTypes/CreateNewAgentContent.tsx @@ -387,7 +387,7 @@ export const CreateNewAgentContent: React.FC = ({ ta ) : ( - {t('CreateAgent.LoadingSchema')} + {t('CreateAgent.NoTemplateSelected')} )} diff --git a/src/pages/Agent/TabContent/TabTypes/__tests__/CreateNewAgentContent.test.tsx b/src/pages/Agent/TabContent/TabTypes/__tests__/CreateNewAgentContent.test.tsx index d94cdf1c..f00087c6 100644 --- a/src/pages/Agent/TabContent/TabTypes/__tests__/CreateNewAgentContent.test.tsx +++ b/src/pages/Agent/TabContent/TabTypes/__tests__/CreateNewAgentContent.test.tsx @@ -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(); + const { unmount } = render(); 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(); + const { unmount: unmount2 } = render(); // 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(); + render(); expect(screen.getByRole('heading', { name: '测试并使用' })).toBeInTheDocument(); }); diff --git a/src/pages/Main/index.tsx b/src/pages/Main/index.tsx index d42ca66d..d0a0c1e3 100644 --- a/src/pages/Main/index.tsx +++ b/src/pages/Main/index.tsx @@ -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();