2026-04-03 16:56:47 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
2026-04-03 19:04:46 +08:00
|
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
2026-04-03 16:56:47 +08:00
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
|
import 'package:meeyao_qianwen/app/app_theme.dart';
|
|
|
|
|
|
import 'package:meeyao_qianwen/features/divination/data/models/divination_params.dart';
|
2026-04-03 19:04:46 +08:00
|
|
|
|
import 'package:meeyao_qianwen/features/divination/data/models/divination_result.dart';
|
2026-04-03 16:56:47 +08:00
|
|
|
|
import 'package:meeyao_qianwen/features/divination/presentation/screens/divination_result_screen.dart';
|
2026-04-03 19:04:46 +08:00
|
|
|
|
import 'package:meeyao_qianwen/l10n/app_localizations.dart';
|
2026-04-03 16:56:47 +08:00
|
|
|
|
|
|
|
|
|
|
void main() {
|
2026-04-06 01:28:10 +08:00
|
|
|
|
DivinationResultData buildResultData() {
|
2026-04-03 19:04:46 +08:00
|
|
|
|
final params = DivinationParams(
|
2026-04-03 16:56:47 +08:00
|
|
|
|
method: DivinationMethod.auto,
|
|
|
|
|
|
questionType: QuestionType.health,
|
|
|
|
|
|
question: '近期状态是否平稳',
|
2026-04-03 19:04:46 +08:00
|
|
|
|
divinationTime: DateTime(2026, 4, 3, 20, 30),
|
|
|
|
|
|
coinBalance: 10,
|
|
|
|
|
|
userId: 'u_test',
|
2026-04-03 16:56:47 +08:00
|
|
|
|
);
|
2026-04-06 01:28:10 +08:00
|
|
|
|
return DivinationResultData(
|
2026-04-03 16:56:47 +08:00
|
|
|
|
params: params,
|
2026-04-03 19:04:46 +08:00
|
|
|
|
binaryCode: '101001',
|
|
|
|
|
|
changedBinaryCode: '100001',
|
|
|
|
|
|
guaName: '山火贲',
|
|
|
|
|
|
targetGuaName: '山雷颐',
|
|
|
|
|
|
upperName: '艮',
|
|
|
|
|
|
lowerName: '离',
|
|
|
|
|
|
signType: '中上签',
|
|
|
|
|
|
keywords: '稳中求进、审时度势、蓄势待发',
|
|
|
|
|
|
conclusion: '1. 方向可行\n2. 节奏宜稳',
|
|
|
|
|
|
analysis: '当前阶段需先稳住节奏,再做关键推进。',
|
|
|
|
|
|
suggestion: '1. 控节奏\n2. 重复盘',
|
|
|
|
|
|
ganzhi: GanzhiData(
|
|
|
|
|
|
yearGanZhi: '丙午',
|
|
|
|
|
|
monthGanZhi: '辛卯',
|
|
|
|
|
|
dayGanZhi: '丁未',
|
|
|
|
|
|
timeGanZhi: '庚戌',
|
|
|
|
|
|
yearKongWang: '子丑',
|
|
|
|
|
|
monthKongWang: '戌亥',
|
|
|
|
|
|
dayKongWang: '寅卯',
|
|
|
|
|
|
timeKongWang: '寅卯',
|
|
|
|
|
|
yueJian: '卯木',
|
|
|
|
|
|
riChen: '未土',
|
|
|
|
|
|
yuePo: '酉金',
|
|
|
|
|
|
riChong: '丑土',
|
|
|
|
|
|
),
|
|
|
|
|
|
wuXingStatus: {'木': '旺', '火': '相', '土': '休', '金': '囚', '水': '死'},
|
|
|
|
|
|
yaoLines: [
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 0,
|
|
|
|
|
|
spirit: '龙',
|
|
|
|
|
|
relation: '父母',
|
|
|
|
|
|
branch: '卯',
|
|
|
|
|
|
element: '木',
|
|
|
|
|
|
type: YaoType.oldYin,
|
|
|
|
|
|
mark: '世',
|
|
|
|
|
|
),
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 1,
|
|
|
|
|
|
spirit: '雀',
|
|
|
|
|
|
relation: '兄弟',
|
|
|
|
|
|
branch: '丑',
|
|
|
|
|
|
element: '土',
|
|
|
|
|
|
type: YaoType.youngYang,
|
|
|
|
|
|
mark: '',
|
|
|
|
|
|
),
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 2,
|
|
|
|
|
|
spirit: '勾',
|
|
|
|
|
|
relation: '妻财',
|
|
|
|
|
|
branch: '亥',
|
|
|
|
|
|
element: '水',
|
|
|
|
|
|
type: YaoType.youngYin,
|
|
|
|
|
|
mark: '',
|
|
|
|
|
|
),
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 3,
|
|
|
|
|
|
spirit: '蛇',
|
|
|
|
|
|
relation: '妻财',
|
|
|
|
|
|
branch: '酉',
|
|
|
|
|
|
element: '金',
|
|
|
|
|
|
type: YaoType.oldYang,
|
|
|
|
|
|
mark: '应',
|
|
|
|
|
|
),
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 4,
|
|
|
|
|
|
spirit: '虎',
|
|
|
|
|
|
relation: '子孙',
|
|
|
|
|
|
branch: '未',
|
|
|
|
|
|
element: '土',
|
|
|
|
|
|
type: YaoType.youngYang,
|
|
|
|
|
|
mark: '',
|
|
|
|
|
|
),
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 5,
|
|
|
|
|
|
spirit: '玄',
|
|
|
|
|
|
relation: '兄弟',
|
|
|
|
|
|
branch: '巳',
|
|
|
|
|
|
element: '火',
|
|
|
|
|
|
type: YaoType.oldYin,
|
|
|
|
|
|
mark: '',
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
targetYaoLines: [
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 0,
|
|
|
|
|
|
spirit: '龙',
|
|
|
|
|
|
relation: '父母',
|
|
|
|
|
|
branch: '子',
|
|
|
|
|
|
element: '水',
|
|
|
|
|
|
type: YaoType.youngYang,
|
|
|
|
|
|
mark: '世',
|
|
|
|
|
|
),
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 1,
|
|
|
|
|
|
spirit: '雀',
|
|
|
|
|
|
relation: '兄弟',
|
|
|
|
|
|
branch: '丑',
|
|
|
|
|
|
element: '土',
|
|
|
|
|
|
type: YaoType.youngYang,
|
|
|
|
|
|
mark: '',
|
|
|
|
|
|
),
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 2,
|
|
|
|
|
|
spirit: '勾',
|
|
|
|
|
|
relation: '妻财',
|
|
|
|
|
|
branch: '亥',
|
|
|
|
|
|
element: '水',
|
|
|
|
|
|
type: YaoType.youngYin,
|
|
|
|
|
|
mark: '',
|
|
|
|
|
|
),
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 3,
|
|
|
|
|
|
spirit: '蛇',
|
|
|
|
|
|
relation: '妻财',
|
|
|
|
|
|
branch: '申',
|
|
|
|
|
|
element: '金',
|
|
|
|
|
|
type: YaoType.youngYin,
|
|
|
|
|
|
mark: '应',
|
|
|
|
|
|
),
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 4,
|
|
|
|
|
|
spirit: '虎',
|
|
|
|
|
|
relation: '子孙',
|
|
|
|
|
|
branch: '未',
|
|
|
|
|
|
element: '土',
|
|
|
|
|
|
type: YaoType.youngYang,
|
|
|
|
|
|
mark: '',
|
|
|
|
|
|
),
|
|
|
|
|
|
YaoLineData(
|
|
|
|
|
|
index: 5,
|
|
|
|
|
|
spirit: '玄',
|
|
|
|
|
|
relation: '兄弟',
|
|
|
|
|
|
branch: '午',
|
|
|
|
|
|
element: '火',
|
|
|
|
|
|
type: YaoType.youngYang,
|
|
|
|
|
|
mark: '',
|
|
|
|
|
|
),
|
2026-04-03 16:56:47 +08:00
|
|
|
|
],
|
|
|
|
|
|
);
|
2026-04-06 01:28:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
testWidgets('result screen shows key sections', (tester) async {
|
|
|
|
|
|
final data = buildResultData();
|
2026-04-03 16:56:47 +08:00
|
|
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
|
|
MaterialApp(
|
|
|
|
|
|
theme: AppTheme.light(),
|
2026-04-03 19:04:46 +08:00
|
|
|
|
locale: const Locale('zh'),
|
|
|
|
|
|
localizationsDelegates: const [
|
|
|
|
|
|
AppLocalizations.delegate,
|
|
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
|
|
],
|
|
|
|
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
2026-04-03 16:56:47 +08:00
|
|
|
|
home: DivinationResultScreen(data: data),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
2026-04-03 19:04:46 +08:00
|
|
|
|
await tester.pump(const Duration(milliseconds: 1000));
|
|
|
|
|
|
await tester.pumpAndSettle();
|
2026-04-03 16:56:47 +08:00
|
|
|
|
|
|
|
|
|
|
expect(find.text('解卦结果'), findsOneWidget);
|
|
|
|
|
|
expect(find.text('AI解卦'), findsOneWidget);
|
|
|
|
|
|
expect(find.text('基础信息'), findsOneWidget);
|
|
|
|
|
|
expect(find.text('卦象详情'), findsOneWidget);
|
|
|
|
|
|
expect(find.text('解卦结论'), findsOneWidget);
|
|
|
|
|
|
expect(find.text('○ 老阳(变)'), findsOneWidget);
|
|
|
|
|
|
expect(find.text('× 老阴(变)'), findsOneWidget);
|
|
|
|
|
|
expect(find.text('○'), findsWidgets);
|
|
|
|
|
|
expect(find.text('×'), findsWidgets);
|
|
|
|
|
|
});
|
2026-04-06 01:28:10 +08:00
|
|
|
|
|
|
|
|
|
|
testWidgets('result screen back returns directly to root home', (
|
|
|
|
|
|
tester,
|
|
|
|
|
|
) async {
|
|
|
|
|
|
final data = buildResultData();
|
|
|
|
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
|
|
MaterialApp(
|
|
|
|
|
|
theme: AppTheme.light(),
|
|
|
|
|
|
locale: const Locale('zh'),
|
|
|
|
|
|
localizationsDelegates: const [
|
|
|
|
|
|
AppLocalizations.delegate,
|
|
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
|
|
],
|
|
|
|
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
|
|
|
|
home: Builder(
|
|
|
|
|
|
builder: (context) {
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
|
body: Center(
|
|
|
|
|
|
child: FilledButton(
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
Navigator.of(context).push<void>(
|
|
|
|
|
|
MaterialPageRoute<void>(
|
|
|
|
|
|
builder: (_) => DivinationResultScreen(data: data),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
child: const Text('open_result'),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.text('open_result'));
|
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
await tester.pump(const Duration(milliseconds: 1000));
|
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
|
|
expect(find.byType(DivinationResultScreen), findsOneWidget);
|
|
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.byIcon(Icons.arrow_back_ios_new_rounded));
|
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
|
|
expect(find.text('open_result'), findsOneWidget);
|
|
|
|
|
|
expect(find.byType(DivinationResultScreen), findsNothing);
|
|
|
|
|
|
});
|
2026-04-03 16:56:47 +08:00
|
|
|
|
}
|