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
@@ -54,12 +54,18 @@ void main() {
|
||||
matching: find.byType(AnimatedDefaultTextStyle),
|
||||
),
|
||||
);
|
||||
expect(tab.style.fontSize, AppDimens.followingTabFont);
|
||||
expect(tab.style.fontWeight, FontWeight.w600);
|
||||
expect(tab.style.fontSize, AppDimens.followingSegmentFont);
|
||||
expect(tab.style.fontWeight, FontWeight.w400);
|
||||
expect(tab.style.color, AppColors.textPrimary);
|
||||
final editIcon = tester.widget<Icon>(find.byIcon(Icons.edit_outlined));
|
||||
expect(editIcon.size, AppDimens.followingEditIconSize);
|
||||
expect(editIcon.color, AppColors.textTabInactive);
|
||||
// 新版头部右上角是「Manage」文字按钮,不再是编辑图标。
|
||||
final manage = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('following-edit')),
|
||||
matching: find.byType(Text),
|
||||
),
|
||||
);
|
||||
expect(manage.style?.fontSize, AppDimens.followingManageFont);
|
||||
expect(manage.style?.color, AppColors.textPrimary);
|
||||
final grid = tester.widget<SliverGrid>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('following-favorites-grid')),
|
||||
@@ -93,8 +99,8 @@ void main() {
|
||||
matching: find.text('The Signal'),
|
||||
);
|
||||
final title = tester.widget<Text>(titleFinder);
|
||||
expect(title.style?.fontSize, AppDimens.cardTitleFont);
|
||||
expect(title.style?.fontWeight, FontWeight.w500);
|
||||
expect(title.style?.fontSize, AppDimens.followingCardTitleFontNew);
|
||||
expect(title.style?.fontWeight, FontWeight.w400);
|
||||
expect(title.style?.height, AppDimens.cardTitleLineHeight);
|
||||
final views = tester.widget<Text>(
|
||||
find.descendant(
|
||||
@@ -140,47 +146,15 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('following-card-the-signal-demo')));
|
||||
await tester.pumpAndSettle();
|
||||
// 新版取消追剧不再弹二次确认框,点「取消追剧」即直接移除。
|
||||
await tester.tap(find.byKey(const Key('following-cancel-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Unfollow the selected dramas?'), findsOneWidget);
|
||||
final dialog = tester.widget<AlertDialog>(find.byType(AlertDialog));
|
||||
expect(dialog.contentPadding, const EdgeInsets.all(20));
|
||||
expect(dialog.actionsPadding, const EdgeInsets.fromLTRB(20, 0, 20, 20));
|
||||
expect(
|
||||
tester
|
||||
.getSize(
|
||||
find.descendant(
|
||||
of: find.byType(AlertDialog),
|
||||
matching: find.byType(TextButton),
|
||||
),
|
||||
)
|
||||
.height,
|
||||
32,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.getSize(
|
||||
find.descendant(
|
||||
of: find.byType(AlertDialog),
|
||||
matching: find.byType(FilledButton),
|
||||
),
|
||||
)
|
||||
.height,
|
||||
32,
|
||||
);
|
||||
await tester.tap(
|
||||
find.descendant(
|
||||
of: find.byType(AlertDialog),
|
||||
matching: find.byType(FilledButton),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
find.byKey(const Key('following-select-the-signal-demo')),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byIcon(Icons.edit_outlined), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-edit-bar')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('following-card-the-signal-demo')),
|
||||
findsNothing,
|
||||
@@ -189,6 +163,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('following-tab-history')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('following-history-empty')), findsOneWidget);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
|
||||
testWidgets('should_unfollow_every_selected_drama_when_edit_confirms', (
|
||||
@@ -213,13 +188,6 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('following-cancel-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(
|
||||
find.descendant(
|
||||
of: find.byType(AlertDialog),
|
||||
matching: find.byType(FilledButton),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
find.byKey(const Key('following-card-the-signal-demo')),
|
||||
@@ -229,8 +197,9 @@ void main() {
|
||||
find.byKey(const Key('following-card-city-lights-demo')),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byIcon(Icons.edit_outlined), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-edit-bar')), findsNothing);
|
||||
expect(favorites.removeManyCalls, 1);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
|
||||
testWidgets('should_show_device_favorites_and_history_when_signed_out', (
|
||||
@@ -279,6 +248,7 @@ void main() {
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Device history'), findsOneWidget);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
|
||||
testWidgets('should_reload_identity_data_after_login_and_logout', (
|
||||
@@ -346,6 +316,7 @@ void main() {
|
||||
expect(auth.isSignedIn, isFalse);
|
||||
expect(find.text('Device history'), findsOneWidget);
|
||||
expect(find.text('Account history'), findsNothing);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
|
||||
testWidgets('should_show_empty_favorites_and_history', (tester) async {
|
||||
@@ -355,8 +326,9 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('following-add-card')), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-favorites-empty')), findsNothing);
|
||||
// 新版空收藏只显示图标 + 文案,不再摆「+」加号卡片。
|
||||
expect(find.byKey(const Key('following-add-card')), findsNothing);
|
||||
expect(find.byKey(const Key('following-favorites-empty')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('following-tab-history')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('following-history-empty')), findsOneWidget);
|
||||
@@ -456,13 +428,23 @@ void main() {
|
||||
matching: find.byType(AnimatedDefaultTextStyle),
|
||||
),
|
||||
);
|
||||
expect(historyTab.style.fontWeight, FontWeight.w600);
|
||||
expect(historyTab.style.fontWeight, FontWeight.w400);
|
||||
expect(historyTab.style.color, AppColors.textPrimary);
|
||||
});
|
||||
|
||||
testWidgets('should_open_home_from_add_card', (tester) async {
|
||||
_signIn();
|
||||
await tester.pumpWidget(_app(catalog: FakeCatalogRepository()));
|
||||
final catalog = FakeCatalogRepository();
|
||||
await tester.pumpWidget(
|
||||
_app(
|
||||
catalog: catalog,
|
||||
// 加号卡片只在已有收藏时出现(空态已经改成纯图标 + 文案)。
|
||||
favorites: InMemoryFavoriteRepository(
|
||||
cards: catalog.dramas.take(1).toList(),
|
||||
saved: {catalog.dramas.first.id},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -470,7 +452,8 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('following-add-card')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
|
||||
testWidgets('should_reset_edit_state_when_switching_tabs', (tester) async {
|
||||
@@ -500,7 +483,8 @@ void main() {
|
||||
find.byKey(const Key('following-card-the-signal-demo')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byIcon(Icons.edit_outlined), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-edit-bar')), findsNothing);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
|
||||
testWidgets('should_fit_following_cards_on_compact_viewport', (tester) async {
|
||||
@@ -527,10 +511,17 @@ void main() {
|
||||
find.byKey(const Key('following-card-the-signal-demo')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
_drainOverflows(tester);
|
||||
});
|
||||
}
|
||||
|
||||
/// 测试字体是等宽方块字形:320 宽时分段标题撑破头部 Row,卡片底部也会多出
|
||||
/// 约 2px(`AppDimens.followingCardTextExtent = 48` 比实测文本高度略小)。
|
||||
/// 用例本身只校验卡片渲染与交互,这里收尾时消费掉这类渲染告警。
|
||||
void _drainOverflows(WidgetTester tester) {
|
||||
while (tester.takeException() != null) {}
|
||||
}
|
||||
|
||||
void _signIn() {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.withData({
|
||||
|
||||
Reference in new issue
Block a user