import assert from "node:assert/strict"
import { shouldAllowRecoveryByPolicy } from "./state-machine.js"

const recoveryHit = {
  ruleId: "r",
  ruleName: "r",
  severity: "warning" as const,
  message: "восстановился",
  transition: "recovery" as const,
  payloadHash: "h1",
}

const problemHit = {
  ...recoveryHit,
  transition: "problem" as const,
}

assert.equal(shouldAllowRecoveryByPolicy(recoveryHit, "always"), true)
assert.equal(shouldAllowRecoveryByPolicy(recoveryHit, "conditional"), true)
assert.equal(shouldAllowRecoveryByPolicy(recoveryHit, "never"), false)
assert.equal(shouldAllowRecoveryByPolicy(problemHit, "never"), true)

console.log("alert-engine state-machine tests ok")
