1a028b9852
Presentational DailyRewardSheet (7 cells, today highlighted, reward icons from the calendar table, claim + watch-ad-2x buttons). HomeScreen becomes a ConsumerStatefulWidget that shows it once per mount via a post-frame guard; the 2x path grants the doubled reward only if the rewarded ad was earned, else the base reward. Guards the throwing saveRepositoryProvider default so a repo-less mount is a no-op. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
39 lines
1.2 KiB
Dart
39 lines
1.2 KiB
Dart
import 'package:block_seasons/l10n/gen/app_localizations.dart';
|
|
import 'package:block_seasons/ui/widgets/daily_reward_sheet.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('renders 7 day cells with today highlighted', (tester) async {
|
|
await tester.pumpWidget(wrap(
|
|
DailyRewardSheet(day: 3, onClaim: (_) {}),
|
|
));
|
|
|
|
for (var d = 1; d <= 7; d++) {
|
|
expect(find.byKey(ValueKey('daily_day_$d')), findsOneWidget,
|
|
reason: 'day $d cell');
|
|
}
|
|
});
|
|
|
|
testWidgets('claim and 2x buttons fire onClaim with the right flag',
|
|
(tester) async {
|
|
final claims = <bool>[];
|
|
await tester.pumpWidget(wrap(
|
|
DailyRewardSheet(day: 1, onClaim: claims.add),
|
|
));
|
|
|
|
await tester.tap(find.byKey(const ValueKey('daily_claim')));
|
|
expect(claims, [false]);
|
|
|
|
await tester.tap(find.byKey(const ValueKey('daily_double')));
|
|
expect(claims, [false, true]);
|
|
});
|
|
}
|