import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:provider/provider.dart';

import 'package:mini_tias/app.dart';
import 'package:mini_tias/providers/camera_provider.dart';
import 'package:mini_tias/providers/gallery_provider.dart';

void main() {
  testWidgets('アプリ起動時にナビゲーションバーが表示される', (WidgetTester tester) async {
    await tester.pumpWidget(
      MultiProvider(
        providers: [
          ChangeNotifierProvider(create: (_) => CameraProvider()),
          ChangeNotifierProvider(create: (_) => GalleryProvider()),
        ],
        child: const MiniTiasApp(),
      ),
    );

    expect(find.text('撮影'), findsOneWidget);
    expect(find.text('一覧'), findsOneWidget);
  });

  testWidgets('一覧タブをタップすると一覧画面に切り替わる', (WidgetTester tester) async {
    await tester.pumpWidget(
      MultiProvider(
        providers: [
          ChangeNotifierProvider(create: (_) => CameraProvider()),
          ChangeNotifierProvider(create: (_) => GalleryProvider()),
        ],
        child: const MiniTiasApp(),
      ),
    );

    await tester.tap(find.text('一覧'));
    await tester.pump();

    // 一覧タブがアクティブになっていることを確認
    final navBar = tester.widget<BottomNavigationBar>(
      find.byType(BottomNavigationBar),
    );
    expect(navBar.currentIndex, 1);
  });
}
