import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:health_app/core/app_router.dart';
import 'package:health_app/core/navigation_provider.dart';

void main() {
  testWidgets(
    'detail routes show an error instead of throwing when id is missing',
    (tester) async {
      await tester.pumpWidget(
        ProviderScope(
          child: Consumer(
            builder: (context, ref, _) {
              return MaterialApp(
                home: buildPage(const RouteInfo('aiAnalysis'), ref),
              );
            },
          ),
        ),
      );

      expect(tester.takeException(), isNull);
      expect(find.text('页面参数错误'), findsOneWidget);
    },
  );
}
