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

+28 -9
View File
@@ -25,6 +25,21 @@ void main() {
setUp(() {
SharedPreferencesAsyncPlatform.instance =
InMemorySharedPreferencesAsync.empty();
// 注册流程会通过 device 通道读取设备国家;widget 测试没有原生实现,
// 不打桩这个通道调用会一直等不到回复(提交按钮转圈、pumpAndSettle 超时)。
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
const MethodChannel('com.stormg.lumadrama/device'),
(call) async => call.method == 'region' ? 'ID' : null,
);
});
tearDown(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
const MethodChannel('com.stormg.lumadrama/device'),
null,
);
});
Future<void> pumpAuthPage(
@@ -179,11 +194,16 @@ void main() {
await pumpAuthPage(tester);
expect(find.text('Welcome back'), findsOneWidget);
await tester.tap(find.text('New here? Create an account'));
// 新版用顶部 Sign In / Sign Up 分段切换,不再有底部文字链接。
await tester.tap(find.byKey(const Key('auth-mode-sign-up')));
await tester.pumpAndSettle();
expect(find.text('Create your account'), findsOneWidget);
expect(find.text('Already have an account? Sign in'), findsOneWidget);
expect(find.text('Welcome back'), findsNothing);
await tester.tap(find.byKey(const Key('auth-mode-sign-in')));
await tester.pumpAndSettle();
expect(find.text('Welcome back'), findsOneWidget);
},
);
@@ -208,10 +228,6 @@ void main() {
tester.getSize(find.byKey(const Key('auth-password-visibility'))).height,
greaterThanOrEqualTo(44),
);
expect(
tester.getSize(find.byKey(const Key('auth-switch-mode'))).height,
greaterThanOrEqualTo(44),
);
});
testWidgets('should_toggle_password_visibility_when_eye_button_is_tapped', (
@@ -287,8 +303,8 @@ 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,
);
@@ -316,12 +332,14 @@ void main() {
(tester) async {
tester.view.physicalSize = const Size(320, 568);
tester.view.devicePixelRatio = 1;
tester.view.viewInsets = const FakeViewPadding(bottom: 260);
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
addTearDown(tester.view.resetViewInsets);
await pumpAuthPage(tester);
// 键盘在邮箱表单打开之后再弹出(落地页按可用高度分段排版,不适合压到 240 高)。
tester.view.viewInsets = const FakeViewPadding(bottom: 260);
await tester.pumpAndSettle();
await tester.scrollUntilVisible(
find.byKey(const Key('auth-submit')),
120,
@@ -474,6 +492,7 @@ class _FailingAuthApi extends AuthApi {
required String email,
required String password,
required String deviceId,
String countryCode = '',
String platform = '',
String osVersion = '',
String appVersion = '',