fix(detail): 指标区间值不再被拼成一个数(DEF-06/07)
`3-6个月` 被渲染成 `36`:两处独立实现都用了 `value.replace(/[^0-9.]/g, '')`,把区间符号与单位一起丢掉。 `metric-value.ts` 的 `parseMetricValue` 在 P4-B4 就已入库, 但**从未被任何组件调用** —— check:dead 实测把它判成「仅测试引用」。 接线到两处:`MetricCard`(detail-product-value)与 `AnimatedCounter`(detail-trust-section)。同时给 ProductValueSection 加 `showDataProofs`,V3 页据此关掉重复的一组 dataProofs (该页下方 DetailTrustSection 已渲染同一组指标)。 判别性测试(各自负对照已做): - 区间值 `3-6个月` 不得出现 `36`;只回退 MetricCard ⇒ 仅该例红 - `3–6 个月`(en dash + 空格)同理;只回退 AnimatedCounter ⇒ 仅该例红 - showDataProofs=false 整块不渲染 代价:V3 页去掉重复指标块后页高 5663px → 5078px, 视觉基线 5 张随之重采(另有 100 张见后续提交)。
This commit is contained in:
1 parent
a34bd35d8e
commit
c9b9c886d1
4 files changed
+53
-14
No files matched your search
@@ -314,6 +314,38 @@ describe('ProductValueSection', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// ── DEF-06/07:区间/多数字指标不得被拼成一个数 ──
|
||||
describe('指标计数动画的取值解析(DEF-06/07)', () => {
|
||||
it('区间值 `3-6个月` 不被渲染成 `36`', async () => {
|
||||
const { ProductValueSection } = await import('./detail-product-value');
|
||||
const rangeProduct = {
|
||||
...mockProduct,
|
||||
dataProofs: [{ metric: '实施周期', value: '3-6个月', description: '典型交付周期' }],
|
||||
};
|
||||
render(<ProductValueSection product={rangeProduct} />);
|
||||
// 旧实现 `value.replace(/[^0-9.]/g,'')` ⇒ 36,`-` 与 `个月` 被丢掉
|
||||
expect(screen.queryByText('36')).not.toBeInTheDocument();
|
||||
expect(screen.getByText(/3-6个月/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('DetailTrustSection 的计数器同样不把 `3–6 个月` 拼成 `36`', async () => {
|
||||
const { DetailTrustSection } = await import('./detail-trust-section');
|
||||
render(
|
||||
<DetailTrustSection
|
||||
dataProofs={[{ metric: '交付周期', value: '3–6 个月', description: '典型周期' }]}
|
||||
/>
|
||||
);
|
||||
expect(screen.queryByText('36')).not.toBeInTheDocument();
|
||||
expect(screen.getByText(/3–6 个月/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('showDataProofs=false 时整块不渲染(V3 去重)', async () => {
|
||||
const { ProductValueSection } = await import('./detail-product-value');
|
||||
render(<ProductValueSection product={mockProduct} showDataProofs={false} />);
|
||||
expect(screen.queryByText('以可量化的目标约束交付')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('DetailTrustSection', () => {
|
||||
|
||||
Reference in new issue
Block a user