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/l10n/app_localizations.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( ProviderScope( child: MaterialApp( // The screen is now localized; provide the delegates it depends on. localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, home: const HomeScreen(), ), ), ); await tester.pump(); expect(find.text('BadNote'), findsOneWidget); expect(find.byTooltip('Search'), findsOneWidget); }); }