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

import 'package:minstrel/library/home_screen.dart';
import 'package:minstrel/library/library_providers.dart';
import 'package:minstrel/models/album.dart';
import 'package:minstrel/models/artist.dart';
import 'package:minstrel/models/home_data.dart';
import 'package:minstrel/theme/theme_data.dart';

void main() {
  testWidgets('home renders sections with rows', (tester) async {
    const fixture = HomeData(
      recentlyAddedAlbums: [
        AlbumRef(id: 'a', title: 'Geogaddi', artistId: 'x', artistName: 'BoC'),
      ],
      rediscoverAlbums: [],
      rediscoverArtists: [
        ArtistRef(id: 'r', name: 'Aphex Twin'),
      ],
      mostPlayedTracks: [],
      lastPlayedArtists: [],
    );
    await tester.pumpWidget(ProviderScope(
      overrides: [
        homeProvider.overrideWith((ref) async => fixture),
      ],
      child: MaterialApp(theme: buildThemeData(), home: const HomeScreen()),
    ));
    await tester.pumpAndSettle();
    expect(find.text('Recently added'), findsOneWidget);
    expect(find.text('Geogaddi'), findsOneWidget);
    expect(find.text('Aphex Twin'), findsOneWidget);
  });
}
