diff --git a/lib/core/router.dart b/lib/core/router.dart index e99db9c..b311d3a 100644 --- a/lib/core/router.dart +++ b/lib/core/router.dart @@ -137,6 +137,23 @@ final appRouter = GoRouter( path: 'friends', builder: (context, state) => const FriendsScreen(), ), + GoRoute( + path: 'clubs', + builder: (context, state) => const ClubsHubScreen(), + routes: [ + GoRoute( + path: 'create', + builder: (context, state) => const CreateClubScreen(), + ), + GoRoute( + path: ':id', + builder: (context, state) { + final id = state.pathParameters['id']!; + return ClubDetailScreen(clubId: id); + }, + ), + ], + ), ], ), ], @@ -163,23 +180,6 @@ final appRouter = GoRouter( path: 'friends', builder: (context, state) => const FriendsScreen(), ), - GoRoute( - path: 'clubs', - builder: (context, state) => const ClubsHubScreen(), - routes: [ - GoRoute( - path: 'create', - builder: (context, state) => const CreateClubScreen(), - ), - GoRoute( - path: ':id', - builder: (context, state) { - final id = state.pathParameters['id']!; - return ClubDetailScreen(clubId: id); - }, - ), - ], - ), GoRoute( path: 'diagnostics', builder: (context, state) => const DiagnosticsScreen(), diff --git a/test/router_test.dart b/test/router_test.dart new file mode 100644 index 0000000..a55bd9b --- /dev/null +++ b/test/router_test.dart @@ -0,0 +1,35 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:motorcycle_dash/core/router.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('appRouter Route Configuration Tests', () { + test('routes include /social/clubs and subroutes', () { + final config = appRouter.configuration; + + // Verify match locations can be resolved without GoException + final matchClubs = config.findMatch(Uri.parse('/social/clubs')); + expect(matchClubs.matches.isNotEmpty, isTrue); + + final matchCreate = config.findMatch(Uri.parse('/social/clubs/create')); + expect(matchCreate.matches.isNotEmpty, isTrue); + + final matchDetail = config.findMatch(Uri.parse('/social/clubs/c123')); + expect(matchDetail.matches.isNotEmpty, isTrue); + }); + + test('routes include /social base and other social routes', () { + final config = appRouter.configuration; + + final matchSocial = config.findMatch(Uri.parse('/social')); + expect(matchSocial.matches.isNotEmpty, isTrue); + + final matchProfile = config.findMatch(Uri.parse('/social/profile')); + expect(matchProfile.matches.isNotEmpty, isTrue); + + final matchFriends = config.findMatch(Uri.parse('/social/friends')); + expect(matchFriends.matches.isNotEmpty, isTrue); + }); + }); +}