From 51f0315d682c66b9308c87a6a0a3404870e4455d Mon Sep 17 00:00:00 2001 From: Nick Zeng Date: Wed, 15 Apr 2026 11:05:50 +0800 Subject: [PATCH] fix test errors --- frontend/src/components/ApiKeyPanel.vue | 33 +- frontend/src/components/DataScopeModal.vue | 19 +- .../components/__tests__/ApiKeyPanel.spec.ts | 323 ++++++++++++++++++ .../layouts/__tests__/MainLayout.spec.ts | 17 +- .../src/pages/profile/__tests__/index.spec.ts | 7 +- frontend/src/pages/profile/index.vue | 5 + frontend/src/pages/sku-mappings/index.vue | 23 +- frontend/src/pages/sku-origins/index.vue | 18 +- frontend/src/utils/jwt.ts | 2 +- 9 files changed, 402 insertions(+), 45 deletions(-) create mode 100644 frontend/src/components/__tests__/ApiKeyPanel.spec.ts diff --git a/frontend/src/components/ApiKeyPanel.vue b/frontend/src/components/ApiKeyPanel.vue index 7e831da..61764f5 100644 --- a/frontend/src/components/ApiKeyPanel.vue +++ b/frontend/src/components/ApiKeyPanel.vue @@ -20,7 +20,7 @@ const createModalOpen = ref(false) const createLoading = ref(false) const createForm = reactive({ name: '', - expires_at: null as string | null, + expires_at: undefined as string | undefined, }) // Plain key modal @@ -50,7 +50,7 @@ const readonlyColumns = columns.filter((c) => c.key !== 'enabled' && c.key !== ' function showCreateModal() { createForm.name = '' - createForm.expires_at = null + createForm.expires_at = undefined createModalOpen.value = true } @@ -84,9 +84,10 @@ async function handleDelete(record: ApiKeyRecord) { } function handleCopyKey() { - navigator.clipboard.writeText(plainKey.value).then(() => { - message.success('已复制') - }) + navigator.clipboard.writeText(plainKey.value).then( + () => message.success('已复制'), + () => message.error('复制失败,请手动复制'), + ) } function handlePlainKeyModalClose() { @@ -97,6 +98,10 @@ function handlePlainKeyModalClose() { onMounted(() => { apiKeyStore.fetchMyKeys() }) + +onBeforeUnmount(() => { + plainKey.value = '' +})