import 'package:cardash_launcher/core/theme/app_theme.dart'; import 'package:cardash_launcher/features/home/widgets/home_hint.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; Widget _host(HomeHint hint) { return MaterialApp( theme: AppTheme.light(), home: Scaffold(body: Center(child: hint)), ); } void main() { testWidgets('hint fades out ten minutes after first launch', (tester) async { final firstLaunch = DateTime(2026, 1, 1, 12); await tester.pumpWidget( _host( HomeHint( text: 'Hold a shortcut to change the app', firstLaunchAt: firstLaunch, clock: () => firstLaunch.add(const Duration(minutes: 1)), ), ), ); expect(find.text('Hold a shortcut to change the app'), findsOneWidget); await tester.pump(const Duration(minutes: 10)); await tester.pump(const Duration(milliseconds: 400)); expect(find.text('Hold a shortcut to change the app'), findsNothing); }); testWidgets('hint never appears after the first-launch window', ( tester, ) async { final firstLaunch = DateTime(2026, 1, 1, 12); await tester.pumpWidget( _host( HomeHint( text: 'Hold a shortcut to change the app', firstLaunchAt: firstLaunch, clock: () => firstLaunch.add(const Duration(minutes: 11)), ), ), ); expect(find.text('Hold a shortcut to change the app'), findsNothing); }); testWidgets('an upgraded installation has no onboarding hint', ( tester, ) async { await tester.pumpWidget( _host( HomeHint( text: 'Hold a shortcut to change the app', firstLaunchAt: DateTime.fromMillisecondsSinceEpoch(0), ), ), ); expect(find.text('Hold a shortcut to change the app'), findsNothing); }); }