From 51f4c974891b91716f40a705e0c8b06b2a40c8cf Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Tue, 18 Aug 2026 00:27:14 +0800 Subject: [PATCH] fix(bom-costing): align completed history status --- .../BomCostingWorkbenchClient.test.tsx | 24 +++++++++++++++++++ .../bom-costing/BomCostingWorkbenchClient.tsx | 7 +++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/furniture-3d-system/src/app/bom-costing/BomCostingWorkbenchClient.test.tsx b/furniture-3d-system/src/app/bom-costing/BomCostingWorkbenchClient.test.tsx index ef36486f..d22a9195 100644 --- a/furniture-3d-system/src/app/bom-costing/BomCostingWorkbenchClient.test.tsx +++ b/furniture-3d-system/src/app/bom-costing/BomCostingWorkbenchClient.test.tsx @@ -1,13 +1,37 @@ import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react' import BomCostingWorkbenchClient, { formatBomCategorySkillVersionHint, + getHistoryStatusDotClass, + getHistoryStatusLabel, } from './BomCostingWorkbenchClient' +import type { BomCostingCaseSummary } from '@/lib/bom-costing/client-types' jest.mock('@/components/platform/AssetWorkbenchEmptyBackdrop', () => ({ AssetWorkbenchEmptyBackdrop: () =>
, })) describe('BomCostingWorkbenchClient', () => { + it('整件预估完成但结构待复核时,历史状态点仍表示完成', () => { + const item: BomCostingCaseSummary = { + id: 'case-structure-review', + title: '结构待复核但预估完成的案例', + status: 'READY', + progress: 100, + statusMessage: '整件预估已生成,结构差异待复核', + needsPriceReview: true, + sourceCacheHit: true, + storedImageCount: 79, + failedImageCount: 0, + createdById: 'user-1', + createdAt: '2026-08-18T00:00:00.000Z', + skuCount: 15, + estimatedCostRange: { min: 432.9, max: 930.38 }, + } + + expect(getHistoryStatusLabel(item)).toBe('预估完成(结构待复核)') + expect(getHistoryStatusDotClass(item)).toBe('bg-[#3f8a68]') + }) + it('旧结果 Skill 与当前版本不同时分别标明,且不把旧结果冒充为新版本', () => { expect(formatBomCategorySkillVersionHint({ resultVersion: 'bom-category-skill/cabinet-bookshelf/v1', diff --git a/furniture-3d-system/src/app/bom-costing/BomCostingWorkbenchClient.tsx b/furniture-3d-system/src/app/bom-costing/BomCostingWorkbenchClient.tsx index 401e5e1b..210d1ccb 100644 --- a/furniture-3d-system/src/app/bom-costing/BomCostingWorkbenchClient.tsx +++ b/furniture-3d-system/src/app/bom-costing/BomCostingWorkbenchClient.tsx @@ -129,7 +129,7 @@ const STATUS_DOT_CLASSES: Record = { FAILED: 'bg-[#b6534e]', } -function getHistoryStatusLabel(item: BomCostingCaseSummary) { +export function getHistoryStatusLabel(item: BomCostingCaseSummary) { if (item.status !== 'READY') return STATUS_LABELS[item.status] if (item.requiresRecalculation) return '旧规则结果' if (item.hasFailedRecalculation) return '重算失败' @@ -137,17 +137,16 @@ function getHistoryStatusLabel(item: BomCostingCaseSummary) { (item.dynamicCostingSummary?.failedSkuCount ?? 0) > 0 || (item.dynamicCostingSummary?.pendingSkuCount ?? 0) > 0 ) return '部分完成' - if (item.needsPriceReview) return '待复核' + if (item.needsPriceReview) return '预估完成(结构待复核)' return STATUS_LABELS[item.status] } -function getHistoryStatusDotClass(item: BomCostingCaseSummary) { +export function getHistoryStatusDotClass(item: BomCostingCaseSummary) { if ( item.status === 'READY' && ( item.requiresRecalculation || item.hasFailedRecalculation || - item.needsPriceReview || (item.dynamicCostingSummary?.failedSkuCount ?? 0) > 0 || (item.dynamicCostingSummary?.pendingSkuCount ?? 0) > 0 )