feat: 接入起卦后端流程并完善积分扣减链路
This commit is contained in:
@@ -1,15 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meeyao_qianwen/app/app_theme.dart';
|
||||
import 'package:meeyao_qianwen/core/auth/session_store.dart';
|
||||
import 'package:meeyao_qianwen/data/network/api_client.dart';
|
||||
import 'package:meeyao_qianwen/data/storage/local_kv_store.dart';
|
||||
import 'package:meeyao_qianwen/features/divination/data/apis/divination_api.dart';
|
||||
import 'package:meeyao_qianwen/features/divination/data/models/divination_params.dart';
|
||||
import 'package:meeyao_qianwen/features/divination/data/services/divination_run_service.dart';
|
||||
import 'package:meeyao_qianwen/features/divination/presentation/screens/auto_divination_screen.dart';
|
||||
import 'package:meeyao_qianwen/features/divination/presentation/screens/divination_screen.dart';
|
||||
import 'package:meeyao_qianwen/features/divination/presentation/screens/manual_divination_screen.dart';
|
||||
import 'package:meeyao_qianwen/l10n/app_localizations.dart';
|
||||
|
||||
void main() {
|
||||
final runService = DivinationRunService(
|
||||
api: DivinationApi(apiClient: ApiClient(baseUrl: 'http://localhost:5775')),
|
||||
);
|
||||
final sessionStore = SessionStore(LocalKvStore());
|
||||
|
||||
testWidgets('divination screen navigates to auto screen', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(theme: AppTheme.light(), home: const DivinationScreen()),
|
||||
MaterialApp(
|
||||
theme: AppTheme.light(),
|
||||
locale: const Locale('zh'),
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: DivinationScreen(
|
||||
sessionStore: sessionStore,
|
||||
userId: 'user_test',
|
||||
runServiceOverride: runService,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.text('自动起卦'));
|
||||
@@ -25,15 +52,27 @@ void main() {
|
||||
testWidgets('auto screen keeps resolve button disabled initially', (
|
||||
tester,
|
||||
) async {
|
||||
final params = DivinationMockData.initial().copyWith(
|
||||
final params = DivinationParams(
|
||||
method: DivinationMethod.auto,
|
||||
questionType: QuestionType.career,
|
||||
question: '测试问题',
|
||||
divinationTime: DateTime(2026, 4, 3, 20, 30),
|
||||
coinBalance: 9,
|
||||
userId: 'user_test',
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.light(),
|
||||
home: AutoDivinationScreen(params: params),
|
||||
locale: const Locale('zh'),
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: AutoDivinationScreen(params: params, runService: runService),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -49,7 +88,22 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(theme: AppTheme.light(), home: const DivinationScreen()),
|
||||
MaterialApp(
|
||||
theme: AppTheme.light(),
|
||||
locale: const Locale('zh'),
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: DivinationScreen(
|
||||
sessionStore: sessionStore,
|
||||
userId: 'user_test',
|
||||
runServiceOverride: runService,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.enterText(find.byType(TextField), '近期感情是否稳定');
|
||||
|
||||
Reference in New Issue
Block a user