From 64e23994a6f7960566456b3ce0cefc7a65ffd3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E9=9C=96=E9=93=83?= Date: Thu, 28 May 2026 00:39:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(test):=20=E4=BF=AE=E5=A4=8D=20CopyButton=20?= =?UTF-8?q?mock=20=E6=9C=AA=E6=8D=95=E8=8E=B7=20clipboard=20writeText=20?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vitest.setup.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vitest.setup.ts b/vitest.setup.ts index d20df79..6f4aaab 100644 --- a/vitest.setup.ts +++ b/vitest.setup.ts @@ -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); },