Report health on every transport, not only the broker

A shop configured for the HTTP route uploaded 17 bills correctly today and
never once appeared on the fleet board. Nothing logged it, because from the
terminal's point of view nothing had failed: the reporter was typed against
MqttOrderTransport and started behind an `is MqttOrderTransport` check, so on
HTTP it was silently never constructed. A monitoring feature that quietly does
not exist on one of two supported routes is worse than no feature, because the
blank square reads as "no terminals" rather than "not wired up".

publishHealth moves onto the OrderTransport interface. The broker publishes to
the health topic as before; HTTP posts the same payload to POST /pos/health;
the simulated route does nothing, which is the honest answer for a till with no
back office configured. The reporter is now started for every route.

There was no test for the reporter at all, which is why this shipped. There are
five now, including one that fails on the old code.

Also removes test/widget_test.dart — the stock `flutter create` counter test,
referencing a MyApp that never existed here. It has never compiled and was the
only red in the suite.

263 tests pass, analyzer clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Suriya
2026-08-05 18:28:22 +05:30
parent 6c0266c9c7
commit 353c6c1075
10 changed files with 292 additions and 39 deletions

View File

@@ -5,7 +5,7 @@ import 'dart:io';
import '../../core/config/sync_config.dart';
import '../../domain/repositories/sync_repository.dart';
import '../local/terminal_identity.dart';
import '../remote/mqtt_order_transport.dart';
import '../remote/order_transport.dart';
import 'sync_engine.dart';
/// What a till reports about itself, every 30 seconds.
@@ -26,7 +26,7 @@ import 'sync_engine.dart';
/// till looking alive until something overwrote it.
class HealthReporter {
HealthReporter({
required MqttOrderTransport transport,
required OrderTransport transport,
required TerminalIdentity terminal,
required SyncConfig config,
required SyncEngine engine,
@@ -46,7 +46,7 @@ class HealthReporter {
_now = clock ?? DateTime.now,
_schedule = scheduleTimer ?? Timer.new;
final MqttOrderTransport _transport;
final OrderTransport _transport;
final TerminalIdentity _terminal;
final SyncConfig _config;
final SyncEngine _engine;