fix(bom-costing): align completed history status
This commit is contained in:
parent
4a8cbcdcb3
commit
51f4c97489
@ -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: () => <div data-testid="empty-backdrop" />,
|
||||
}))
|
||||
|
||||
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',
|
||||
|
||||
@ -129,7 +129,7 @@ const STATUS_DOT_CLASSES: Record<BomCostingCaseSummary['status'], string> = {
|
||||
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
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user