import 'package:flutter_test/flutter_test.dart';
import 'package:live_vacation_memories/main.dart';
import 'package:live_vacation_memories/core/preferences.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';

void main() {
  // Set up sqflite ffi database factory for testing
  sqfliteFfiInit();
  databaseFactory = databaseFactoryFfi;

  testWidgets('Smoke test - loading app', (WidgetTester tester) async {
    // Mock shared preferences
    SharedPreferences.setMockInitialValues({});
    await AppPreferences.init();

    // Build our app and trigger a frame.
    await tester.pumpWidget(const LiveVacationMemoriesApp());
    
    // Wait for async initialization and database query to complete
    await tester.pump(const Duration(milliseconds: 100));

    // Verify that the title is displayed
    expect(find.text('Live Memories'), findsOneWidget);
  });
}
