- getPlaylists() + getPlaylistSongs() APIs für Subsonic-Playlist-Laden - syncPlaylistsFromServer() in PlaylistService importiert alle Server-Playlisten als lokale - Benennung mit 🌐 Präfix um Server-Playlisten zu kennzeichnen - Settings-Button lädt alle Playlisten mit ihren Songs vom Server - Zeigt Anzahl importierter Playlisten mit SnackBar Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XJzQjUtnvYUtHdnTs3iCru
72 lines
2.1 KiB
Dart
72 lines
2.1 KiB
Dart
import 'package:drift/drift.dart';
|
|
import 'package:drift/native.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:melo/library/database.dart';
|
|
import 'package:melo/services/offline_mode.dart';
|
|
import 'package:melo/settings/settings_screen.dart';
|
|
|
|
Widget _wrap(MeloDb db, Widget child) {
|
|
return MultiProvider(
|
|
providers: [
|
|
Provider<MeloDb>.value(value: db),
|
|
ChangeNotifierProvider<OfflineMode>.value(value: OfflineMode()),
|
|
],
|
|
child: MaterialApp(home: child),
|
|
);
|
|
}
|
|
|
|
void main() {
|
|
testWidgets('zeigt 0 Songs ohne Bibliothek', (tester) async {
|
|
final db = MeloDb(NativeDatabase.memory());
|
|
|
|
await tester.pumpWidget(_wrap(db, const SettingsScreen()));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('0 Songs in der Bibliothek'), findsOneWidget);
|
|
|
|
await db.close();
|
|
});
|
|
|
|
testWidgets('zeigt korrekte Song-Anzahl und Gesamtspieldauer', (tester) async {
|
|
final db = MeloDb(NativeDatabase.memory());
|
|
await db.into(db.songs).insert(SongsCompanion.insert(
|
|
id: 'song-1',
|
|
path: '/a.mp3',
|
|
title: 'Song A',
|
|
dateAddedMs: 0,
|
|
updatedAtMs: 0,
|
|
durationMs: const Value(200000),
|
|
));
|
|
await db.into(db.songs).insert(SongsCompanion.insert(
|
|
id: 'song-2',
|
|
path: '/b.mp3',
|
|
title: 'Song B',
|
|
dateAddedMs: 0,
|
|
updatedAtMs: 0,
|
|
durationMs: const Value(185000),
|
|
));
|
|
|
|
await tester.pumpWidget(_wrap(db, const SettingsScreen()));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('2 Songs in der Bibliothek'), findsOneWidget);
|
|
expect(find.text('6m Gesamtspieldauer'), findsOneWidget);
|
|
|
|
await db.close();
|
|
});
|
|
|
|
testWidgets('zeigt Favoriten- und Playlisten-Sync', (tester) async {
|
|
final db = MeloDb(NativeDatabase.memory());
|
|
|
|
await tester.pumpWidget(_wrap(db, const SettingsScreen()));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('🌟 Favoriten-Sync'), findsOneWidget);
|
|
expect(find.text('📋 Playlisten-Sync'), findsOneWidget);
|
|
|
|
await db.close();
|
|
});
|
|
}
|