fix(price-track): 失败任务的色块不再被"这一店已出结果"顶成绿色
跟价历史行的颜色取 item.success(服务端 biz_file_result.success),文案取任务状态: 32889 跑到第 53/54 页掉登录时结果行已置 success=1、任务是 FAILED,同屏出现"绿点 + 失败"。 现在 FAILED 先判红,与文案同一口径;下载按钮不受影响,部分结果照常可下。 守卫用例含反向自证,并钉住"改红不许顺手封掉 FAILED 行的下载口"。
This commit is contained in:
@@ -1664,8 +1664,13 @@ function statusText(item: PriceTrackHistoryItem) {
|
||||
|
||||
function statusClass(item: PriceTrackHistoryItem) {
|
||||
const st = resolvedTaskStatus(item)
|
||||
// 色块与文案必须同一口径:任务判死就是红。`item.success` 是**这一店铺的结果行**成功
|
||||
// (biz_file_result.success=1),跟价跑到第 53/54 页掉登录时,行里既已出了部分结果文件、
|
||||
// 任务又是 FAILED——旧写法先认 `item.success` 就画成绿点,现网 32889 就是"绿点 + 失败"
|
||||
// 同屏(2026-10-30 用户点名)。下载按钮不受这里影响,仍由 canDownload 放行部分结果。
|
||||
if (st === 'FAILED') return taskStatusClass('FAILED')
|
||||
if (st === 'SUCCESS' || item.success) return taskStatusClass('SUCCESS')
|
||||
// 其余(FAILED/未知状态)保持原实现:failed / running
|
||||
// 其余(未知状态)保持原实现:running
|
||||
return taskStatusClass(st, { classMap: { CANCELLED: 'running' }, classFallback: 'running' })
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
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'
|
||||
import { taskStatusClass } from '../src/shared/utils/task-status-text.ts'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const tabSource = readFileSync(
|
||||
resolve(here, '../src/pages/brand/components/BrandPriceTrackTab.vue'),
|
||||
'utf-8',
|
||||
)
|
||||
|
||||
function functionBody(name: string): string {
|
||||
const match = tabSource.match(new RegExp(`function ${name}\\([\\s\\S]*?\\n\\}`))
|
||||
assert.ok(match, `找不到函数 ${name}`)
|
||||
return match[0]
|
||||
}
|
||||
|
||||
/** 只留代码行:注释里会出现 "item.success" 这类字面量,不剥掉的话顺序判据抓的是注释。 */
|
||||
function codeOnly(name: string): string {
|
||||
return functionBody(name)
|
||||
.split('\n')
|
||||
.filter((line) => !line.trim().startsWith('//'))
|
||||
.join('\n')
|
||||
}
|
||||
|
||||
// 跟价历史行的色块读的是**结果行**的 success(biz_file_result.success=1),
|
||||
// 而文案读的是任务状态。任务判死时结果行往往已经出了部分文件(现网 32889:
|
||||
// 跟到第 53/54 页掉登录,陈先锋.xlsx 已生成、任务是 FAILED),旧写法先认
|
||||
// `item.success` ⇒ 绿点配"失败"文案,同一格说谎(2026-10-30 用户点名)。
|
||||
test('test_failed_class_wins_over_row_success', () => {
|
||||
const body = codeOnly('statusClass')
|
||||
const failedIdx = body.indexOf("=== 'FAILED'")
|
||||
const successShortcutIdx = body.indexOf('item.success')
|
||||
assert.ok(failedIdx >= 0, 'statusClass 缺少 FAILED 分支')
|
||||
assert.ok(successShortcutIdx >= 0, 'statusClass 不再引用 item.success:判据要看的是两者先后')
|
||||
assert.ok(failedIdx < successShortcutIdx, 'FAILED 必须先于 item.success 判为 failed 样式')
|
||||
assert.match(body, /taskStatusClass\('FAILED'\)/, 'FAILED 样式必须由公共映射产出')
|
||||
assert.equal(taskStatusClass('FAILED'), 'failed', '公共映射里 FAILED 应产出 failed 样式')
|
||||
})
|
||||
|
||||
test('test_color_guard_is_not_vacuous', () => {
|
||||
// 反向自证:抹掉 FAILED 那条早退,顺序判据必须立刻判红(否则上面那条可能是空的)
|
||||
const body = functionBody('statusClass').replace(/if \(st === 'FAILED'\)[\s\S]*?\n/, '')
|
||||
const failedIdx = body.indexOf("=== 'FAILED'")
|
||||
const successShortcutIdx = body.indexOf('item.success')
|
||||
assert.ok(failedIdx === -1 || failedIdx > successShortcutIdx, '抹掉 FAILED 早退仍判得过 ⇒ 色块判据是恒真的')
|
||||
})
|
||||
|
||||
test('test_failed_row_keeps_download_button', () => {
|
||||
// 颜色改红不许顺手把部分结果的下载口封掉:这是"起码失败了也可以下载"的既有口径
|
||||
const body = functionBody('canDownload')
|
||||
assert.match(body, /st === 'FAILED'/, 'FAILED 行必须仍可下载已跑出来的部分结果')
|
||||
})
|
||||
Reference in New Issue
Block a user