import 'package:flutter_test/flutter_test.dart'; import 'package:miler/Models/stop_status.dart'; import 'package:miler/data/service_profile.dart'; /// ───────────────────────────────────────────────────────────────────────── /// A COLLECTED MILK RUN MUST STILL HAVE CARDS /// /// The Deliveries queue filtered on the raw rung — `!status.isPicked` — while /// the progress rail directly above it read the profile-aware /// [StopStatusX.isWorkComplete]. /// /// On a parcel route the two agree by accident: collection IS the end of that /// job. On a milk run they disagree completely — `picked` is the middle of the /// morning, with fifteen lunches in the rider's hands and none delivered. So /// collecting a crate emptied the card list while the rail kept drawing the /// stop as a node: a rail with work on it and nothing underneath. /// ───────────────────────────────────────────────────────────────────────── void main() { tearDown(() => ServiceProfile.setActive(ServiceProfile.parcel)); /// The queue's filter, as the screen applies it. bool worked(StopStatus s) => !s.isCancelled && !s.isWorkComplete; group('milk run', () { setUp(() => ServiceProfile.setActive(ServiceProfile.milkMan)); test('a collected crate is still work, so it still has a card', () { expect(worked(StopStatus.picked), isTrue); expect(worked(StopStatus.outForDelivery), isTrue); expect(worked(StopStatus.deliveryArrived), isTrue); }); test('and it leaves the queue at the door, not at the kitchen', () { expect(worked(StopStatus.delivered), isFalse); expect(worked(StopStatus.cancelled), isFalse); }); test('the rail and the card list agree at every rung', () { // The bug in one assertion: these two predicates drove the same screen // and disagreed about `picked`. for (final s in StopStatus.values) { expect( worked(s), isNot(s.isWorkComplete), reason: '$s renders a node on the rail but no card, or the reverse', ); } }); }); group('parcel route', () { setUp(() => ServiceProfile.setActive(ServiceProfile.parcel)); test('collection is the end of the job, so the card goes', () { expect(worked(StopStatus.accepted), isTrue); expect(worked(StopStatus.arrived), isTrue); expect(worked(StopStatus.picked), isFalse); }); }); }