feat(flutter): 完成 K28-A1 四 Tab 首页

This commit is contained in:
Zhou Weidong committed 2026-10-20 09:57:10 +08:00
1 parent f981f88e0d
commit 49f3e63ed0
25 files changed
+606 -689

No files matched your search

+21 -12
View File
@@ -24,27 +24,37 @@ void main() {
InMemorySharedPreferencesAsync.empty();
});
testWidgets('should_show_search_category_language_and_drama_grid', (
testWidgets('should_show_search_categories_ranking_and_all_dramas', (
tester,
) async {
await _pumpTheater(tester, categoryRepository: _GridCategoryRepository());
expect(find.text('Continue Watching'), findsNothing);
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')), findsOneWidget);
expect(find.byKey(const Key('discover-category-grid')), findsOneWidget);
expect(find.byKey(const Key('discover-ranking-section')), findsOneWidget);
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
expect(find.byKey(const Key('ranking-tab-hot')), findsOneWidget);
expect(find.byKey(const Key('ranking-tab-new')), findsOneWidget);
final grid = tester.widget<GridView>(
find.byKey(const Key('discover-category-grid')),
);
final delegate =
grid.gridDelegate as SliverGridDelegateWithFixedCrossAxisCount;
expect(delegate.crossAxisCount, 3);
expect(tester.takeException(), isNull);
});
testWidgets('should_filter_grid_when_category_chip_is_tapped', (
testWidgets('should_open_category_dramas_page_when_tile_is_tapped', (
tester,
) async {
await _pumpTheater(tester, categoryRepository: _GridCategoryRepository());
await tester.tap(find.byKey(const Key('theater-category-7')));
await tester.tap(find.byKey(const Key('discover-category-7')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('category-dramas-page')), findsOneWidget);
expect(
find.byKey(const Key('home-drama-card-city-lights-demo')),
findsOneWidget,
@@ -66,23 +76,22 @@ void main() {
);
final headerBefore = tester.getTopLeft(
find.byKey(const Key('discover-search')),
find.byKey(const Key('discover-search-button')),
);
final scrollable = find.descendant(
of: find.byKey(const Key('discover-refresh')),
matching: find.byType(Scrollable),
final contentBefore = tester.getTopLeft(
find.byKey(const Key('discover-category-grid')),
);
await tester.drag(find.byType(ListView), const Offset(0, -140));
await tester.pumpAndSettle();
expect(
tester.getTopLeft(find.byKey(const Key('discover-search'))),
tester.getTopLeft(find.byKey(const Key('discover-search-button'))),
headerBefore,
);
expect(
tester.state<ScrollableState>(scrollable).position.pixels,
greaterThan(0),
tester.getTopLeft(find.byKey(const Key('discover-category-grid'))).dy,
lessThan(contentBefore.dy),
);
});