import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:miler/data/service_profile.dart'; import 'package:miler/views/Dashboard/home/trip.dart'; import 'package:miler/views/Dashboard/home/trip_card.dart'; /// The stop being worked lives in the trip list, not on a floating strip. /// /// Home used to hide an active parcel stop from its own route and announce it /// instead with a red "Active Pickup" banner pinned over the bottom of the /// page — which covered the last card, said less than the row would have, and /// whose tap only refetched the queue. These tests are the two halves of that /// being one thing now: the row shows, and the row is the way in. void main() { TestWidgetsFlutterBinding.ensureInitialized(); tearDown(() => ServiceProfile.setActive(ServiceProfile.parcel)); Map stop({required String id, required String status}) => { 'orderid': id, 'step': 1, 'pickupcustomer': 'Customer $id', 'pickupaddress': '1 Main Road, RS Puram', 'orderstatus': status, 'type': 'pickup', 'pickuplat': 13.08, 'pickuplon': 80.21, }; Future pumpRow( WidgetTester tester, { required String status, void Function(Map)? onContinue, }) async { tester.view.physicalSize = const Size(1080, 2400); tester.view.devicePixelRatio = 3.0; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); final trip = Trip.fromStops( id: 't', stops: [stop(id: '1', status: status)], ); await tester.pumpWidget( ScreenUtilInit( designSize: const Size(390, 844), builder: (_, _) => MaterialApp( home: Scaffold( body: SingleChildScrollView( child: TripCard( trip: trip, onToggleSelect: (_) {}, onContinueStop: onContinue, ).buildStops(), ), ), ), ), ); await tester.pump(const Duration(milliseconds: 300)); } testWidgets('a parcel stop under way stays on Home, marked Active', ( tester, ) async { ServiceProfile.setActive(ServiceProfile.parcel); await pumpRow(tester, status: 'active', onContinue: (_) {}); // It used to be filtered out of the list entirely on this tenant. expect(find.text('Customer 1'), findsOneWidget); expect(find.text('Active'), findsOneWidget); }); testWidgets('the live row carries the way back into the stop', ( tester, ) async { ServiceProfile.setActive(ServiceProfile.parcel); Map? continued; await pumpRow(tester, status: 'active', onContinue: (s) => continued = s); // Not "finish it in Bookings" beside a banner that was the only real way // through: the row he is looking at is the control. expect(find.text('In progress — finish it in Bookings'), findsNothing); // The control is an icon in the card's action cluster now — labelled, so // it is found the way a screen reader finds it rather than by its glyph. await tester.tap(find.bySemanticsLabel('Continue this stop')); await tester.pump(); expect(continued?['orderid'], '1'); }); testWidgets('with nowhere to continue to, the row states its state', ( tester, ) async { ServiceProfile.setActive(ServiceProfile.parcel); await pumpRow(tester, status: 'active'); expect(find.bySemanticsLabel('Continue this stop'), findsNothing); expect(find.text('In progress — finish it in Bookings'), findsOneWidget); }); testWidgets('a service run marks its live stop the same way', (tester) async { ServiceProfile.setActive(ServiceProfile.meals); await pumpRow(tester, status: 'active', onContinue: (_) {}); expect(find.text('Customer 1'), findsOneWidget); expect(find.text('Active'), findsOneWidget); }); testWidgets('an accepted parcel stop still leaves Home for Bookings', ( tester, ) async { // The handoff rule is untouched — only the *active* state moved. ServiceProfile.setActive(ServiceProfile.parcel); await pumpRow(tester, status: 'accepted', onContinue: (_) {}); expect(find.text('Customer 1'), findsNothing); expect(find.text('Active'), findsNothing); }); }