feat(home): 首页改为三列探索网格

This commit is contained in:
Zhou Weidong committed 2026-10-22 17:03:45 +08:00
1 parent 6dea9d479e
commit dd96792e33
29 files changed
+1912 -256

No files matched your search

+24 -40
View File
@@ -66,9 +66,10 @@ void main() {
await tester.pumpAndSettle();
// 首页 feed 启动会创建首个播放器,先清掉再统计剧场播放器。
created.clear();
await _openTheaterPlayer(tester);
await _openRecommendFullPlayer(tester);
expect(created, hasLength(2));
expect(created, isNotEmpty);
final createdBeforeSwipe = created.length;
expect(find.byType(CircularProgressIndicator), findsNothing);
await tester.drag(find.byType(PageView).last, const Offset(0, -550));
await tester.pumpAndSettle();
@@ -77,8 +78,8 @@ void main() {
tester.widget<Text>(find.byKey(const Key('player-episode-heading'))).data,
contains('Episode 2'),
);
expect(created, hasLength(3));
expect(created.toSet(), hasLength(3));
expect(created.length, greaterThan(createdBeforeSwipe));
expect(created, contains('the-signal-demo-2'));
});
testWidgets('should_open_fullscreen_player_when_theater_card_is_tapped', (
@@ -86,7 +87,7 @@ void main() {
) async {
await tester.pumpWidget(appUnderTest());
await tester.pumpAndSettle();
await _openTheaterPlayer(tester);
await _openRecommendFullPlayer(tester);
final player = tester.widget<PlayerPage>(find.byType(PlayerPage).last);
expect(player.homeMode, isFalse);
@@ -103,22 +104,22 @@ void main() {
await tester.pumpWidget(appUnderTest());
await tester.pumpAndSettle();
await _openTheaterPlayer(tester);
await _openRecommendFullPlayer(tester);
expect(find.byType(PlayerPage), findsOneWidget);
await tester.tap(find.byKey(const Key('player-back')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
expect(
Navigator.of(
tester.element(find.byKey(const Key('home-all-dramas-grid'))),
tester.element(find.byKey(const Key('home-feed-title'))),
).canPop(),
isFalse,
);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
expect(find.byKey(const Key('home-grid')), findsOneWidget);
await tester.tap(find.byKey(const Key('tab-follow')));
await tester.pumpAndSettle();
@@ -183,7 +184,7 @@ void main() {
await tester.pumpWidget(appUnderTest());
await tester.pumpAndSettle();
await _openTheaterPlayer(tester);
await _openRecommendFullPlayer(tester);
expect(find.byKey(const Key('progress-loading')), findsNothing);
expect(find.byKey(const Key('progress-inactive')), findsOneWidget);
@@ -197,9 +198,7 @@ void main() {
expect(tester.takeException(), isNull);
});
testWidgets('should_render_theater_filters_and_grid_on_same_route_tab', (
tester,
) async {
testWidgets('should_render_home_explorer_grid_on_home_tab', (tester) async {
tester.view.physicalSize = const Size(360, 720);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
@@ -207,13 +206,11 @@ void main() {
await tester.pumpWidget(appUnderTest());
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('tab-recommend')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('discover-search')), findsOneWidget);
expect(find.byKey(const Key('theater-category-chips')), findsOneWidget);
expect(find.byKey(const Key('theater-language-chips')), findsNothing);
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
expect(find.byKey(const Key('home-grid')), findsOneWidget);
expect(find.byKey(const Key('home-grid-cards')), findsOneWidget);
expect(find.byKey(const Key('home-search-entry')), findsOneWidget);
expect(find.byKey(const Key('home-secondary-tags')), findsOneWidget);
expect(tester.takeException(), isNull);
});
@@ -244,7 +241,7 @@ void main() {
),
);
await tester.pumpAndSettle();
await _openTheaterPlayer(tester);
await _openRecommendFullPlayer(tester);
await tester.tap(find.byKey(const Key('player-rail-comments')));
await tester.pumpAndSettle();
@@ -264,13 +261,13 @@ void main() {
await tester.tap(find.byKey(const Key('player-rail-like')));
await tester.pumpAndSettle();
expect(interactions.likeTargets, contains('EPISODE:city-lights-demo-1'));
expect(interactions.likeTargets, contains('EPISODE:the-signal-demo-1'));
await tester.tap(find.byKey(const Key('player-rail-save')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('player-rail-share')));
await tester.pumpAndSettle();
expect(sharedText, contains('City Lights & Velvet Nights'));
expect(sharedText, contains('The Signal'));
expect(sharedText, contains('FruitShorts'));
expect(tester.takeException(), isNull);
});
@@ -284,7 +281,7 @@ void main() {
await tester.pumpWidget(appUnderTest(interactionRepository: interactions));
await tester.pumpAndSettle();
await _openTheaterPlayer(tester);
await _openRecommendFullPlayer(tester);
await tester.tap(find.byKey(const Key('player-rail-like')));
await tester.pumpAndSettle();
@@ -300,7 +297,7 @@ void main() {
await tester.pumpWidget(appUnderTest());
await tester.pumpAndSettle();
await _openTheaterPlayer(tester);
await _openRecommendFullPlayer(tester);
await tester.tap(find.byKey(const Key('player-rail-save')));
await tester.pumpAndSettle();
@@ -311,26 +308,13 @@ void main() {
await tester.tap(find.byKey(const Key('mine-watchlist')));
await tester.pumpAndSettle();
expect(find.text('City Lights & Velvet Nights'), findsWidgets);
expect(find.text('The Signal'), findsWidgets);
});
}
Future<void> _openTheaterPlayer(WidgetTester tester) async {
Future<void> _openRecommendFullPlayer(WidgetTester tester) async {
await tester.tap(find.byKey(const Key('tab-recommend')));
await tester.pumpAndSettle();
final card = find.byKey(const Key('home-drama-card-city-lights-demo'));
await tester.scrollUntilVisible(
card,
220,
scrollable: find
.descendant(
of: find.byKey(const Key('discover-refresh')),
matching: find.byType(Scrollable),
)
.first,
);
await tester.ensureVisible(card);
await tester.pumpAndSettle();
await tester.tap(card);
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await tester.pumpAndSettle();
}