fix(test): 修复 CopyButton mock 未捕获 clipboard writeText 异常

This commit is contained in:
雨霖铃
2026-05-28 00:39:47 +08:00
parent 528621f16e
commit 64e23994a6
+5 -1
View File
@@ -80,7 +80,11 @@ vi.mock('@/components/CopyButton', () => ({
type: 'button',
onClick: async (e: React.MouseEvent) => {
if (text) {
await navigator.clipboard.writeText(text);
try {
await navigator.clipboard.writeText(text);
} catch {
// 与真实 CopyButton 行为一致:失败时静默处理
}
}
onClick?.(e);
},