feat(flutter/widgets): PlaylistCard + PlaylistPlaceholderCard

Mirrors the web equivalents at the same ~176dp width so the home
Playlists row keeps visual rhythm whether the slot is filled with a
real playlist or a placeholder.

PlaylistPlaceholderCard variants:
- building: spinner + "Building…"
- failed: warning + "Couldn't generate"
- seed-needed: muted icon + "Like more music"
- pending: muted icon + "Coming soon"

Used in the next commit's home Playlists row; otherwise unused this
slice.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-09 11:38:19 -04:00
parent dccdb00bce
commit 3ac8cc9363
4 changed files with 257 additions and 0 deletions
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:minstrel/models/playlist.dart';
import 'package:minstrel/playlists/widgets/playlist_card.dart';
import 'package:minstrel/theme/theme_data.dart';
const _userPlaylist = Playlist(
id: 'p1',
userId: 'u1',
name: 'Road trip',
description: '',
isPublic: false,
systemVariant: null,
trackCount: 12,
coverUrl: '',
ownerUsername: 'alice',
createdAt: '2026-05-01T00:00:00Z',
updatedAt: '2026-05-01T00:00:00Z',
);
const _forYou = Playlist(
id: 'p2',
userId: 'u1',
name: 'For You',
description: '',
isPublic: false,
systemVariant: 'for_you',
trackCount: 75,
coverUrl: '',
ownerUsername: 'alice',
createdAt: '2026-05-01T00:00:00Z',
updatedAt: '2026-05-01T00:00:00Z',
);
void main() {
testWidgets('renders name and no badge for user playlist', (tester) async {
await tester.pumpWidget(MaterialApp(
theme: buildThemeData(),
home: const Scaffold(
body: PlaylistCard(playlist: _userPlaylist),
),
));
expect(find.text('Road trip'), findsOneWidget);
expect(find.text('for you'), findsNothing);
});
testWidgets('renders system badge for system playlist', (tester) async {
await tester.pumpWidget(MaterialApp(
theme: buildThemeData(),
home: const Scaffold(
body: PlaylistCard(playlist: _forYou),
),
));
expect(find.text('For You'), findsOneWidget);
expect(find.text('for you'), findsOneWidget);
});
}
@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:minstrel/playlists/widgets/playlist_placeholder_card.dart';
import 'package:minstrel/theme/theme_data.dart';
void main() {
testWidgets('building variant renders spinner + label', (tester) async {
await tester.pumpWidget(MaterialApp(
theme: buildThemeData(),
home: const Scaffold(
body: PlaylistPlaceholderCard(label: 'For You', variant: 'building'),
),
));
expect(find.text('For You'), findsOneWidget);
expect(find.text('Building…'), findsOneWidget);
expect(find.byType(CircularProgressIndicator), findsOneWidget);
});
testWidgets('failed variant shows warning + copy', (tester) async {
await tester.pumpWidget(MaterialApp(
theme: buildThemeData(),
home: const Scaffold(
body: PlaylistPlaceholderCard(label: 'Songs like…', variant: 'failed'),
),
));
expect(find.text("Couldn't generate"), findsOneWidget);
});
testWidgets('seed-needed variant copy', (tester) async {
await tester.pumpWidget(MaterialApp(
theme: buildThemeData(),
home: const Scaffold(
body: PlaylistPlaceholderCard(label: 'Songs like…', variant: 'seed-needed'),
),
));
expect(find.text('Like more music'), findsOneWidget);
});
testWidgets('pending variant copy', (tester) async {
await tester.pumpWidget(MaterialApp(
theme: buildThemeData(),
home: const Scaffold(
body: PlaylistPlaceholderCard(label: 'For You', variant: 'pending'),
),
));
expect(find.text('Coming soon'), findsOneWidget);
});
}