feat(flutter): 剧场页按参考图重做
This commit is contained in:
1 parent
2abb8c7032
commit
5a51af4264
13 files changed
+499
-258
No files matched your search
@@ -34,9 +34,54 @@ void main() {
|
||||
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('discover-identify')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-profile')), findsNothing);
|
||||
for (final tool in ['filter', 'ranking', 'new', 'reserve']) {
|
||||
expect(find.byKey(Key('theater-toolbar-$tool')), findsOneWidget);
|
||||
}
|
||||
expect(
|
||||
find.byKey(const Key('drama-heat-city-lights-demo')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byKey(const Key('drama-tag-chip-city-lights-demo-0')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_open_filter_sheet_and_apply_category', (tester) async {
|
||||
await _pumpTheater(tester, categoryRepository: _GridCategoryRepository());
|
||||
|
||||
await tester.tap(find.byKey(const Key('theater-toolbar-filter')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('theater-filter-sheet')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('theater-filter-option-7')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('theater-filter-sheet')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('home-drama-card-city-lights-demo')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byKey(const Key('home-drama-card-the-signal-demo')),
|
||||
findsNothing,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_show_coming_soon_when_identify_is_tapped', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpTheater(tester, categoryRepository: _GridCategoryRepository());
|
||||
|
||||
await tester.tap(find.byKey(const Key('discover-identify')));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Coming soon'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_filter_grid_when_category_chip_is_tapped', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -73,7 +118,7 @@ void main() {
|
||||
matching: find.byType(Scrollable),
|
||||
);
|
||||
|
||||
await tester.drag(find.byType(ListView), const Offset(0, -140));
|
||||
await tester.drag(_verticalFeed, const Offset(0, -140));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
@@ -129,7 +174,7 @@ void main() {
|
||||
await _pumpTheater(tester, categoryRepository: counter);
|
||||
|
||||
final before = counter.categoryLoads + counter.feedLoads;
|
||||
await tester.drag(find.byType(ListView), const Offset(0, 320));
|
||||
await tester.drag(_verticalFeed, const Offset(0, 320));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -139,6 +184,10 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
final Finder _verticalFeed = find.byWidgetPredicate(
|
||||
(widget) => widget is ListView && widget.scrollDirection == Axis.vertical,
|
||||
);
|
||||
|
||||
Future<void> _pumpTheater(
|
||||
WidgetTester tester, {
|
||||
required CategoryRepository categoryRepository,
|
||||
|
||||
@@ -215,7 +215,7 @@ void main() {
|
||||
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('discover-profile')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-identify')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user