import { describe, it, expect } from "vitest"; import type { UpdateSnapshot, ExecutionResult } from "./types.js"; describe("rétro-compatibilité des contrats", () => { it("un snapshot jalon 1 (sans blocs optionnels) reste valide", () => { const snap: UpdateSnapshot = { machineId: "m1", hostname: "h", os: { family: "debian", version: "12" }, checkedAt: "2026-06-05T10:00:00Z", status: "ok", apt: { enabled: true, count: 0, rebootRequired: false, packages: [] }, }; expect(snap.apt.count).toBe(0); }); it("une exécution jalon 1 (mode manual, sans blocs) reste valide", () => { const exec: ExecutionResult = { executionId: "e1", machineId: "m1", startedAt: "a", finishedAt: "b", mode: "manual", action: "apt_full_upgrade", status: "ok", rebootRequiredAfterRun: false, importantLogLines: [], rawLogRef: "r", reportRef: "rr", }; expect(exec.action).toBe("apt_full_upgrade"); }); it("accepte les nouveaux blocs optionnels", () => { const snap: UpdateSnapshot = { machineId: "m1", hostname: "h", os: { family: "proxmox", version: "8" }, checkedAt: "t", status: "updates_available", apt: { enabled: true, count: 1, rebootRequired: false, packages: [], status: "updates_available" }, schemaVersion: 1, kind: "apt_update_analyze", machineKind: "proxmox_host", docker: { enabled: false, installed: false, count: 0, stacks: [] }, errors: [], }; expect(snap.docker?.installed).toBe(false); }); });