Files
AI-Health/health_app/test/widget_test.dart
MingNian 63d2092c24 feat: UI全面改造 + 后端多项修复
【后端修复】
- 删除diet/consultation agent假工具声明
- 修复DayOfWeek实体注释
- 修复Vision API content序列化
- cleanup_service级联删除修复
- 用药提醒时区偏差修复
- 统一DateTime处理(UtcNow+8)
- 新增UTC DateTime JSON转换器

【前端UI重构】
- 配色体系全面更新(#8B5CF6淡紫+#F0ECFF背景)
- 登录页重设计
- 首页重设计(透明顶栏、渐变背景、胶囊输入区)
- 聊天卡片加白蓝边框、渐变标题
- 侧边栏重构(渐变背景、合并顶部、删除底部设置)
- 确认卡片可编辑字段恢复
- 所有子页面加返回按钮
- catch异常加日志
- 删除后refresh provider缓存
2026-06-10 18:27:38 +08:00

72 lines
2.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:health_app/core/app_theme.dart';
import 'package:health_app/pages/auth/login_page.dart';
void main() {
testWidgets('主题颜色正确', (tester) async {
expect(AppTheme.primary, const Color(0xFF6366F1));
expect(AppTheme.primaryLight, const Color(0xFFEEF2FF));
expect(AppTheme.bg, AppTheme.bg);
expect(AppTheme.error, const Color(0xFFF56C6C));
expect(AppTheme.success, const Color(0xFF6ECF8A));
});
testWidgets('登录页渲染正常', (tester) async {
await tester.pumpWidget(const ProviderScope(child: MaterialApp(home: LoginPage())));
await tester.pumpAndSettle();
expect(find.text('健康管家'), findsOneWidget);
expect(find.text('登 录'), findsOneWidget);
});
testWidgets('获取验证码按钮存在', (tester) async {
await tester.pumpWidget(const ProviderScope(child: MaterialApp(home: LoginPage())));
await tester.pumpAndSettle();
expect(find.text('获取验证码'), findsOneWidget);
});
testWidgets('AI 气泡样式', (tester) async {
await tester.pumpWidget(MaterialApp(
theme: AppTheme.lightTheme,
home: Scaffold(body: Align(
alignment: Alignment.centerLeft,
child: Container(
constraints: const BoxConstraints(maxWidth: 300),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
border: const Border(left: BorderSide(color: AppTheme.primaryLight, width: 3)),
),
child: const Text('收到!已记录', style: TextStyle(fontSize: 16)),
),
)),
));
await tester.pumpAndSettle();
expect(find.text('收到!已记录'), findsOneWidget);
});
testWidgets('用户气泡样式', (tester) async {
await tester.pumpWidget(MaterialApp(
theme: AppTheme.lightTheme,
home: Scaffold(body: Align(
alignment: Alignment.centerRight,
child: Container(
constraints: const BoxConstraints(maxWidth: 300),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: AppTheme.primaryLight,
borderRadius: BorderRadius.circular(16),
),
child: const Text('血压 135/85', style: TextStyle(fontSize: 16, color: Colors.white)),
),
)),
));
await tester.pumpAndSettle();
expect(find.text('血压 135/85'), findsOneWidget);
});
}