feat(07-02): add sort dropdown tests to HomeScreen and fix AppShell test regression

- Add sortPreferenceProvider override to _buildApp test helper
- Add 'HomeScreen sort dropdown' test group: verifies PopupMenuButton<TaskSortOption> and AppBar title
- Fix app_shell_test: expect findsWidgets for 'Übersicht' since AppBar title now also shows it
- 115 tests pass total (113 existing + 2 new)
This commit is contained in:
2026-03-16 22:39:18 +01:00
parent e5eccb74e5
commit a3e4d0224b
2 changed files with 40 additions and 2 deletions

View File

@@ -10,6 +10,8 @@ import 'package:household_keeper/features/home/presentation/calendar_providers.d
import 'package:household_keeper/features/rooms/presentation/room_providers.dart';
import 'package:household_keeper/features/tasks/domain/effort_level.dart';
import 'package:household_keeper/features/tasks/domain/frequency.dart';
import 'package:household_keeper/features/tasks/domain/task_sort_option.dart';
import 'package:household_keeper/features/tasks/presentation/sort_preference_notifier.dart';
import 'package:household_keeper/l10n/app_localizations.dart';
import 'package:household_keeper/features/home/domain/daily_plan_models.dart';
@@ -65,6 +67,7 @@ Widget _buildApp(CalendarDayState dayState) {
roomWithStatsListProvider.overrideWith(
(ref) => Stream.value([]),
),
sortPreferenceProvider.overrideWith(SortPreferenceNotifier.new),
]);
return UncontrolledProviderScope(
@@ -238,4 +241,38 @@ void main() {
expect(find.byType(ListView), findsWidgets);
});
});
group('HomeScreen sort dropdown', () {
testWidgets('shows sort dropdown in AppBar', (tester) async {
await tester.pumpWidget(_buildApp(CalendarDayState(
selectedDate: today,
dayTasks: const [],
overdueTasks: const [],
totalTaskCount: 0,
)));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
// SortDropdown wraps a PopupMenuButton<TaskSortOption>
expect(
find.byType(PopupMenuButton<TaskSortOption>),
findsOneWidget,
);
});
testWidgets('shows AppBar with title', (tester) async {
await tester.pumpWidget(_buildApp(CalendarDayState(
selectedDate: today,
dayTasks: const [],
overdueTasks: const [],
totalTaskCount: 0,
)));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
// tabHome l10n string is 'Übersicht'. It appears in the AppBar title
// and also in the bottom navigation bar label — use findsWidgets.
expect(find.text('\u00dcbersicht'), findsWidgets);
});
});
}