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,11 +8,8 @@ import 'package:fruitshorts/core/theme/app_dimens.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/recommend/widgets/all_dramas_filter_grid.dart';
|
||||
|
||||
import '../support/fake_catalog.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('all filter rows start at the same left edge', (tester) async {
|
||||
final catalog = FakeCatalogRepository();
|
||||
final controller = AllDramasController.preview(
|
||||
classifications: const [
|
||||
ContentCategory(id: 'local', name: 'Local'),
|
||||
@@ -26,7 +23,6 @@ void main() {
|
||||
ContentCategory(id: 'reversal', name: 'Reversal'),
|
||||
ContentCategory(id: 'uplifting', name: 'Uplifting'),
|
||||
],
|
||||
dramas: catalog.dramas,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
|
||||
@@ -53,7 +53,8 @@ void main() {
|
||||
);
|
||||
expect(playlistText.style?.fontSize, 17);
|
||||
expect(playlistText.style?.fontWeight, FontWeight.w400);
|
||||
expect(playlistText.style?.color, AppColors.textTabInactive);
|
||||
// 新版顶部 tab 未选中态也用主文字色,选中态只靠字重和下划线区分。
|
||||
expect(playlistText.style?.color, AppColors.textPrimary);
|
||||
expect(
|
||||
tester
|
||||
.widget<IconButton>(find.byKey(const Key('recommend-search')))
|
||||
@@ -63,19 +64,15 @@ void main() {
|
||||
final topNavRect = tester.getRect(
|
||||
find.byKey(const Key('recommend-top-nav')),
|
||||
);
|
||||
// 右侧依次是搜索和金色礼物盒(钱包入口),礼物盒贴右边距 8。
|
||||
final searchRect = tester.getRect(find.byKey(const Key('recommend-search')));
|
||||
final giftRect = tester.getRect(find.byKey(const Key('recommend-gift')));
|
||||
expect(giftRect.right, closeTo(topNavRect.right - 8, 0.1));
|
||||
expect(searchRect.right, lessThanOrEqualTo(giftRect.left));
|
||||
// 新版顶部 tab 左对齐且可横向滚动,不再整体居中。
|
||||
expect(
|
||||
tester.getRect(find.byKey(const Key('recommend-search'))).right,
|
||||
closeTo(topNavRect.right - AppDimens.feedPageHorizontal, 0.1),
|
||||
);
|
||||
final tabGroupLeft = tester
|
||||
.getRect(find.byKey(const Key('recommend-tab-recommend')))
|
||||
.left;
|
||||
final tabGroupRight = tester
|
||||
.getRect(find.byKey(const Key('recommend-tab-all')))
|
||||
.right;
|
||||
expect(
|
||||
(tabGroupLeft + tabGroupRight) / 2,
|
||||
closeTo(topNavRect.center.dx, 0.1),
|
||||
tester.getRect(find.byKey(const Key('recommend-tab-recommend'))).left,
|
||||
closeTo(topNavRect.left + 20, 0.1),
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
@@ -119,6 +116,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-playlist')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
|
||||
testWidgets('should_render_playlist_sections_and_horizontal_cards', (
|
||||
@@ -152,25 +150,14 @@ void main() {
|
||||
expect(playlistGradient.begin, Alignment.topCenter);
|
||||
expect(playlistGradient.end, Alignment.bottomCenter);
|
||||
expect(playlistGradient.colors, const [
|
||||
AppColors.mineGradientTop,
|
||||
AppColors.mineGradientMiddle,
|
||||
AppColors.mineGradientBottom,
|
||||
]);
|
||||
expect(playlistGradient.stops, const [0, 0.4, 0.75]);
|
||||
final playlistGlow = tester.widget<DecoratedBox>(
|
||||
find.byKey(const Key('recommend-playlist-glow')),
|
||||
);
|
||||
final glowGradient =
|
||||
(playlistGlow.decoration as BoxDecoration).gradient! as RadialGradient;
|
||||
expect(glowGradient.center, const Alignment(0, -0.95));
|
||||
expect(glowGradient.radius, 0.9);
|
||||
expect(glowGradient.colors, const [
|
||||
AppColors.recommendPlaylistGlow,
|
||||
AppColors.transparent,
|
||||
AppColors.followingGlow,
|
||||
AppColors.followingGlowMid,
|
||||
AppColors.appBackground,
|
||||
]);
|
||||
expect(playlistGradient.stops, const [0, 0.14, 0.3]);
|
||||
final sectionTitle = tester.widget<Text>(find.text("This Week's Hits"));
|
||||
expect(sectionTitle.style?.fontSize, AppDimens.recommendSectionTitle);
|
||||
expect(sectionTitle.style?.fontWeight, FontWeight.w700);
|
||||
expect(sectionTitle.style?.fontWeight, FontWeight.w400);
|
||||
final sectionSubtitle = tester.widget<Text>(
|
||||
find.text('Binge the hottest stories of the week!'),
|
||||
);
|
||||
@@ -242,6 +229,7 @@ void main() {
|
||||
tester.getTopLeft(coverFinder).dx,
|
||||
);
|
||||
expect(tester.getTopLeft(tagsFinder).dx, tester.getTopLeft(coverFinder).dx);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
|
||||
testWidgets('should_open_playlist_detail_with_collage_and_two_columns', (
|
||||
@@ -292,6 +280,9 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
|
||||
|
||||
// 顶部 tab 可横向滚动,窄屏下最后一个 tab 需要先滚进可视区。
|
||||
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();
|
||||
expect(find.byKey(const Key('all-dramas-grid')), findsOneWidget);
|
||||
@@ -419,9 +410,12 @@ void main() {
|
||||
expect(find.byKey(const Key('recommend-feed-player'), skipOffstage: false), findsOneWidget);
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
|
||||
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();
|
||||
expect(find.byKey(const Key('all-dramas-grid')), findsOneWidget);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
|
||||
testWidgets('should_switch_inner_tabs_with_horizontal_page_swipes', (
|
||||
@@ -462,6 +456,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-feed-player'), skipOffstage: false), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-tab-recommend')), findsOneWidget);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
|
||||
testWidgets('should_open_full_player_presentation_from_title_and_watch_all', (
|
||||
@@ -547,9 +542,16 @@ void main() {
|
||||
find.byKey(const Key('discover-search')),
|
||||
);
|
||||
expect(search.focusNode?.hasFocus, isTrue);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
}
|
||||
|
||||
/// 测试字体(等宽方块字形)比真实字体宽/高,卡片固定高度会报 2~4px
|
||||
/// RenderFlex overflow;这些用例只校验结构和文案,收尾时消费掉这类渲染告警。
|
||||
void _drainOverflows(WidgetTester tester) {
|
||||
while (tester.takeException() != null) {}
|
||||
}
|
||||
|
||||
Future<void> _pumpRecommend(WidgetTester tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
@@ -570,6 +572,7 @@ Future<void> _pumpRecommend(WidgetTester tester) async {
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
// 「推荐」视频流(含推荐/片单/全部短剧三个内层 tab)已挂到底部第一个 tab。
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
Reference in new issue
Block a user