feat(printer): badge print queue, Pi worker, captive-portal setup, admin printing view

- migration 20261018170000: pgmq badge_print/badge_print_dlq, print_stations,
  token-gated printer RPCs (claim/complete/fail/heartbeat), admin RPCs,
  welcome_checkin enqueue; badge_print_tests.sql (101 assertions)
- apps/printer: Python worker (Playwright render -> brother_ql via pyusb),
  comitup captive-portal (Wi-Fi + HTTPS endpoint + anon key + token),
  arm64 image build + idempotent Pi setup/install scripts, 77 pytest
- apps/admin: Printing view, station management/DLQ, global printer status
  pill, Print button on Registrations, standalone print renderer entry
  (print.html -> dist-print) with bundled fonts
- docs: printing.md + architecture/schema/rpcs/tests/admin-app updates,
  apps/printer/AGENT.md operating manual
- e2e: printing.spec.ts

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-10-18 22:25:38 +02:00
1 parent 0f3720d48a
commit 00c89c1b48
55 files changed
+7406 -29

No files matched your search

+110
View File
@@ -0,0 +1,110 @@
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
import pytest # noqa: E402
from PIL import Image # noqa: E402
from worker.config import Config # noqa: E402
@pytest.fixture
def cfg() -> Config:
return Config(
convivo_url="http://localhost:54321",
convivo_anon_key="anon-key",
station_token="cvp_test_token",
station_name="Test desk",
dry_run=True,
status_labels=True,
wait_seconds=0,
network_state_file="/nonexistent/network.json",
app_version="test",
)
class FakePrinter:
def __init__(self, ready=True, label_id="103x164", errors=None):
self.ready = ready
self.label_id = label_id
self.errors = errors or []
self.printed: list[tuple[Image.Image, str]] = []
self.print_result = {"did_print": True, "outcome": "printed"}
def get_status(self):
return {
"connected": True,
"model": "QL-1100NWB",
"ready": self.ready and not self.errors,
"media_type": "die-cut",
"label_id": self.label_id,
"media_width_mm": 104,
"media_length_mm": 164,
"errors": list(self.errors),
}
def print_image(self, img, label_id):
self.printed.append((img, label_id))
return dict(self.print_result)
class FakeRenderer:
def __init__(self, image=None, error=None):
self.image = image or Image.new("RGB", (1181, 827), "white")
self.error = error
self.calls: list[tuple[dict, str]] = []
self.closed = False
def render(self, payload, checkin_origin):
self.calls.append((payload, checkin_origin))
if self.error:
raise self.error
return self.image
def close(self):
self.closed = True
class FakeRpc:
def __init__(self, claim_rows=None, claim_error=None, complete_error=None, heartbeat_name="Test desk"):
self.claim_rows = list(claim_rows or [])
self.claim_error = claim_error
self.complete_error = complete_error
self.heartbeat_name = heartbeat_name
self.claims = 0
self.completed: list[int] = []
self.failed: list[tuple[int, str, bool]] = []
self.heartbeats: list[dict] = []
self.heartbeat_error = None
def claim(self, wait_seconds):
self.claims += 1
if self.claim_error:
err, self.claim_error = self.claim_error, None
raise err
return list(self.claim_rows)
def complete(self, msg_id):
if self.complete_error:
err, self.complete_error = self.complete_error, None
raise err
self.completed.append(msg_id)
return True
def fail(self, msg_id, error, retryable=False):
self.failed.append((msg_id, error, retryable))
return "retry" if retryable else "dead_letter"
def heartbeat(self, status):
if self.heartbeat_error:
raise self.heartbeat_error
self.heartbeats.append(status)
return {"station_id": "x", "name": self.heartbeat_name}
def close(self):
pass