import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:provider/provider.dart'; import 'package:fuel_tax_tracker/screens/report_screen.dart'; import 'package:fuel_tax_tracker/services/app_state.dart'; void main() { testWidgets('shows both toggles, off by default, with the cross-reference hint only when both are on', (tester) async { final appState = AppState()..isLoading = false; await tester.pumpWidget( ChangeNotifierProvider.value( value: appState, child: const MaterialApp(home: ReportScreen()), ), ); expect(find.text('Include Receipt Images'), findsOneWidget); expect(find.text('Include Receipt Line Items'), findsOneWidget); expect( tester.widgetList(find.byType(SwitchListTile)).map((s) => s.value), [false, false], ); expect(find.textContaining('matching number'), findsNothing); await tester.tap(find.text('Include Receipt Images')); await tester.pumpAndSettle(); expect(find.textContaining('matching number'), findsNothing, reason: 'only one toggle is on'); await tester.tap(find.text('Include Receipt Line Items')); await tester.pumpAndSettle(); expect(find.textContaining('matching number'), findsOneWidget, reason: 'both toggles now on'); }); testWidgets( 'shows a link to the state refund claim form, regardless of whether a range is picked', (tester) async { final appState = AppState()..isLoading = false; await tester.pumpWidget( ChangeNotifierProvider.value( value: appState, child: const MaterialApp(home: ReportScreen()), ), ); expect(find.text('Need the refund claim form?'), findsOneWidget); await tester.scrollUntilVisible( find.text('Get the Motor Fuel Refund Claim form'), 200, scrollable: find.byType(Scrollable), ); expect(find.text('Get the Motor Fuel Refund Claim form'), findsOneWidget); }); }