mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-05 18:20:39 -08:00
fix: failed rjsf test
This commit is contained in:
parent
407dfefe7a
commit
1fea03027f
3 changed files with 25 additions and 16 deletions
|
|
@ -387,7 +387,7 @@ export const CreateNewAgentContent: React.FC<CreateNewAgentContentProps> = ({ ta
|
||||||
)
|
)
|
||||||
: (
|
: (
|
||||||
<Typography variant='body2' color='text.secondary'>
|
<Typography variant='body2' color='text.secondary'>
|
||||||
{t('CreateAgent.LoadingSchema')}
|
{t('CreateAgent.NoTemplateSelected')}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</StepContainer>
|
</StepContainer>
|
||||||
|
|
|
||||||
|
|
@ -219,22 +219,27 @@ describe('CreateNewAgentContent', () => {
|
||||||
it('should show correct step content based on currentStep', () => {
|
it('should show correct step content based on currentStep', () => {
|
||||||
// Test step 1 (currentStep: 0) - Setup Agent (name + template)
|
// Test step 1 (currentStep: 0) - Setup Agent (name + template)
|
||||||
const step1Tab = { ...mockTab, currentStep: 0 };
|
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.getByRole('heading', { name: '设置智能体' })).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText('智能体名称')).toBeInTheDocument();
|
expect(screen.getByLabelText('智能体名称')).toBeInTheDocument();
|
||||||
expect(screen.getByTestId('template-search-input')).toBeInTheDocument();
|
expect(screen.getByTestId('template-search-input')).toBeInTheDocument();
|
||||||
|
|
||||||
|
// Clean up before next render
|
||||||
|
unmount();
|
||||||
|
|
||||||
// Test step 2 (currentStep: 1) - Edit Prompt
|
// Test step 2 (currentStep: 1) - Edit Prompt
|
||||||
const step2Tab = { ...mockTab, currentStep: 1 };
|
const step2Tab = { ...mockTab, currentStep: 1 };
|
||||||
rerender(<TestComponent tab={step2Tab} />);
|
const { unmount: unmount2 } = render(<TestComponent tab={step2Tab} />);
|
||||||
|
|
||||||
// Should show editPrompt placeholder when no template selected
|
// Should show editPrompt placeholder when no template selected
|
||||||
expect(screen.getByText('请先选择一个模板')).toBeInTheDocument();
|
expect(screen.getByText('请先选择一个模板')).toBeInTheDocument();
|
||||||
|
|
||||||
|
unmount2();
|
||||||
|
|
||||||
// Test step 3 (currentStep: 2) - Immediate Use
|
// Test step 3 (currentStep: 2) - Immediate Use
|
||||||
const step3Tab = { ...mockTab, currentStep: 2 };
|
const step3Tab = { ...mockTab, currentStep: 2 };
|
||||||
rerender(<TestComponent tab={step3Tab} />);
|
render(<TestComponent tab={step3Tab} />);
|
||||||
|
|
||||||
expect(screen.getByRole('heading', { name: '测试并使用' })).toBeInTheDocument();
|
expect(screen.getByRole('heading', { name: '测试并使用' })).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import { Helmet } from '@dr.pogodin/react-helmet';
|
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 { lazy } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import is, { isNot } from 'typescript-styled-is';
|
|
||||||
import { Route, Switch } from 'wouter';
|
import { Route, Switch } from 'wouter';
|
||||||
|
|
||||||
import { PageType } from '@/constants/pageTypes';
|
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;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
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%;
|
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 {
|
export default function Main(): React.JSX.Element {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue