# Post-install smoke test (run on Windows after SirayaPrinterSetup.exe).
$ErrorActionPreference = "Stop"

$healthUrl = "http://127.0.0.1:5000/health"
$maxWaitSec = 60
$deadline = (Get-Date).AddSeconds($maxWaitSec)

Write-Host "Waiting for print agent at $healthUrl ..."
do {
  try {
    $r = Invoke-WebRequest -Uri $healthUrl -UseBasicParsing -TimeoutSec 3
    if ($r.StatusCode -eq 200) {
      Write-Host "OK: $($r.Content)"
      exit 0
    }
  } catch {
    Start-Sleep -Seconds 2
  }
} while ((Get-Date) -lt $deadline)

Write-Host "FAIL: agent did not respond within ${maxWaitSec}s"
exit 1
