test: 按新 UI 基线重写过期用例

覆盖 155 条失败与 4 处编译错误:入口改走推荐流 tab、弹框换 AppGlowDialog、
rail 尺寸与底部锚定、子页标题字重 w400、底栏选中品牌红、收藏文案改收藏短剧。
全量 flutter test 775 通过。
This commit is contained in:
Zhou Weidong authored and trae-solo-agent committed 2026-10-28 18:48:03 +08:00
1 parent 799f3d1b7d
commit 1d4ab5e0e6
33 files changed
+853 -1114

No files matched your search

+31 -18
View File
@@ -39,7 +39,7 @@ void main() {
AppConfig.ready = Future<void>.value();
});
testWidgets('should_show_grid_skeleton_without_an_in_app_splash', (
testWidgets('should_show_feed_skeleton_without_an_in_app_splash', (
tester,
) async {
final repository = _PendingCatalogRepository();
@@ -47,8 +47,8 @@ void main() {
await tester.pump();
expect(find.byKey(const Key('home-tabs')), findsOneWidget);
expect(find.byKey(const Key('home-grid-header')), findsOneWidget);
expect(find.byKey(const Key('home-grid-skeleton')), findsOneWidget);
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-skeleton')), findsOneWidget);
expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget);
expect(find.byKey(const Key('startup-splash')), findsNothing);
expect(find.byType(CircularProgressIndicator), findsNothing);
@@ -57,34 +57,40 @@ void main() {
await _pumpForAppData(tester);
await _pumpUntilFound(
tester,
find.byKey(const Key('home-feed-card-the-signal-demo')),
find.byKey(const Key('recommend-feed-player')),
);
expect(find.byKey(const Key('startup-splash')), findsNothing);
expect(find.byKey(const Key('home-grid-skeleton')), findsNothing);
expect(find.byKey(const Key('home-grid')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-skeleton')), findsNothing);
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
});
testWidgets('should_show_catalog_error_inside_grid_without_full_overlay', (
testWidgets('should_show_catalog_error_inside_feed_without_full_overlay', (
tester,
) async {
await _pumpApp(tester, _FailingCatalogRepository());
await _pumpForAppData(tester);
await _pumpUntilFound(tester, find.byKey(const Key('home-grid-error')));
// 首页 feed 失败后会先自动重试 3 次(每 1.5s),重试用尽才展示错误态。
await _pumpUntilFound(
tester,
find.byKey(const Key('recommend-feed-empty')),
step: const Duration(milliseconds: 1600),
frames: 8,
);
expect(find.byKey(const Key('home-grid-header')), findsOneWidget);
expect(find.byKey(const Key('home-grid-error')), findsOneWidget);
expect(find.byKey(const Key('recommend-top-nav')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-empty')), findsOneWidget);
expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget);
expect(find.byType(CircularProgressIndicator), findsNothing);
});
testWidgets('should_show_catalog_empty_state_inside_grid', (tester) async {
testWidgets('should_show_catalog_empty_state_inside_feed', (tester) async {
await _pumpApp(tester, _EmptyCatalogRepository());
await _pumpForAppData(tester);
await _pumpUntilFound(tester, find.byKey(const Key('home-grid-empty')));
await _pumpUntilFound(tester, find.byKey(const Key('recommend-feed-empty')));
expect(find.byKey(const Key('home-grid-header')), findsOneWidget);
expect(find.byKey(const Key('home-grid-empty')), findsOneWidget);
expect(find.byKey(const Key('recommend-top-nav')), findsOneWidget);
expect(find.byKey(const Key('recommend-feed-empty')), findsOneWidget);
expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget);
});
}
@@ -108,10 +114,15 @@ Future<void> _pumpApp(WidgetTester tester, CatalogRepository repository) async {
await tester.pump();
}
Future<void> _pumpUntilFound(WidgetTester tester, Finder finder) async {
for (var frame = 0; frame < 40; frame++) {
Future<void> _pumpUntilFound(
WidgetTester tester,
Finder finder, {
Duration step = const Duration(milliseconds: 16),
int frames = 40,
}) async {
for (var frame = 0; frame < frames; frame++) {
if (finder.evaluate().isNotEmpty) return;
await tester.pump(const Duration(milliseconds: 16));
await tester.pump(step);
}
await tester.pump();
}
@@ -163,9 +174,11 @@ class _EmptyCatalogRepository implements CatalogRepository {
class _PendingCatalogRepository implements CatalogRepository {
final Completer<HomeFeed> _home = Completer<HomeFeed>();
final Completer<FeedPage> _page = Completer<FeedPage>();
void complete(HomeFeed feed) {
if (!_home.isCompleted) _home.complete(feed);
if (!_page.isCompleted) _page.complete(FeedPage(dramas: feed.dramas));
}
@override
@@ -180,7 +193,7 @@ class _PendingCatalogRepository implements CatalogRepository {
String? categoryId,
String? cursor,
int size = 10,
}) async => FeedPage(dramas: _feed.dramas);
}) => _page.future;
@override
Future<Drama> fetchDrama(String dramaId) async => _feed.dramas.first;