fix(home): hide Robot entry and balance three module cards
This commit is contained in:
1 parent
23ddce11da
commit
13336cfe12
6 files changed
+167
-81
No files matched your search
@@ -52,7 +52,7 @@ describe('AI module navigation', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('shows the four supported module choices and routes Canvas from the chooser', async () => {
|
||||
it('shows Agents, Code and Canvas on the home page and routes Canvas from the chooser', async () => {
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/module-select']}>
|
||||
<Routes>
|
||||
@@ -64,18 +64,16 @@ describe('AI module navigation', () => {
|
||||
|
||||
expect(screen.getByTestId('ai-module-selection-page')).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: '今天,想创作什么?' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: '今天,想创作什么?' })).toHaveClass('whitespace-nowrap');
|
||||
expect(screen.getByTestId('ai-module-options')).toHaveClass('module-selection-options');
|
||||
expect(await screen.findByText('小明,欢迎回来!')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('ai-module-option-programming')).toHaveClass('module-option-card', 'module-option-card-horizontal');
|
||||
for (const moduleId of ['programming', 'painting', 'robot', 'cloud_agents'] as const) {
|
||||
expect(screen.getByTestId('ai-module-option-programming')).toHaveClass('module-option-card');
|
||||
for (const moduleId of ['programming', 'painting', 'cloud_agents'] as const) {
|
||||
expect(screen.getByTestId(`ai-module-option-${moduleId}`).querySelector('.module-option-artwork')).toBeNull();
|
||||
}
|
||||
expect(screen.getAllByTestId(/^ai-module-option-/u).map((option) => option.dataset.testid)).toEqual([
|
||||
'ai-module-option-cloud_agents',
|
||||
'ai-module-option-programming',
|
||||
'ai-module-option-painting',
|
||||
'ai-module-option-robot',
|
||||
]);
|
||||
expect(screen.queryByTestId('ai-module-option-learning')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('先选一个入口。进入后,你还可以从左下角随时切换到其他模块。')).not.toBeInTheDocument();
|
||||
@@ -89,12 +87,7 @@ describe('AI module navigation', () => {
|
||||
expect(screen.getByText('Canvas 设计')).toBeInTheDocument();
|
||||
expect(screen.getByAltText('数位板设计创作')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('ai-module-option-painting')).toHaveTextContent('用灵感描绘色彩缤纷的世界');
|
||||
const robotOption = screen.getByTestId('ai-module-option-robot');
|
||||
expect(robotOption).toBeEnabled();
|
||||
expect(robotOption).not.toHaveClass('module-option-card-disabled');
|
||||
expect(robotOption).toHaveTextContent('Robot 机器');
|
||||
expect(robotOption).toHaveTextContent('制作你的第一个机器人小伙伴');
|
||||
expect(screen.getByAltText('青少年管理机器人硬件与设备绑定')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('ai-module-option-robot')).not.toBeInTheDocument();
|
||||
expect(screen.getByAltText('个人云智能体')).toHaveAttribute('src', expect.stringContaining('module-agents.webp'));
|
||||
expect(screen.getByAltText('个人云智能体')).toHaveClass('module-option-card-image-media', 'object-cover');
|
||||
|
||||
@@ -102,7 +95,8 @@ describe('AI module navigation', () => {
|
||||
expect(await screen.findByTestId('location-path')).toHaveTextContent('/image-canvas');
|
||||
});
|
||||
|
||||
it('routes Robot from the chooser to the AI hardware workspace', async () => {
|
||||
it('hides Robot from the chooser even when its module permission is enabled', () => {
|
||||
useAuthStore.setState({ moduleAccess: { programming: true, design: true, robot: true, cloud_agents: true } });
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/module-select']}>
|
||||
<Routes>
|
||||
@@ -112,8 +106,9 @@ describe('AI module navigation', () => {
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByTestId('ai-module-option-robot'));
|
||||
expect(await screen.findByTestId('location-path')).toHaveTextContent('/ai-hardware');
|
||||
expect(screen.queryByTestId('ai-module-option-robot')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Robot 机器')).not.toBeInTheDocument();
|
||||
expect(screen.queryByAltText('青少年管理机器人硬件与设备绑定')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('greys out a disabled module and does not navigate when it is clicked', async () => {
|
||||
|
||||
Reference in new issue
Block a user