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

+52 -45
View File
@@ -13,7 +13,6 @@ import 'package:fruitshorts/core/data/services/auth_controller.dart';
import 'package:fruitshorts/core/data/services/auth_session_store.dart';
import 'package:fruitshorts/core/platform/haptics.dart';
import 'package:fruitshorts/core/theme/app_colors.dart';
import 'package:fruitshorts/core/theme/app_dimens.dart';
import 'package:fruitshorts/l10n/app_localizations.dart';
import 'package:fruitshorts/pages/auth/auth_view.dart';
@@ -78,13 +77,13 @@ void main() {
expect(find.byKey(const Key('auth-landing')), findsOneWidget);
expect(find.text('FruitShorts'), findsOneWidget);
expect(
find.text('Sign in to sync progress, favorites and coins'),
findsOneWidget,
);
final brand = tester.widget<Text>(find.text('FruitShorts'));
expect(brand.style?.fontSize, 26);
expect(brand.style?.fontWeight, FontWeight.w700);
expect(brand.style?.letterSpacing, 2);
expect(
tester.getSize(find.byKey(const Key('auth-brand-logo'))),
const Size(72, 72),
const Size(88, 88),
);
expect(find.byKey(const Key('auth-entry-google')), findsNothing);
expect(find.byKey(const Key('auth-entry-phone')), findsOneWidget);
@@ -92,11 +91,11 @@ void main() {
expect(find.byKey(const Key('auth-legal')), findsOneWidget);
expect(
tester.getSize(find.byKey(const Key('auth-entry-phone'))).height,
50,
52,
);
expect(
tester.getSize(find.byKey(const Key('auth-entry-email'))).height,
50,
52,
);
final phoneButton = tester.widget<Material>(
find.descendant(
@@ -104,67 +103,68 @@ void main() {
matching: find.byType(Material),
),
);
expect(phoneButton.color, AppColors.blue);
expect(phoneButton.color, AppColors.brandRed);
expect(
(phoneButton.shape! as RoundedRectangleBorder).borderRadius,
BorderRadius.circular(26),
);
final emailButton = tester.widget<Material>(
find.descendant(
of: find.byKey(const Key('auth-entry-email')),
matching: find.byType(Material),
),
);
expect(emailButton.color, AppColors.card);
expect(
(emailButton.shape! as RoundedRectangleBorder).side.color,
AppColors.border,
);
// 次按钮是「白 6%」玻璃拟态,不再有描边。
expect(emailButton.color, Colors.white.withValues(alpha: 0.06));
final glow = tester.widget<Container>(
find.byKey(const Key('auth-background-glow')),
final glow = tester.widget<DecoratedBox>(
find.byKey(const Key('auth-red-glow')),
);
final glowDecoration = glow.decoration! as BoxDecoration;
final glowDecoration = glow.decoration as BoxDecoration;
final gradient = glowDecoration.gradient! as RadialGradient;
expect(gradient.colors.first, AppColors.surfaceTop);
expect(gradient.colors.last.a, 0);
expect(gradient.colors, const [
AppColors.primaryBorder,
AppColors.transparent,
]);
await tester.tap(find.byKey(const Key('auth-entry-email')));
await tester.pumpAndSettle();
final card = tester.widget<Container>(find.byKey(const Key('auth-card')));
final cardDecoration = card.decoration! as BoxDecoration;
expect(cardDecoration.color, AppColors.card);
expect(
cardDecoration.borderRadius,
BorderRadius.circular(AppDimens.authCardRadius),
);
expect(cardDecoration.boxShadow, isNull);
expect(card.padding, const EdgeInsets.all(20));
// 新版表单不再套卡片盒子,直接排在光晕背景上。
expect(find.byKey(const Key('auth-card')), findsOneWidget);
final email = tester.widget<TextField>(
find.byKey(const Key('auth-email')),
);
expect(email.decoration?.fillColor, AppColors.card);
expect(
email.decoration?.fillColor,
Colors.white.withValues(alpha: 0.05),
);
expect(email.style?.color, AppColors.onSurface);
expect(email.style?.fontSize, 15);
expect(email.cursorColor, AppColors.blue);
expect(email.cursorColor, AppColors.brandRed);
expect(tester.getSize(find.byKey(const Key('auth-email'))).height, 52);
final emailBorder =
email.decoration!.enabledBorder! as OutlineInputBorder;
expect(emailBorder.borderRadius, BorderRadius.circular(14));
expect(emailBorder.borderSide.color, AppColors.border);
expect(emailBorder.borderSide.width, 1);
expect(emailBorder.borderRadius, BorderRadius.circular(12));
expect(emailBorder.borderSide, BorderSide.none);
final password = tester.widget<TextField>(
find.byKey(const Key('auth-password')),
);
expect(password.style?.color, AppColors.onSurface);
expect(password.style?.fontSize, 15);
expect(password.cursorColor, AppColors.blue);
expect(password.cursorColor, AppColors.brandRed);
final submit = tester.widget<FilledButton>(
find.byKey(const Key('auth-submit')),
);
expect(submit.style!.backgroundColor!.resolve(const {}), AppColors.blue);
expect(
submit.style!.backgroundColor!.resolve(const {}),
AppColors.brandRed,
);
expect(
submit.style!.backgroundColor!.resolve(const {WidgetState.pressed}),
AppColors.bluePressed,
AppColors.brandRedPressed,
);
expect(tester.getSize(find.byKey(const Key('auth-submit'))).height, 50);
expect(
@@ -201,9 +201,14 @@ void main() {
(image.image as AssetImage).assetName,
'assets/icon/fruitshorts.png',
);
// 新版落地页用三等分 Spacer 排版,Logo 居中且落在两个入口按钮上方。
final logo = find.byKey(const Key('auth-brand-logo'));
expect(tester.getCenter(logo).dx, closeTo(195, 0.1));
expect(
tester.getTopLeft(find.byKey(const Key('auth-brand-logo'))).dy,
84,
tester.getBottomLeft(logo).dy,
lessThan(
tester.getTopLeft(find.byKey(const Key('auth-entry-phone'))).dy,
),
);
},
);
@@ -250,7 +255,7 @@ void main() {
expect(find.text('Create your account'), findsOneWidget);
expect(find.text('Welcome back'), findsNothing);
expect(_segmentColor(tester, 'auth-mode-sign-up'), AppColors.blue);
expect(_segmentColor(tester, 'auth-mode-sign-up'), AppColors.brandRed);
expect(_segmentColor(tester, 'auth-mode-sign-in'), Colors.transparent);
await tester.tap(find.byKey(const Key('auth-mode-sign-in')));
@@ -258,7 +263,7 @@ void main() {
expect(find.text('Welcome back'), findsOneWidget);
expect(find.text('Create your account'), findsNothing);
expect(_segmentColor(tester, 'auth-mode-sign-in'), AppColors.blue);
expect(_segmentColor(tester, 'auth-mode-sign-in'), AppColors.brandRed);
expect(_segmentColor(tester, 'auth-mode-sign-up'), Colors.transparent);
},
);
@@ -330,8 +335,10 @@ void main() {
);
expect(
tester
.widget<TextButton>(find.byKey(const Key('auth-switch-mode')))
.onPressed,
.widget<GestureDetector>(
find.byKey(const Key('auth-mode-sign-up')),
)
.onTap,
isNull,
);
expect(
@@ -379,10 +386,10 @@ void main() {
Color? _segmentColor(WidgetTester tester, String key) {
final segment = find.byKey(Key(key));
final animated = tester.widget<AnimatedContainer>(
find.descendant(of: segment, matching: find.byType(AnimatedContainer)),
final underline = tester.widget<Container>(
find.descendant(of: segment, matching: find.byType(Container)),
);
return (animated.decoration! as BoxDecoration).color;
return (underline.decoration! as BoxDecoration).color;
}
class _PendingAuthApi extends AuthApi {