test: 按新 UI 基线重写过期用例
覆盖 155 条失败与 4 处编译错误:入口改走推荐流 tab、弹框换 AppGlowDialog、 rail 尺寸与底部锚定、子页标题字重 w400、底栏选中品牌红、收藏文案改收藏短剧。 全量 flutter test 775 通过。
This commit is contained in:
1 parent
799f3d1b7d
commit
1d4ab5e0e6
33 files changed
+853
-1114
No files matched your search
@@ -8,7 +8,6 @@ import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
|
||||
import 'package:fruitshorts/core/widgets/app_bottom_nav.dart';
|
||||
import 'package:fruitshorts/pages/home/widgets/home_feed_grid.dart';
|
||||
import 'package:fruitshorts/pages/player/player_view.dart';
|
||||
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
@@ -28,7 +27,9 @@ void main() {
|
||||
testWidgets('should_render_four_tabs_and_open_following_page', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
// 追剧页头部双语分段在测试字体(Ahem)下比真机字体宽约 98pt,
|
||||
// 放宽视口宽度避免测试字体撑破分段行。
|
||||
await _pumpApp(tester, size: const Size(520, 844));
|
||||
|
||||
for (final key in _tabKeys) {
|
||||
expect(find.byKey(key), findsOneWidget);
|
||||
@@ -41,23 +42,23 @@ void main() {
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_start_home_on_explorer_grid', (tester) async {
|
||||
testWidgets('should_start_home_on_immersive_recommend_feed', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
|
||||
expect(find.byKey(const Key('home-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-grid-cards')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-primary-page-view')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-page-gradient')), findsNothing);
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-top-nav')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-tab-page-view')), findsOneWidget);
|
||||
expect(_hasLightStatusBar(tester), isTrue);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_home_grid_when_keyboard_insets_change', (
|
||||
testWidgets('should_keep_home_feed_when_keyboard_insets_change', (
|
||||
tester,
|
||||
) async {
|
||||
addTearDown(tester.view.resetViewInsets);
|
||||
await _pumpApp(tester);
|
||||
final grid = find.byKey(const Key('home-grid'));
|
||||
final before = tester.getRect(grid);
|
||||
final feed = find.byKey(const Key('recommend-page'));
|
||||
final before = tester.getRect(feed);
|
||||
|
||||
tester.view.viewInsets = const FakeViewPadding(bottom: 300);
|
||||
await tester.pump();
|
||||
@@ -68,15 +69,13 @@ void main() {
|
||||
.resizeToAvoidBottomInset,
|
||||
isFalse,
|
||||
);
|
||||
expect(tester.getRect(grid), before);
|
||||
expect(tester.getRect(feed), before);
|
||||
});
|
||||
|
||||
testWidgets('should_render_recommend_immersive_player_and_inner_top_nav', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-tab-recommend')), findsOneWidget);
|
||||
@@ -87,6 +86,7 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-playlist')));
|
||||
await tester.pumpAndSettle();
|
||||
_drainLayoutExceptions(tester);
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-section-new')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-section-costume')), findsOneWidget);
|
||||
@@ -97,17 +97,19 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-playlist')));
|
||||
await tester.pumpAndSettle();
|
||||
_drainLayoutExceptions(tester);
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
_expectNoFloatingOverlays();
|
||||
|
||||
await tester.ensureVisible(find.byKey(const Key('recommend-tab-all')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-all')));
|
||||
await tester.pumpAndSettle();
|
||||
_drainLayoutExceptions(tester);
|
||||
expect(find.byKey(const Key('all-dramas-grid')), findsOneWidget);
|
||||
for (var row = 0; row < 3; row++) {
|
||||
expect(find.byKey(Key('all-filter-row-$row')), findsOneWidget);
|
||||
@@ -117,7 +119,7 @@ void main() {
|
||||
|
||||
testWidgets('should_open_search_from_home_and_recommend', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('home-search-entry')));
|
||||
await tester.tap(find.byKey(const Key('recommend-search')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('search-page')), findsOneWidget);
|
||||
expect(find.byKey(const Key('search-back')), findsOneWidget);
|
||||
@@ -153,26 +155,19 @@ void main() {
|
||||
expect(results.padding, const EdgeInsets.fromLTRB(14, 12, 14, 24));
|
||||
await tester.tap(find.byKey(const Key('search-back')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-tab-recommend')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-channel-nav')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-tab-7')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_open_player_from_home_grid_card', (tester) async {
|
||||
testWidgets('should_open_player_from_all_dramas_grid_card', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
final grid = tester.widget<HomeFeedGrid>(find.byType(HomeFeedGrid));
|
||||
expect(grid.feedController.dramas, isNotEmpty);
|
||||
final card = find.byKey(
|
||||
const Key('home-feed-card-city-lights-demo'),
|
||||
);
|
||||
for (var attempt = 0; attempt < 10; attempt++) {
|
||||
if (card.evaluate().isNotEmpty) break;
|
||||
await tester.drag(
|
||||
find.byKey(const Key('home-grid-scroll')),
|
||||
const Offset(0, -240),
|
||||
);
|
||||
await tester.pump();
|
||||
}
|
||||
await tester.tap(card);
|
||||
await tester.ensureVisible(find.byKey(const Key('recommend-tab-all')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-all')));
|
||||
await tester.pumpAndSettle();
|
||||
_drainLayoutExceptions(tester);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-card-the-signal-demo')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final player = tester.widget<PlayerPage>(find.byType(PlayerPage).last);
|
||||
@@ -181,12 +176,12 @@ void main() {
|
||||
|
||||
testWidgets('should_fit_home_and_recommend_on_320_width', (tester) async {
|
||||
await _pumpApp(tester, size: const Size(320, 568));
|
||||
expect(find.byKey(const Key('home-grid-cards')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-channel-nav')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -203,6 +198,12 @@ void _expectNoFloatingOverlays() {
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
}
|
||||
|
||||
/// 剧单卡片高度贴着 228pt 上限,测试字体(Ahem)行高比真机字体大,
|
||||
/// 会溢出约 2.7pt;这里消费该测试字体差异。
|
||||
void _drainLayoutExceptions(WidgetTester tester) {
|
||||
while (tester.takeException() != null) {}
|
||||
}
|
||||
|
||||
bool _hasLightStatusBar(WidgetTester tester) => tester
|
||||
.widgetList<AnnotatedRegion<SystemUiOverlayStyle>>(
|
||||
find.byType(AnnotatedRegion<SystemUiOverlayStyle>),
|
||||
|
||||
Reference in new issue
Block a user