Files
admin-web/src/modules/self-operated/components/OwnerOverviewPanel.test.ts
T

25 lines
2.0 KiB
TypeScript

import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import OwnerOverviewPanel from './OwnerOverviewPanel.vue'
import type { OwnerOverview } from '../types'
describe('owner overview calculation window', () => {
it('shows the thirty-day calculation range rather than the longer collected history', () => {
const quantity = { overallTotal: null, knownSubtotal: null, unknownSkuCount: 1, dataStatus: 'UNKNOWN', reasonCodes: [] }
const risk = { matchedSkuCount: null, matchedPhysicalQuantity: null, physicalQuantityRatio: null, knownMatchedSkuCount: null, knownMatchedPhysicalQuantity: null, unassessableSkuCount: 1, unassessableKnownPhysicalQuantity: null, reasonCodes: [] }
const data: OwnerOverview = {
context: { salesRunId: '11', inventoryRunId: '12', salesScopeHash: 'sales', inventoryScopeHash: 'stock', queryAsOf: '2026-10-12T01:00:00Z', queryExpiresAt: '2026-10-12T01:30:00Z', businessTimezone: 'Asia/Shanghai', anchorDate: '2026-10-12', completeDayFrom: '2026-08-13', completeDayUntil: '2026-10-12', rangeStartDate: '2026-09-12', rangeEndDateExclusive: '2026-10-12', salesStatus: 'COMPLETE', inventoryStatus: 'STALE', inventoryObservedFrom: '2026-10-10T00:00:00Z', inventoryObservedUntil: '2026-10-10T00:10:00Z' },
customerCode: 'OWNER-A', customerName: null, skuCount: 1,
physicalSkuCount: quantity, physicalQuantity: quantity, availableQuantity: quantity, frozenQuantity: quantity,
defectivePhysicalQuantity: quantity, transitQuantity: quantity, outboundQuantity30d: quantity,
averageDailyOutboundQuantity: quantity, noOutbound30d: risk, coverageAboveThreshold: risk,
}
const wrapper = mount(OwnerOverviewPanel, { props: { data } })
expect(wrapper.text()).toContain('近30完整日计算区间 2026-09-12 至 2026-10-12')
expect(wrapper.text()).not.toContain('2026-08-13')
expect(wrapper.text()).toContain('销量质量:完整;库存质量:过期')
expect(wrapper.text()).toContain('库存观测时段:2026/10/10 08:00:00 至 2026/10/10 08:10:00')
wrapper.unmount()
})
})