import 'package:block_seasons/game/models/booster.dart'; import 'package:block_seasons/l10n/gen/app_localizations.dart'; import 'package:block_seasons/ui/widgets/booster_hint.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { Widget wrap(Widget child) => MaterialApp( locale: const Locale('en'), localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, home: Scaffold(body: Center(child: child)), ); testWidgets('shows the cell hint for hammer and cancels on tap', (tester) async { var cancelled = false; await tester.pumpWidget(wrap(BoosterHint( arming: BoosterType.hammer, accent: const Color(0xFF5B7FFF), onCancel: () => cancelled = true, ))); await tester.pump(const Duration(milliseconds: 250)); // settle entrance expect(find.text('Tap a cell'), findsOneWidget); await tester.tap(find.byType(BoosterHint)); expect(cancelled, isTrue); }); testWidgets('shows the line hint for the line bomb', (tester) async { await tester.pumpWidget(wrap(BoosterHint( arming: BoosterType.lineBomb, accent: const Color(0xFF5B7FFF), onCancel: () {}, ))); await tester.pump(const Duration(milliseconds: 250)); expect(find.text('Tap a row or column'), findsOneWidget); }); testWidgets('ignores taps when nothing is armed', (tester) async { var cancelled = false; await tester.pumpWidget(wrap(BoosterHint( arming: null, accent: const Color(0xFF5B7FFF), onCancel: () => cancelled = true, ))); await tester.pump(const Duration(milliseconds: 250)); await tester.tap(find.byType(BoosterHint), warnIfMissed: false); expect(cancelled, isFalse); }); }