a5d86a92c2
feat: 升级项目 Logo、完善 toast 提示及优化工程化配置 ### Features - **logo**: 替换全套项目图标,更新 wxt.config.ts 浏览器扩展图标配置。 ### Bug Fixes - **ui/toast**: 引入 <Toaster> 组件修复 toast 无法显示问题,并调整位置为正下方。 - **i18n**: 统一将 t() 函数中的 `.` 和 `:` 转换为 `_`,修复国际化文案读取失败问题。 - **context-menu**: 限制 srcUrl 检查仅在二维码图片菜单项生效,避免误判。 - **hooks**: 修复 pre-push 钩子,仅对变更文件进行 eslint 检查,并支持无 upstream 时的回退对比。 - **components**: 修复 CopyButton 动画与组件导入方式,并补齐无障碍属性与测试。 - **async**: 延迟生成二维码以正确渲染 loading 状态,并适配相关异步测试。 ### Refactor & Cleans - **clean**: 清理未使用的组件(ToolCard)、Hook(useDebounce)及多个未使用的工具函数导出。 - **structure**: 统一移动测试文件至 __tests__ 目录,移除不必要的类型导出。 ### Documentation - **docs**: 在 AGENTS.md 中明确规范 Git Commit 必须使用中文描述。
26 lines
931 B
TypeScript
26 lines
931 B
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { openExtensionPage } from '@/utils/chromeTabs';
|
|
|
|
describe('chromeTabs', () => {
|
|
describe('openExtensionPage', () => {
|
|
it('应该在新标签页中打开扩展页面', async () => {
|
|
await openExtensionPage('popup.html');
|
|
|
|
expect(chrome.runtime.getURL).toHaveBeenCalledWith('popup.html');
|
|
expect(chrome.tabs.create).toHaveBeenCalledWith({
|
|
url: 'chrome-extension://test-extension-id/popup.html',
|
|
});
|
|
});
|
|
|
|
it('当创建标签页失败时应记录错误', async () => {
|
|
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
(chrome.tabs.create as any).mockRejectedValue(new Error('Tab creation failed'));
|
|
|
|
await openExtensionPage('popup.html');
|
|
|
|
expect(consoleSpy).toHaveBeenCalledWith('打开扩展页面失败:', expect.any(Error));
|
|
consoleSpy.mockRestore();
|
|
});
|
|
});
|
|
});
|