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

import 'package:freecell/main.dart';
import 'package:freecell/screens/freecell_screen.dart';
import 'package:freecell/screens/loading_screen.dart';
import 'package:freecell/screens/start_screen.dart';

void main() {
  testWidgets('FreeCell app flow routes smoke test', (
    WidgetTester tester,
  ) async {
    await tester.pumpWidget(const FreeCellDemoApp());
    await tester.pump();

    expect(find.byType(LoadingScreen), findsOneWidget);

    final context = tester.element(find.byType(LoadingScreen));
    Navigator.of(context).pushReplacementNamed('/start');
    await tester.pump();
    await tester.pump(const Duration(milliseconds: 350));

    expect(find.byType(StartScreen), findsOneWidget);

    Navigator.of(
      tester.element(find.byType(StartScreen)),
    ).pushReplacementNamed('/game');
    await tester.pump();
    await tester.pump(const Duration(milliseconds: 350));

    expect(find.byType(FreeCellScreen), findsOneWidget);
  });
}
