feat(brand): 失败任务「重新提交」入口+排队期显示执行方人话文案(3700 客户端半边)
- brand.ts:resubmitBrandTask 走桥 resubmit_brand_task(重跑必须本机客户端建单执行, 线上 15126 无从替用户重跑;老客户端 available=false 提示升级);BrandLocalBridge 登记 桥形状;BrandLineProgressInfo 补 progress_text 与 queued 档注释。 - BrandBrandTab.vue:failed/cancelled 行出「重新提交」按钮(确认框点名沿用策略与通道); 排队期 extraLines 显示 progress_text(已等待 N 秒;同机 M/K 槽在用),countLabel 不再 摆恒 0 的「0/265」——用户从「排队中/0 行」无从分辨排队与卡死。 - pywebview.ts:open_jd_login 注释改按自动链路口径(见下一笔,桥本身零改动)。 - 判据:brand-resubmit-entry.test.ts(桥形状+入口 wiring+源码绊线)+ task-progress-view-wiring.test.ts +排队文案透出绊线+catch-silence 台账 blocks 334→335 (resubmitTask 的 try/catch 有用户可见出口,非静默,silent 与 perFile 未动)。
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { resubmitBrandTask, type BrandLocalBridge } from '../src/shared/api/types/modules/brand.ts'
|
||||
|
||||
function setupWindow() {
|
||||
;(globalThis as Record<string, unknown>).window = {
|
||||
localStorage: { getItem: () => '42' },
|
||||
location: { origin: 'http://localhost' },
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 品牌任务「重新提交」(2026-11-23 任务 3700)。
|
||||
*
|
||||
* <p>3700 排队 120 分钟被判失败后,界面没有任何重跑入口——用户只能重新选文件、重新上传。
|
||||
* 重跑必须由本机客户端建单并执行(线上 15126 无从替用户执行),所以走桥而不是相对地址;
|
||||
* 老客户端没有该方法时必须明确回 available=false,页面据此提示升级,而不是静默失败。
|
||||
*/
|
||||
test('test_brand_resubmit_without_bridge_reports_unavailable', async () => {
|
||||
setupWindow()
|
||||
assert.deepEqual(await resubmitBrandTask(3700), { available: false })
|
||||
assert.deepEqual(await resubmitBrandTask(3700, {} as BrandLocalBridge), { available: false },
|
||||
'桥在但没有 resubmit_brand_task(老客户端)同样要回答不可用')
|
||||
})
|
||||
|
||||
test('test_brand_resubmit_forwards_task_id_and_uid', async () => {
|
||||
setupWindow()
|
||||
const calls: unknown[] = []
|
||||
const bridge: BrandLocalBridge = {
|
||||
resubmit_brand_task: (payload) => {
|
||||
calls.push(payload)
|
||||
return Promise.resolve({ success: true, task_id: 3720 })
|
||||
},
|
||||
}
|
||||
|
||||
const result = await resubmitBrandTask(3700, bridge)
|
||||
|
||||
assert.equal(result.available, true)
|
||||
assert.equal(result.success, true)
|
||||
assert.equal(result.taskId, 3720)
|
||||
assert.deepEqual(calls, [{ taskId: 3700, uid: 42 }],
|
||||
'桥调用要带 uid:本机 Flask 建单要按用户归属,且要校验原单归属')
|
||||
})
|
||||
|
||||
test('test_brand_resubmit_bridge_failure_is_reported', async () => {
|
||||
setupWindow()
|
||||
const bridge: BrandLocalBridge = {
|
||||
resubmit_brand_task: () => Promise.resolve({ success: false, error: '只有失败或已取消的任务可以重新提交' }),
|
||||
}
|
||||
|
||||
const result = await resubmitBrandTask(3700, bridge)
|
||||
|
||||
assert.equal(result.available, true)
|
||||
assert.equal(result.success, false)
|
||||
assert.match(result.error, /只有失败或已取消/)
|
||||
})
|
||||
|
||||
test('test_brand_resubmit_entry_only_for_failed_or_cancelled', () => {
|
||||
const page = readFileSync(
|
||||
join(import.meta.dirname, '..', 'src', 'pages', 'brand', 'components', 'BrandBrandTab.vue'),
|
||||
'utf8',
|
||||
)
|
||||
assert.match(page, /canResubmit/, '历史任务卡必须有重新提交判定')
|
||||
assert.match(page, /status === 'failed' \|\| status === 'cancelled'/, '只对失败/已取消出按钮')
|
||||
assert.match(page, /resubmitBrandTask\(item\.id/, '按钮必须经桥重提,而不是重新上传文件')
|
||||
})
|
||||
@@ -109,7 +109,11 @@ const BASELINE = {
|
||||
// 「已提示任务代」localStorage 读/写各一支 try/catch。读不出一律按「没提示过」处理(return []),
|
||||
// 写不进去就放弃跨页面去重(return,本次挂载仍由内存 Set 挡住重复弹窗)——两支都没有把
|
||||
// 用户可见错误吞掉(弹窗本身不受影响,丢的只是可选优化),silent 一格没涨、perFile 无新增条目。
|
||||
blocks: 334,
|
||||
// 335 = 334 + 1(2026-11-23 品牌任务「重新提交」,任务 3700 复盘):BrandBrandTab.vue 的
|
||||
// resubmitTask 包住重新提交请求——失败 ElMessage.error 当场把服务端文案报给用户、
|
||||
// 成功 ElMessage.success 并刷新看板;确认框的取消走 `error === 'cancel'` 直接 return。
|
||||
// 非静默(块内有用户可见出口),silent 一格没涨、perFile 无新增条目,只进 blocks。
|
||||
blocks: 335,
|
||||
// 2026-10-30(ops Phase 6/可读棘轮):ApiSecretSettingsPanel.vue 1113→775 行,面板里那处
|
||||
// 静默 catch(余额查询失败只 console.warn、界面留空)随 loadBalance 整块搬进
|
||||
// useProxyPlan.ts。不是新增静默:面板 1→0、新文件记 1,silent 总数与 blocks 都一格没动,
|
||||
|
||||
@@ -73,3 +73,19 @@ test('light 白名单与后端 VO 的进度三字段同名同形', () => {
|
||||
assert.ok(polling.includes(`${field}: item.${field} ?? null`), `task-progress-polling.ts 归一时丢了 ${field}`)
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 2026-11-23 任务 3700:品牌单排队 120 分钟后判死,界面全程只有「排队中 / 已处理 0 行」。
|
||||
* 客户端心跳一直带着人话文案(progressText),后端 2026-11-23 起把它透出成 progress_text,
|
||||
* 任务卡必须把它显示出来——否则用户无法分辨「在排队」还是「卡死」。
|
||||
*/
|
||||
test('品牌任务卡必须显示后端透出的排队文案 progress_text', () => {
|
||||
const src = readFileSync(join(COMPONENTS, 'BrandBrandTab.vue'), 'utf8')
|
||||
assert.match(src, /progress_text/, 'BrandBrandTab 必须读取 line_progress.info.progress_text')
|
||||
assert.match(src, /phase === 'queued'/, '排队文案只在 queued 阶段替代行数行')
|
||||
const types = readFileSync(
|
||||
join(import.meta.dirname, '..', 'src', 'shared', 'api', 'types', 'modules', 'brand.ts'),
|
||||
'utf8',
|
||||
)
|
||||
assert.match(types, /progress_text\?: string/, 'BrandLineProgressInfo 必须声明 progress_text')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user