feat(recommend): 轮播只保留标题简介并重做顶部导航

This commit is contained in:
Vicky authored and trae-solo-agent committed 2026-10-30 17:14:34 +08:00
1 parent 53e8c924a6
commit 9ef8eb15b0
6 files changed
+180 -205

No files matched your search

+36 -2
View File
@@ -2,6 +2,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/core/data/models/drama.dart';
import 'package:fruitshorts/core/data/models/home_feed.dart';
import 'package:fruitshorts/core/theme/app_colors.dart';
import 'package:fruitshorts/l10n/app_localizations.dart';
@@ -12,7 +13,14 @@ const List<FeedBanner> _banners = [
FeedBanner(id: '2', imageUrl: 'https://cdn.test/b.png'),
];
Widget _harness(List<FeedBanner> banners) {
const Drama _drama = Drama(
id: 'd1',
title: 'City Lights',
synopsis: 'A quiet city romance.',
posterUrl: 'https://cdn.test/d.png',
);
Widget _harness(List<FeedBanner> banners, {Drama? drama}) {
return MaterialApp(
locale: const Locale('en'),
supportedLocales: AppLocalizations.supportedLocales,
@@ -20,7 +28,7 @@ Widget _harness(List<FeedBanner> banners) {
home: Scaffold(
body: HomeHeroCarousel(
banners: banners,
dramaFor: (_) => null,
dramaFor: (_) => drama,
onWatch: (_) {},
),
),
@@ -69,6 +77,32 @@ void main() {
expect(_dotColor(tester, 0), AppColors.brandRed);
});
testWidgets('should_keep_only_title_and_synopsis_above_dots', (tester) async {
await tester.pumpWidget(_harness(_banners, drama: _drama));
await tester.pumpAndSettle();
final copy = find.byKey(const Key('home-hero-copy-0'));
expect(copy, findsOneWidget);
expect(
find.descendant(of: copy, matching: find.text('City Lights')),
findsOneWidget,
);
expect(
find.descendant(
of: copy,
matching: find.text('A quiet city romance.'),
),
findsOneWidget,
);
expect(find.byKey(const Key('home-hero-watch')), findsNothing);
expect(find.byKey(const Key('home-hero-favorite')), findsNothing);
// 文案块整体位于轮播点上方,给进度点留出间距。
final copyRect = tester.getRect(copy);
final dotRect = tester.getRect(find.byKey(const Key('home-hero-dot-0')));
expect(copyRect.bottom, lessThanOrEqualTo(dotRect.top));
});
testWidgets('should_not_loop_when_only_one_banner', (tester) async {
await tester.pumpWidget(
_harness(const [FeedBanner(id: '1', imageUrl: 'https://cdn.test/a.png')]),