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

import 'package:badnote/screens/home_screen.dart';

void main() {
  testWidgets('Home screen renders its app bar title', (
    WidgetTester tester,
  ) async {
    // The note list is backed by the on-device database, which is not
    // available in the widget-test environment; the body therefore shows a
    // loading/error state. The app-bar chrome renders regardless, so we assert
    // on that. The home screen must be wrapped in a ProviderScope, which the
    // app's real entrypoint (main.dart) provides.
    SharedPreferences.setMockInitialValues({});

    await tester.pumpWidget(
      const ProviderScope(child: MaterialApp(home: HomeScreen())),
    );
    await tester.pump();

    expect(find.text('BadNote'), findsOneWidget);
    expect(find.byTooltip('Search'), findsOneWidget);
  });
}
