test(devices): Phase 2 — ESC/POS byte stream + printer routing

Pins the device-layer bugs we kept hand-verifying, as pure byte-stream assertions
(no sockets, no hardware):

- printer-escpos.test.ts (12): CP852 codepage select; the ë→0x89 / Ë→0xD3 mapping
  and the em-dash/⚠ ASCII fallbacks (never a stray 0x3f "?"); and the Code128 MODULE
  WIDTH contract — a short ticket id at width 3, but the ~20-char out-of-window
  occurrence id at width 2 so it fits the 80mm head (width 3 overflows ~576 dots and
  the firmware silently aborts the barcode). Plus the QR-and-Code128 dual encoding and
  the Albanian stamp() format.
- printer-routing.test.ts (6): the failover order (booth printer is a fallback for
  entry tickets; a receipt never prints on the outside dispenser), rank-then-id
  tiebreak, and printWithFailover walking the order + NoPrinterAvailableError.

Wires Vitest into @parking/devices. devices 18/18 green.

Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
2026-06-21 16:17:51 +02:00
parent 5e9be16f65
commit 352c643009
6 changed files with 212 additions and 3 deletions
+9
View File
@@ -0,0 +1,9 @@
import { defineConfig } from "vitest/config";
// Device tests are pure byte-stream assertions over the ESC/POS renderers + the
// printer-routing logic — no sockets, no hardware. Run from src (not dist).
export default defineConfig({
test: {
include: ["src/**/*.test.ts"],
},
});