feat(01-02): create router, navigation shell, screens, and app shell test
- GoRouter with StatefulShellRoute.indexedStack and 3 branches (Home, Rooms, Settings) - AppShell with NavigationBar using localized labels and thematic icons - HomeScreen with empty state and cross-navigation to Rooms tab - RoomsScreen with empty state and placeholder action button - SettingsScreen with SegmentedButton theme switcher and About section - Widget test verifying 3 navigation destinations with correct German labels Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
70
test/shell/app_shell_test.dart
Normal file
70
test/shell/app_shell_test.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
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/l10n/app_localizations.dart';
|
||||
|
||||
void main() {
|
||||
group('AppShell Navigation', () {
|
||||
setUp(() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
|
||||
testWidgets('renders 3 navigation destinations with correct German labels',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
child: MaterialApp.router(
|
||||
routerConfig: router,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: const [Locale('de')],
|
||||
locale: const Locale('de'),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify 3 NavigationDestination widgets are rendered
|
||||
expect(find.byType(NavigationDestination), findsNWidgets(3));
|
||||
|
||||
// Verify correct German labels from ARB (with umlauts)
|
||||
expect(find.text('\u00dcbersicht'), findsOneWidget);
|
||||
expect(find.text('R\u00e4ume'), findsOneWidget);
|
||||
expect(find.text('Einstellungen'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('tapping a destination changes the selected tab',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
child: MaterialApp.router(
|
||||
routerConfig: router,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: const [Locale('de')],
|
||||
locale: const Locale('de'),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Initially on Home tab (index 0) -- verify home empty state is shown
|
||||
expect(find.text('Noch nichts zu tun!'), findsOneWidget);
|
||||
|
||||
// Tap the Rooms tab (second destination)
|
||||
await tester.tap(find.text('R\u00e4ume'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify we see Rooms content now
|
||||
expect(find.text('Hier ist noch alles leer!'), findsOneWidget);
|
||||
|
||||
// Tap the Settings tab (third destination)
|
||||
await tester.tap(find.text('Einstellungen'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify we see Settings content now
|
||||
expect(find.text('Darstellung'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user