feat(library): 收藏卡片展示简介

This commit is contained in:
Zhou Weidong committed 2026-10-22 12:45:27 +08:00
1 parent 9093700a04
commit 57f3029018
4 files changed
+117 -3

No files matched your search

+42 -2
View File
@@ -32,10 +32,10 @@ import '../support/fake_interaction_repositories.dart';
import '../support/fake_notice_repository.dart';
import '../support/widget_player.dart';
Drama _card(String id) => Drama(
Drama _card(String id, {String synopsis = 'synopsis'}) => Drama(
id: id,
title: 'Drama $id',
synopsis: 'synopsis',
synopsis: synopsis,
posterUrl: '/files/$id.png',
totalEpisodes: 12,
);
@@ -73,6 +73,14 @@ void main() {
);
expect(title.style?.color, AppColors.onSurface);
expect(title.style?.fontSize, 15);
final synopsis = tester.widget<Text>(
find.byKey(const Key('favorite-synopsis-signal')),
);
expect(synopsis.data, 'synopsis');
expect(synopsis.maxLines, 2);
expect(synopsis.overflow, TextOverflow.ellipsis);
expect(synopsis.style?.color, AppColors.muted);
expect(synopsis.style?.fontSize, 12);
expect(
tester.getSize(find.byKey(const Key('favorite-cover-signal'))),
const Size(80, 106),
@@ -100,6 +108,38 @@ void main() {
expect(find.byKey(const Key('favorite-card-signal')), findsNothing);
});
testWidgets('should_hide_blank_synopsis_without_changing_card_height', (
tester,
) async {
final auth = await _auth(signedIn: true);
final longSynopsis = List.filled(12, '很长的剧情简介').join();
final favorites = FavoriteController(
InMemoryFavoriteRepository(
saved: {'with-synopsis', 'without-synopsis'},
cards: [
_card('with-synopsis', synopsis: longSynopsis),
_card('without-synopsis', synopsis: ' '),
],
),
);
await _pumpPage(tester, auth: auth, favorites: favorites);
final withSynopsis = tester.widget<Text>(
find.byKey(const Key('favorite-synopsis-with-synopsis')),
);
expect(withSynopsis.maxLines, 2);
expect(withSynopsis.overflow, TextOverflow.ellipsis);
expect(
find.byKey(const Key('favorite-synopsis-without-synopsis')),
findsNothing,
);
expect(
tester.getSize(find.byKey(const Key('favorite-card-with-synopsis'))),
tester.getSize(find.byKey(const Key('favorite-card-without-synopsis'))),
);
});
testWidgets('should_keep_card_and_show_failure_when_remove_fails', (
tester,
) async {