feat(05-02): build CalendarStrip, CalendarTaskRow, CalendarDayList widgets
- Add totalTaskCount field to CalendarDayState to distinguish first-run from celebration - Add getTaskCount() to CalendarDao (SELECT COUNT from tasks) - CalendarStrip: 181-day horizontal scroll with German abbreviations, today highlighting, month boundary labels, scroll-to-today controller - CalendarTaskRow: task name + room tag chip + checkbox, no relative date, isOverdue coral styling - CalendarDayList: loading/error/first-run-empty/empty-day/celebration/has-tasks states, overdue section (today only), slide-out completion animation - Update home_screen_test.dart and app_shell_test.dart to test new calendar providers instead of dailyPlanProvider
This commit is contained in:
@@ -4,8 +4,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:household_keeper/core/router/router.dart';
|
||||
import 'package:household_keeper/features/home/domain/daily_plan_models.dart';
|
||||
import 'package:household_keeper/features/home/presentation/daily_plan_providers.dart';
|
||||
import 'package:household_keeper/features/home/domain/calendar_models.dart';
|
||||
import 'package:household_keeper/features/home/presentation/calendar_providers.dart';
|
||||
import 'package:household_keeper/features/rooms/presentation/room_providers.dart';
|
||||
import 'package:household_keeper/l10n/app_localizations.dart';
|
||||
|
||||
@@ -15,6 +15,9 @@ void main() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
|
||||
/// Helper to build the app with providers overridden for testing.
|
||||
///
|
||||
/// Uses [UncontrolledProviderScope] with a [ProviderContainer] to avoid
|
||||
@@ -26,15 +29,16 @@ void main() {
|
||||
roomWithStatsListProvider.overrideWith(
|
||||
(ref) => Stream.value([]),
|
||||
),
|
||||
// Override daily plan to return empty state so HomeScreen
|
||||
// renders without a database.
|
||||
dailyPlanProvider.overrideWith(
|
||||
(ref) => Stream.value(const DailyPlanState(
|
||||
overdueTasks: [],
|
||||
todayTasks: [],
|
||||
tomorrowTasks: [],
|
||||
completedTodayCount: 0,
|
||||
totalTodayCount: 0,
|
||||
// Override selected date to avoid any DB access.
|
||||
selectedDateProvider.overrideWith(SelectedDateNotifier.new),
|
||||
// Override calendar day provider to return empty first-run state so
|
||||
// HomeScreen renders without a database.
|
||||
calendarDayProvider.overrideWith(
|
||||
(ref) => Stream.value(CalendarDayState(
|
||||
selectedDate: today,
|
||||
dayTasks: const [],
|
||||
overdueTasks: const [],
|
||||
totalTaskCount: 0,
|
||||
)),
|
||||
),
|
||||
]);
|
||||
@@ -53,7 +57,8 @@ void main() {
|
||||
testWidgets('renders 3 navigation destinations with correct German labels',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(buildApp());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Verify 3 NavigationDestination widgets are rendered
|
||||
expect(find.byType(NavigationDestination), findsNWidgets(3));
|
||||
@@ -67,22 +72,24 @@ void main() {
|
||||
testWidgets('tapping a destination changes the selected tab',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(buildApp());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Initially on Home tab (index 0) -- verify home empty state is shown
|
||||
// (dailyPlanNoTasks text from the daily plan empty state)
|
||||
// Initially on Home tab (index 0) -- verify home first-run empty state
|
||||
expect(find.text('Noch keine Aufgaben angelegt'), findsOneWidget);
|
||||
|
||||
// Tap the Rooms tab (second destination)
|
||||
await tester.tap(find.text('R\u00e4ume'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Verify we see Rooms content now (empty state)
|
||||
expect(find.text('Hier ist noch alles leer!'), findsOneWidget);
|
||||
|
||||
// Tap the Settings tab (third destination)
|
||||
await tester.tap(find.text('Einstellungen'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Verify we see Settings content now
|
||||
expect(find.text('Darstellung'), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user