Files
admin-web/src/modules/audit/presentation.test.ts
T

30 lines
1.5 KiB
TypeScript
Raw Normal View History

2026-08-17 19:52:04 +08:00
import { describe, expect, it } from 'vitest'
2026-08-18 09:46:34 +08:00
import { auditDescriptionLabel, auditEventLabel, auditHttpMethodLabel, auditOperatorLabel, auditResourceLabel, auditServiceLabel } from './presentation'
2026-08-17 19:52:04 +08:00
describe('audit event presentation', () => {
it('uses customer-facing labels for known event codes', () => {
expect(auditEventLabel('PLATFORM_TENANT_UPDATE')).toBe('编辑客户档案')
expect(auditEventLabel('TENANT_REVIEW')).toBe('客户入驻审核')
2026-08-18 09:46:34 +08:00
expect(auditEventLabel('INBOUND_MEASURE_APPROVE')).toBe('入库测量审核通过')
expect(auditEventLabel('INBOUND_WEIGHT_OCR_CONFIRM')).toBe('确认 OCR 重量')
2026-08-17 19:52:04 +08:00
})
2026-08-18 09:46:34 +08:00
it('uses a Chinese fallback instead of exposing an unknown technical code', () => {
expect(auditEventLabel('INBOUND_CARTON_CREATE')).toBe('入库箱码创建')
expect(auditEventLabel('FUTURE_CUSTOMER_EVENT')).toBe('客户')
2026-08-17 19:52:04 +08:00
expect(auditEventLabel('')).toBe('—')
})
2026-08-18 09:46:34 +08:00
it('localizes service, resource, operator and request method values', () => {
expect(auditServiceLabel('firstleg-service')).toBe('头程履约服务')
expect(auditResourceLabel('INBOUND_MEASUREMENT')).toBe('入库测量')
expect(auditOperatorLabel('platform_admin')).toBe('平台管理员')
expect(auditHttpMethodLabel('POST')).toBe('提交')
})
it('prefers the Chinese half of a bilingual audit description', () => {
expect(auditDescriptionLabel('Approve order / 审核通过')).toBe('审核通过')
expect(auditDescriptionLabel('测量审核通过')).toBe('测量审核通过')
})
2026-08-17 19:52:04 +08:00
})