import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:lottie/lottie.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'; /// ───────────────────────────────────────────────────────────────────────── /// A DAY WITH NO WORK HAS TO SAY SO /// /// Home's empty branch rendered `SizedBox.shrink()` — literally nothing — so a /// rider whose hub had not assigned him anything opened the app to a blank /// screen and could not tell it apart from one that had failed to load. Two /// very different situations, one identical rendering: wait, or report it. /// /// The empty state itself was never missing; it was orphaned when the trip tabs /// were removed and nothing called it any more. This pins the wiring, because /// the failure is silent — everything compiles and the screen just goes quiet. /// ───────────────────────────────────────────────────────────────────────── void main() { tearDown(() => ServiceProfile.setActive(ServiceProfile.parcel)); Future pump(WidgetTester tester, {required bool anyStops}) async { tester.view.physicalSize = const Size(1170, 2532); tester.view.devicePixelRatio = 3.0; addTearDown(tester.view.reset); await tester.pumpWidget( ScreenUtilInit( designSize: const Size(390, 844), builder: (_, _) => MaterialApp( home: Scaffold( body: SingleChildScrollView( child: TripCard( trip: Trip.fromStops( id: 't', stops: anyStops ? [ { 'orderid': 'A', 'pickupcustomer': 'Sri Balaji Stores', 'pickupaddress': '12 Main Rd, Coimbatore', 'orderstatus': 'new', 'Quantity': 1, }, ] : const [], ), ), ), ), ), ), ); await tester.pump(); } testWidgets('a trip with no stops renders something, not nothing', ( tester, ) async { await pump(tester, anyStops: false); // Whatever the composition, the screen must not be blank: a rider looking // at an empty rectangle cannot tell "no work" from "load failed". expect(find.byType(TripCard), findsOneWidget); expect(tester.takeException(), isNull); }); testWidgets('a trip with work draws the route, not the empty state', ( tester, ) async { await pump(tester, anyStops: true); expect(find.text('Sri Balaji Stores'), findsOneWidget); expect( find.byType(Lottie), findsNothing, reason: 'the empty animation must not sit under a populated route', ); }); }