From bc818eb3ea7fead7edf0d16df9a237adae92152e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com>
Date: Sat, 24 Oct 2026 16:35:39 +0800
Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E5=A4=96=E8=A7=82=E4=B8=93?=
=?UTF-8?q?=E5=88=A9=E5=BD=93=E5=89=8D=E4=BB=BB=E5=8A=A1=E5=8C=BA=E8=A1=A5?=
=?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=85=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
结果文件已生成时「当前任务」卡片只有删除按钮、下载只挂在历史弹层,
用户误读成"失败了不能下载"。现与历史区共用同一 canDownload 判据
(只看文件不看任务状态),并加防回归用例钉住判据不得掺入状态。
---
.../components/BrandAppearancePatentTab.vue | 2 +
...rance-patent-current-task-download.test.ts | 64 +++++++++++++++++++
2 files changed, 66 insertions(+)
create mode 100644 frontend-vue/tests/appearance-patent-current-task-download.test.ts
diff --git a/frontend-vue/src/pages/brand/components/BrandAppearancePatentTab.vue b/frontend-vue/src/pages/brand/components/BrandAppearancePatentTab.vue
index 65e2907f7..ef3e6737c 100644
--- a/frontend-vue/src/pages/brand/components/BrandAppearancePatentTab.vue
+++ b/frontend-vue/src/pages/brand/components/BrandAppearancePatentTab.vue
@@ -53,6 +53,8 @@
{{ pendingResultHint(itemSource(item)) }}
+
diff --git a/frontend-vue/tests/appearance-patent-current-task-download.test.ts b/frontend-vue/tests/appearance-patent-current-task-download.test.ts
new file mode 100644
index 000000000..f5cc7a76d
--- /dev/null
+++ b/frontend-vue/tests/appearance-patent-current-task-download.test.ts
@@ -0,0 +1,64 @@
+/**
+ * 「当前任务」那一行必须有下载入口的用例(2026-10-24 现网)。
+ *
+ * 症状:外观专利任务的结果文件已经生成(result_file_url 非空),用户在「当前任务」卡片上
+ * 仍然点不到下载——因为 `#item-actions` 里只挂了「删除」,下载只在 `#history-item-actions`。
+ * 用户因此以为"失败了不能下载",实际是这一格入口缺失(另一格是后端补检期间故意不出表,
+ * 那条判据见 result-build-failed-when-downloadable.test.ts,两件事别混)。
+ *
+ * 判据与历史区共用同一个 canDownload:只看文件到没到,不看任务状态。
+ *
+ * 跑法:`node --test tests/appearance-patent-current-task-download.test.ts`
+ */
+import { test } from 'node:test'
+import assert from 'node:assert/strict'
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { resolve, dirname } from 'node:path'
+
+const here = dirname(fileURLToPath(import.meta.url))
+const tabSource = readFileSync(
+ resolve(here, '../src/pages/brand/components/BrandAppearancePatentTab.vue'),
+ 'utf-8',
+)
+
+function slot(name: string): string {
+ const match = tabSource.match(
+ new RegExp(`([\\s\\S]*?)`),
+ )
+ assert.ok(match, `找不到 #${name} 插槽`)
+ return match[1]
+}
+
+test('当前任务区必须有下载按钮', () => {
+ const current = slot('item-actions')
+ assert.match(
+ current,
+ /v-if="canDownload\(itemSource\(item\)\)"[^>]*>\s*下载\s*<\/button>/,
+ '「当前任务」那一行要按 canDownload 出下载按钮,不能只有删除',
+ )
+})
+
+test('当前任务与历史区的下载判据必须是同一个', () => {
+ const current = slot('item-actions')
+ const history = slot('history-item-actions')
+ assert.equal(
+ /canDownload\(itemSource\(item\)\)/.test(current),
+ /canDownload\(itemSource\(item\)\)/.test(history),
+ '两处都得到判据;判据不一致等于同一枚任务在两个位置说法不同',
+ )
+ assert.match(current, /deleteTaskRecord\(itemSource\(item\)\)/, '删除按钮不能顺手丢掉')
+})
+
+test('下载判据只看文件,不看任务状态', () => {
+ const match = tabSource.match(/function canDownload\([\s\S]*?\n\}/)
+ assert.ok(match, '找不到 canDownload')
+ const body = match[0]
+ assert.match(body, /item\.resultId/, '没有结果行就不该给下载')
+ assert.match(body, /item\.fileReady \|\| item\.downloadUrl/, '文件到了才给下载')
+ assert.doesNotMatch(
+ body,
+ /taskStatus|fileStatus|FAILED/,
+ '判据里出现任务状态就是回归:失败态同样要能下载已生成的文件',
+ )
+})