import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:miler/views/Dashboard/home/trip_empty_state.dart'; /// An unfilled trip tab used to render a bordered white card with a grey /// glyph in it — a piece of content that had arrived empty. It is the page /// itself now, so the assertion that matters is that no card comes back: a /// `Container` with a `Border` around the whole state is the thing being /// removed, and a redesign that quietly reintroduces one should fail here. void main() { Future pump( WidgetTester tester, { required bool offline, VoidCallback? onGoOnDuty, }) async { tester.view.physicalSize = const Size(1170, 2532); tester.view.devicePixelRatio = 3.0; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( ScreenUtilInit( designSize: const Size(390, 844), builder: (_, _) => MaterialApp( home: Scaffold( body: TripEmptyState( tripLabel: 'Trip 2', offline: offline, onGoOnDuty: onGoOnDuty, ), ), ), ), ); await tester.pumpAndSettle(); } /// Any decoration carrying a border, anywhere in the state. Finder borderedBoxes() => find.byWidgetPredicate((w) { if (w is! Container) return false; final d = w.decoration; return d is BoxDecoration && d.border != null; }); testWidgets('one line and the artwork, and no card', (tester) async { await pump(tester, offline: false); // ── The line is fixed copy now, not the tab's name ── // // It read `${'$'}{tripLabel} not assigned yet` — "Trip 2 not assigned yet" — // so each tab named itself. The user asked for one line, `Trip not // assigned yet`, on every tab; the tab bar directly above already says // which trip is selected, which is where that answer now lives alone. expect(find.text('Trip not assigned yet'), findsOneWidget); expect(borderedBoxes(), findsNothing); }); testWidgets('the artwork carries the wait — no paragraph, no chip', ( tester, ) async { await pump(tester, offline: false); // The illustration says "waiting for work" in one look, so the two // sentences and the `● Waiting for your hub` pill under it are gone. // Anything that reintroduces prose here should fail this. expect(find.byType(Image), findsOneWidget); expect(find.text('Waiting for your hub'), findsNothing); expect(find.textContaining('Your hub assigns trips'), findsNothing); }); testWidgets( 'off duty is a different sentence with the action that fixes it', (tester) async { var tapped = false; await pump(tester, offline: true, onGoOnDuty: () => tapped = true); expect(find.text('You are off duty'), findsOneWidget); // Nothing is coming until he goes on duty, so the wait is not claimed. expect(find.text('Waiting for your hub'), findsNothing); await tester.tap(find.text('Go on duty')); await tester.pump(); expect(tapped, isTrue); }, ); }