feat(selfop): add volume ranking and refine turnover presentation
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { turnoverChart, turnoverNumber, windowText, turnoverReasonsText, volumeNote } from './turnoverPresentation'
|
||||
import { turnoverChart, turnoverNumber, volumeText, windowText, turnoverReasonsText, volumeNote } from './turnoverPresentation'
|
||||
import type { TurnoverCharts, TurnoverWindowMetric } from './turnoverTypes'
|
||||
describe('turnover honest precision and charts', () => {
|
||||
it('keeps unknown volume distinct from zero and labels historical volume as estimated', () => {
|
||||
@@ -19,10 +19,14 @@ describe('turnover honest precision and charts', () => {
|
||||
expect(turnoverNumber(0.000001)).toBe('<0.01')
|
||||
expect(turnoverNumber(0.01, 1)).toBe('<0.1')
|
||||
expect(turnoverNumber(0)).toBe('0'); expect(turnoverNumber(null)).toBe('—')
|
||||
expect(volumeText(1.25)).toBe('1.25 m³')
|
||||
expect(volumeText(0)).toBe('0 m³')
|
||||
expect(volumeText(null)).toBe('—')
|
||||
expect(volumeText(0.0000000001, 9)).toBe('<0.000000001 m³')
|
||||
})
|
||||
it('does not draw partial-window totals as daily averages or zero bars', () => {
|
||||
const partial: TurnoverWindowMetric = { days: 15, startDate: '2026-09-28', endDateExclusive: '2026-10-13', dataStatus: 'PARTIAL', observedQuantity: 150, outboundQuantity: null, averageDailyOutboundQuantity: null, completeDayCount: 7, partialDayCount: 1, unknownDayCount: 7, reasonCodes: [] }
|
||||
const charts: TurnoverCharts = { ownerPhysicalTop: [], unknownOwnerCount: 0, averageDaily: [{ ...partial, days: 7, dataStatus: 'COMPLETE', averageDailyOutboundQuantity: 10 }, partial] }
|
||||
const charts: TurnoverCharts = { ownerPhysicalTop: [], unknownOwnerCount: 0, ownerVolumeTop: [], unknownVolumeOwnerCount: 0, averageDaily: [{ ...partial, days: 7, dataStatus: 'COMPLETE', averageDailyOutboundQuantity: 10 }, partial] }
|
||||
const option = turnoverChart(charts, 'daily')
|
||||
const tooltip = option.tooltip as { valueFormatter: (value: number | null) => string }
|
||||
expect(tooltip.valueFormatter(2165.133333)).toBe('2,165.13 件/日')
|
||||
|
||||
Reference in New Issue
Block a user