aa23a263fe
- 移除 react-i18next、i18next 及相关依赖
- 删除旧的 i18n/ 目录和 useLazyTranslation 工具
- 新增 utils/chromeI18n.ts 类型安全 wrapper(useI18n Hook + getMessage)
- 生成 public/_locales/{zh,en}/messages.json(298 个翻译 key)
- 批量更新 39+ 组件文件的导入和翻译调用
- 转换翻译键格式:namespace:key → namespace_key
- 修复 ErrorBoundary/PageErrorBoundary 从 withTranslation HOC 改为直接调用 getMessage
- 更新 vitest.setup.ts mock 加载实际翻译文本
- 修复 11 个测试文件的断言以匹配中文翻译
- TypeScript、ESLint、547 项测试全部通过
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { render, screen, fireEvent } from '@testing-library/react';
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import RightClickRestorerPage from '../index';
|
|
|
|
const mockUnlock = vi.fn();
|
|
|
|
vi.mock('../useRightClickRestorer', () => ({
|
|
useRightClickRestorer: () => ({
|
|
domain: 'example.com',
|
|
isLoading: false,
|
|
isUnlocked: false,
|
|
isUnsupported: false,
|
|
unlock: mockUnlock,
|
|
}),
|
|
}));
|
|
|
|
describe('RightClickRestorerPage', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it('should render current domain', () => {
|
|
render(<RightClickRestorerPage />);
|
|
expect(screen.getByText(/example\.com/)).toBeInTheDocument();
|
|
});
|
|
|
|
it('should render locked status', () => {
|
|
render(<RightClickRestorerPage />);
|
|
expect(screen.getByText(/未解锁/)).toBeInTheDocument();
|
|
});
|
|
|
|
it('should call unlock when button clicked', () => {
|
|
render(<RightClickRestorerPage />);
|
|
const button = screen.getByRole('button');
|
|
fireEvent.click(button);
|
|
expect(mockUnlock).toHaveBeenCalled();
|
|
});
|
|
});
|