import { describe, expect, it } from 'vitest' import type { KbxConflictSnapshot, KbxOperationRun, KbxRuntimeNotice } from '@kbx/contracts' describe('KBX runtime contract', () => { it('distinguishes degraded mode from normal business state', () => { const notice: KbxRuntimeNotice = { mode: 'degraded', title: '택배 연계 지연', retryAllowed: true } expect(notice.mode).toBe('degraded') }) it('keeps concurrency conflict explicit instead of silent overwrite', () => { const conflict: KbxConflictSnapshot = { code: 'ORDER_VERSION_CONFLICT', title: '다른 사용자가 변경했습니다.', requestedVersion: 3, currentVersion: 4, changes: [{ field: 'quantity', label: '수량', mine: 10, latest: 8 }], } expect(conflict.currentVersion).toBeGreaterThan(conflict.requestedVersion!) }) it('can represent partial completion without reporting full success', () => { const run: KbxOperationRun = { id: 'op-1', type: 'bulk-ship', title: '대량 출고지시', status: 'partially-completed', requestedAt: new Date().toISOString(), total: 100, processed: 100, succeeded: 97, failed: 3, } expect(run.status).toBe('partially-completed') expect(run.failed).toBe(3) }) })