2026-09-02 21:07:47 +08:00
|
|
|
|
// 功能描述:验证工作人员端登录页字段、手机号校验和接口错误中文化。
|
|
|
|
|
|
// 版本:1.1.0
|
2026-07-30 21:47:41 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
|
import 'package:service_app/app/dependencies.dart';
|
2026-09-02 21:07:47 +08:00
|
|
|
|
import 'package:service_app/data/services/api_client.dart';
|
2026-07-30 21:47:41 +08:00
|
|
|
|
import 'package:service_app/data/services/secure_session_store.dart';
|
|
|
|
|
|
import 'package:service_app/ui/features/auth/login_page.dart';
|
|
|
|
|
|
|
2026-09-02 21:07:47 +08:00
|
|
|
|
/// 验证工作人员端登录界面的关键交互。
|
2026-07-30 21:47:41 +08:00
|
|
|
|
void main() {
|
|
|
|
|
|
testWidgets('staff login explains the single shared entry', (tester) async {
|
|
|
|
|
|
final session = StaffSession(SecureSessionStore());
|
|
|
|
|
|
await tester.pumpWidget(MaterialApp(home: LoginPage(session: session)));
|
|
|
|
|
|
|
|
|
|
|
|
expect(find.text('瓶安芯服务工作台'), findsOneWidget);
|
|
|
|
|
|
expect(find.text('配送、安装维修与安检共用入口'), findsOneWidget);
|
|
|
|
|
|
expect(find.byType(TextField), findsNWidgets(2));
|
|
|
|
|
|
});
|
2026-09-02 21:07:47 +08:00
|
|
|
|
|
|
|
|
|
|
testWidgets('手机号格式错误显示输入框中文提示', (tester) async {
|
|
|
|
|
|
final session = StaffSession(SecureSessionStore());
|
|
|
|
|
|
await tester.pumpWidget(MaterialApp(home: LoginPage(session: session)));
|
|
|
|
|
|
|
|
|
|
|
|
await tester.enterText(find.byType(TextField).first, '+8613800138000');
|
|
|
|
|
|
await tester.tap(find.text('进入工作台'));
|
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
|
|
expect(find.text('请输入正确的11位手机号'), findsOneWidget);
|
|
|
|
|
|
expect(find.text('Invalid Argument'), findsNothing);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('接口错误优先按错误码中文化并屏蔽未知英文', () {
|
|
|
|
|
|
expect(localizeApiErrorMessage(1704, 'Invalid Argument'), '请求参数错误');
|
|
|
|
|
|
expect(localizeApiErrorMessage(1108, 'Password Incorrect'), '密码错误');
|
|
|
|
|
|
expect(localizeApiErrorMessage(9999, '业务处理失败'), '业务处理失败');
|
|
|
|
|
|
expect(localizeApiErrorMessage(9999, 'Unexpected Error'), '操作失败,请稍后重试');
|
|
|
|
|
|
});
|
2026-07-30 21:47:41 +08:00
|
|
|
|
}
|