feat: 增加测试覆盖率并优化代码质量
test: 添加单元测试和端到端测试 refactor: 重构登录页面和上传模块 ci: 更新测试覆盖率阈值至42% build: 添加测试相关依赖 docs: 更新测试文档 style: 修复代码格式问题
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom';
|
||||
import PrivacyPolicyPage from './page';
|
||||
|
||||
describe('PrivacyPolicyPage', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('Rendering', () => {
|
||||
it('should render privacy policy page', () => {
|
||||
render(<PrivacyPolicyPage />);
|
||||
const container = screen.getByText('隐私政策').closest('div');
|
||||
expect(container).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render page title', () => {
|
||||
render(<PrivacyPolicyPage />);
|
||||
const title = screen.getByRole('heading', { level: 1 });
|
||||
expect(title).toBeInTheDocument();
|
||||
expect(title).toHaveTextContent('隐私政策');
|
||||
});
|
||||
|
||||
it('should render introduction section', () => {
|
||||
render(<PrivacyPolicyPage />);
|
||||
const intro = screen.getByText('引言');
|
||||
expect(intro).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render information collection section', () => {
|
||||
render(<PrivacyPolicyPage />);
|
||||
const section = screen.getByText(/我们如何收集和使用您的个人信息/i);
|
||||
expect(section).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Accessibility', () => {
|
||||
it('should have proper heading hierarchy', () => {
|
||||
render(<PrivacyPolicyPage />);
|
||||
const h1 = screen.getByRole('heading', { level: 1 });
|
||||
expect(h1).toBeInTheDocument();
|
||||
|
||||
const h2s = screen.getAllByRole('heading', { level: 2 });
|
||||
expect(h2s.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user