fix(player): 评论面板按参考图重做
This commit is contained in:
1 parent
bdd3a53632
commit
7862e0be09
3 files changed
+273
-244
No files matched your search
@@ -129,7 +129,10 @@ void main() {
|
||||
await _pumpSheet(tester, repository: repository);
|
||||
expect(find.text('Great episode'), findsOneWidget);
|
||||
expect(find.byKey(const Key('comment-list-load-more')), findsOneWidget);
|
||||
expect(find.byKey(const Key('comment-count-label')), findsNothing);
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('comment-count-label'))).data,
|
||||
'Comments',
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('comment-list-load-more')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -209,30 +212,89 @@ void main() {
|
||||
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('comment-post'))),
|
||||
const Size(40, 40),
|
||||
const Size(38, 38),
|
||||
);
|
||||
expect(tester.getSize(find.byKey(const Key('comment-input'))).height, 52);
|
||||
expect(tester.getSize(find.byKey(const Key('comment-input'))).height, 44);
|
||||
expect(find.byKey(const Key('player-comments-drag-handle')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('player-comments-drag-handle')),
|
||||
tester.getSize(find.byKey(const Key('player-comments-close'))),
|
||||
const Size(44, 44),
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-comments-close')),
|
||||
matching: find.byIcon(Icons.keyboard_arrow_down_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
final title = tester.widget<Text>(
|
||||
find.byKey(const Key('comment-count-label')),
|
||||
);
|
||||
expect(title.style?.fontSize, 16);
|
||||
expect(title.style?.fontWeight, FontWeight.w600);
|
||||
expect(
|
||||
tester.getCenter(find.byKey(const Key('comment-count-label'))).dx,
|
||||
closeTo(
|
||||
tester.getCenter(find.byKey(const Key('player-comments-sheet'))).dx,
|
||||
0.5,
|
||||
),
|
||||
);
|
||||
final avatar = tester.widget<CircleAvatar>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('comment-item-10')),
|
||||
matching: find.byType(CircleAvatar),
|
||||
),
|
||||
);
|
||||
expect(avatar.radius, 16);
|
||||
expect(avatar.radius, 20);
|
||||
final body = tester.widget<Text>(find.text('Great episode'));
|
||||
expect(body.style?.fontSize, 14);
|
||||
expect(body.style?.fontSize, 16);
|
||||
expect(body.style?.height, 1.4);
|
||||
expect(
|
||||
tester
|
||||
.widget<TextField>(find.byKey(const Key('comment-input')))
|
||||
.decoration
|
||||
?.fillColor,
|
||||
AppColors.commentInput,
|
||||
final composer = tester.widget<Container>(
|
||||
find.byKey(const Key('comment-composer')),
|
||||
);
|
||||
final decoration = composer.decoration! as BoxDecoration;
|
||||
expect(decoration.color, AppColors.commentInput);
|
||||
expect(decoration.borderRadius, BorderRadius.circular(22));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('comment-menu-10')),
|
||||
matching: find.byIcon(Icons.more_horiz_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_hide_comment_like_controls', (tester) async {
|
||||
final repository = FakeCommentRepository(
|
||||
pages: [
|
||||
CommentPage(
|
||||
comments: [commentFixture(id: '10', content: 'No likes shown')],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
await _pumpSheet(tester, repository: repository);
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget.key is ValueKey<String> &&
|
||||
(widget.key! as ValueKey<String>).value.startsWith('comment-like-'),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byIcon(Icons.favorite_rounded), findsNothing);
|
||||
expect(find.byIcon(Icons.favorite_border_rounded), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_close_sheet_from_down_arrow', (tester) async {
|
||||
final repository = FakeCommentRepository(pages: [const CommentPage()]);
|
||||
|
||||
await _pumpSheet(tester, repository: repository);
|
||||
await tester.tap(find.byKey(const Key('player-comments-close')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('player-comments-sheet')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_show_review_badge_and_server_replaced_content', (
|
||||
@@ -306,34 +368,6 @@ void main() {
|
||||
expect(find.byKey(const Key('comment-list-retry')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_update_comment_like_count_when_server_returns_count', (
|
||||
tester,
|
||||
) async {
|
||||
final repository = FakeCommentRepository(
|
||||
pages: [
|
||||
CommentPage(
|
||||
comments: [commentFixture(id: '10', content: 'Like me')],
|
||||
),
|
||||
],
|
||||
);
|
||||
final interactions = FakeInteractionRepository()
|
||||
..nextLikeResult = const LikeToggleResult(liked: true, count: 7);
|
||||
final haptics = FakeHaptics();
|
||||
|
||||
await _pumpSheet(
|
||||
tester,
|
||||
repository: repository,
|
||||
interactions: interactions,
|
||||
haptics: haptics,
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('comment-like-10')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(interactions.likeTargets, ['COMMENT:10']);
|
||||
expect(haptics.lightImpacts, 1);
|
||||
expect(find.text('7'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_report_comment_and_show_success_when_submitted', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -480,10 +514,14 @@ Future<AuthController> _pumpSheet(
|
||||
locale: const Locale('en'),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: const Scaffold(
|
||||
backgroundColor: AppColors.ink,
|
||||
body: DramaCommentsSheet(drama: _drama),
|
||||
),
|
||||
initialRoute: '/comments',
|
||||
routes: {
|
||||
'/': (_) => const Scaffold(backgroundColor: AppColors.ink),
|
||||
'/comments': (_) => const Scaffold(
|
||||
backgroundColor: AppColors.ink,
|
||||
body: DramaCommentsSheet(drama: _drama),
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user