test(fix): stop handover widget test hanging on awaited stream .first

The 'giving all with payment and promise' widget test awaited
repo.watchSales().first / watchPlantares().first in its body. A Drift
stream's .first never completes under the widget-test fake-async clock
(pumpAndSettle has already returned, so dart_test.yaml's per-test timeout
can't bound it), so the test hung to the framework's 10-min hard cap.

- Read the recorded sale/plantare with one-shot db.select(...).get()
  queries instead (same filter, resolves fine under fake-async) — the
  suite now passes in ~1s.
- Add a pure-Dart guard test that scans test/ui/ and fails loudly if any
  awaited watchX().first reappears, so this stops being recurrent.
This commit is contained in:
vjrj 2026-07-12 07:54:35 +02:00
parent b22db7d0cb
commit d42ed0df1a
2 changed files with 64 additions and 2 deletions

View file

@ -84,13 +84,21 @@ void main() {
await tester.tap(find.byKey(const Key('handover.save')));
await tester.pumpAndSettle();
final sales = await repo.watchSales().first;
// One-shot .get() reads (NOT watch().first): a Drift stream's `.first`
// never completes under the widget-test fake-async clock, so awaiting it
// in a testWidgets body hangs the whole test to the 10-min hard cap. A
// plain SELECT resolves fine (same as the movements/lot reads below).
final sales = await (db.select(
db.sales,
)..where((s) => s.isDeleted.equals(false))).get();
expect(sales.single.direction, SaleDirection.iSold);
expect(sales.single.amount, 2.5);
expect(sales.single.currency, 'Ğ1');
expect(sales.single.counterparty, 'María');
final plantares = await repo.watchPlantares().first;
final plantares = await (db.select(
db.plantares,
)..where((p) => p.isDeleted.equals(false))).get();
expect(plantares.single.direction, PlantareDirection.owedToMe);
expect(plantares.single.owedDescription, 'un puñado');