Your Name e4959d584f feat: 完善代理商端业务逻辑与前后端框架
主要更新:
- 更新代理商端文档,明确项目由品牌方分配流程
- 新增Brief配置详情页(已配置)设计稿
- 完善工作台紧急待办中品牌新任务功能
- 整理Pencil设计文件中代理商端页面顺序
- 新增后端FastAPI框架及核心API
- 新增前端Next.js页面和组件库
- 添加.gitignore排除构建和缓存文件

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 19:27:31 +08:00

89 lines
2.9 KiB
TypeScript

/**
* MobileLayout 组件测试
* 测试覆盖: StatusBar、BottomNav 显示、内容区域样式
*/
import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { MobileLayout } from './MobileLayout';
describe('MobileLayout', () => {
// ==================== 基础渲染测试 ====================
describe('基础渲染', () => {
it('渲染子元素', () => {
render(<MobileLayout></MobileLayout>);
expect(screen.getByText('内容区域')).toBeInTheDocument();
});
it('默认显示状态栏', () => {
render(<MobileLayout></MobileLayout>);
expect(screen.getByText('9:41')).toBeInTheDocument();
});
it('默认显示底部导航', () => {
render(<MobileLayout role="creator"></MobileLayout>);
expect(screen.getByText('任务')).toBeInTheDocument();
});
});
// ==================== StatusBar 测试 ====================
describe('StatusBar', () => {
it('showStatusBar=true 显示状态栏', () => {
render(<MobileLayout showStatusBar={true}></MobileLayout>);
expect(screen.getByText('9:41')).toBeInTheDocument();
});
it('showStatusBar=false 隐藏状态栏', () => {
render(<MobileLayout showStatusBar={false}></MobileLayout>);
expect(screen.queryByText('9:41')).not.toBeInTheDocument();
});
});
// ==================== BottomNav 测试 ====================
describe('BottomNav', () => {
it('showBottomNav=false 隐藏底部导航', () => {
render(
<MobileLayout showBottomNav={false}>
</MobileLayout>
);
expect(screen.queryByText('任务')).not.toBeInTheDocument();
});
});
// ==================== 内容区域测试 ====================
describe('内容区域', () => {
it('showBottomNav=true 时内容区域有底部 padding', () => {
const { container } = render(
<MobileLayout showBottomNav={true}>
</MobileLayout>
);
const main = container.querySelector('main');
expect(main).toHaveClass('pb-[95px]');
});
it('showBottomNav=false 时内容区域无底部 padding', () => {
const { container } = render(
<MobileLayout showBottomNav={false}></MobileLayout>
);
const main = container.querySelector('main');
expect(main).not.toHaveClass('pb-[95px]');
});
});
// ==================== 样式测试 ====================
describe('样式', () => {
it('应用背景色', () => {
const { container } = render(<MobileLayout></MobileLayout>);
expect(container.firstChild).toHaveClass('bg-bg-page');
});
it('支持自定义 className', () => {
const { container } = render(
<MobileLayout className="custom-layout"></MobileLayout>
);
expect(container.firstChild).toHaveClass('custom-layout');
});
});
});