refactor(domain): 标注 SoH 来源语义
This commit is contained in:
@@ -44,14 +44,17 @@ describe('battery domain', () => {
|
||||
expect(response.total).toBe(items.length)
|
||||
expect(response.lowPower).toBe(1)
|
||||
expect(response.charging).toBe(1)
|
||||
expect(response.nextCursor).toBeNull()
|
||||
expect(response.items[0]?.createTime).toBe('2026-05-10T23:00:00.000Z')
|
||||
})
|
||||
|
||||
test('creates old dashboard aggregate shape from deterministic records', () => {
|
||||
test('creates dashboard aggregate shape without using power as fake SOH', () => {
|
||||
const now = new Date('2026-05-11T00:00:00.000Z')
|
||||
const snapshot = createDashboardSnapshot(rows.map(toBatteryInfo), now)
|
||||
|
||||
expect(snapshot.devices).toHaveLength(2)
|
||||
expect(snapshot.devices.every((device) => device.sohSource === 'unavailable')).toBe(true)
|
||||
expect(snapshot.devices.every((device) => device.soh === 0)).toBe(true)
|
||||
expect(snapshot.soh.history).toHaveLength(12)
|
||||
expect(snapshot.soh.forecast).toHaveLength(4)
|
||||
expect(snapshot.summary.totalDevices).toBe(snapshot.devices.length)
|
||||
@@ -87,6 +90,7 @@ describe('battery domain', () => {
|
||||
const predicted = snapshot.devices.find((device) => device.id === 'RING-A03')
|
||||
|
||||
expect(predicted?.soh).toBe(60)
|
||||
expect(predicted?.sohSource).toBe('prediction')
|
||||
expect(predicted?.soh30d).toBe(58)
|
||||
expect(predicted?.soh90d).toBe(52)
|
||||
expect(predicted?.status).toBe('预警')
|
||||
|
||||
Reference in New Issue
Block a user