69 lines
2.3 KiB
Dart
69 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:motorcycle_dash/core/router.dart';
|
|
import 'package:motorcycle_dash/core/theme/theme_extensions.dart';
|
|
import 'package:motorcycle_dash/features/records/records_service.dart';
|
|
import 'package:motorcycle_dash/features/social/feed/social_feed_screen.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
setUp(() {
|
|
SharedPreferences.setMockInitialValues({});
|
|
});
|
|
|
|
testWidgets('Navigating to /social and tapping Community Feed opens SocialFeedScreen', (tester) async {
|
|
await tester.binding.setSurfaceSize(const Size(400, 800));
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [
|
|
sharedPreferencesProvider.overrideWithValue(prefs),
|
|
],
|
|
child: MaterialApp.router(
|
|
theme: ThemeData.dark().copyWith(
|
|
extensions: const [
|
|
MotorSignalThemeColors.dark,
|
|
],
|
|
),
|
|
routerConfig: appRouter,
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
// 1. We start on Dashboard (index 0)
|
|
expect(find.text('Dash'), findsWidgets);
|
|
|
|
// 2. Tap Social in bottom navigation bar
|
|
final socialTab = find.byKey(const ValueKey('nav_social_icon'));
|
|
expect(socialTab, findsOneWidget);
|
|
await tester.tap(socialTab);
|
|
await tester.pumpAndSettle();
|
|
|
|
// 3. We land directly on Community Feed!
|
|
expect(find.byType(SocialFeedScreen), findsOneWidget);
|
|
expect(find.text('SQUAD & CANYON FEED'), findsOneWidget);
|
|
|
|
// 4. Tap 'Hub' toggle in AppBar to view Rider Hub
|
|
final hubToggle = find.byKey(const ValueKey('social_tab_hub'));
|
|
expect(hubToggle, findsOneWidget);
|
|
await tester.tap(hubToggle);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Rider Network'), findsOneWidget);
|
|
expect(find.byKey(const ValueKey('social_card_feed')), findsOneWidget);
|
|
|
|
// 5. Tapping 'Feed' toggle switches back to Community Feed
|
|
final feedToggle = find.byKey(const ValueKey('social_tab_feed'));
|
|
await tester.tap(feedToggle);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('SQUAD & CANYON FEED'), findsOneWidget);
|
|
});
|
|
}
|