Files
KArtSell.Aegis/docs/Design/kbx-foundation-v52-fe-operational-navigation-screen-anatomy/tests/unit/wms-safe-retry.contract.spec.ts
T
kjh2064 c41e5063b7 chore: remove kbx-foundation-v36 reference (superseded by v4 implementation)
Removed entire kbx-foundation-v36 directory as it's been replaced by
the new KBX Foundation v4 patterns implemented in this session:
- Registry-driven screen definitions
- Density-aware UI adapter components
- Feature module templates (ShadowRun, Models)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-08-12 01:39:58 +09:00

34 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import type { KbxWmsScanCommand } from '@kbx/contracts'
function replayOrder(commands: KbxWmsScanCommand[]) {
// Scanner commands are sequence-sensitive and must never be parallelized.
return [...commands].sort((a, b) => a.occurredAt.localeCompare(b.occurredAt))
}
describe('WMS scanner retry contract', () => {
it('preserves the same idempotency key across transport retry', () => {
const command: KbxWmsScanCommand = {
taskId: 'task-1',
barcode: 'LOC-A-01',
source: 'keyboard-wedge',
idempotencyKey: 'task-1:abc',
expectedVersion: 7,
occurredAt: '2026-08-08T07:00:00Z',
}
const retried = { ...command }
expect(retried.idempotencyKey).toBe(command.idempotencyKey)
})
it('replays sequential scans in occurrence order', () => {
const make = (key: string, occurredAt: string): KbxWmsScanCommand => ({
taskId: 'task-1', barcode: key, source: 'keyboard-wedge', idempotencyKey: key,
expectedVersion: 7, occurredAt,
})
expect(replayOrder([
make('B', '2026-08-08T07:00:02Z'),
make('A', '2026-08-08T07:00:01Z'),
]).map(x => x.idempotencyKey)).toEqual(['A', 'B'])
})
})