feat(app): 完成 P0 钱包解锁、下载落盘与手机号登录
This commit is contained in:
1 parent
de941c841c
commit
136ee74618
47 files changed
+3264
-70
No files matched your search
@@ -0,0 +1,101 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:fruitshorts/core/data/models/wallet.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/commerce_repository.dart';
|
||||
import 'package:fruitshorts/core/data/services/wallet_controller.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/wallet/wallet_page.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_show_server_balance_and_ledger_when_wallet_opens', (
|
||||
tester,
|
||||
) async {
|
||||
final controller = WalletController(_FakeCommerceRepository());
|
||||
|
||||
await tester.pumpWidget(
|
||||
ChangeNotifierProvider<WalletController>.value(
|
||||
value: controller,
|
||||
child: MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: const WalletPage(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('wallet-balance')), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('wallet-balance'))).data,
|
||||
'320',
|
||||
);
|
||||
expect(find.text('Episode unlock'), findsOneWidget);
|
||||
expect(find.text('-50'), findsOneWidget);
|
||||
expect(find.byKey(const Key('wallet-ledger-11')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_show_empty_ledger_copy_when_wallet_has_no_entries', (
|
||||
tester,
|
||||
) async {
|
||||
final controller = WalletController(
|
||||
_FakeCommerceRepository(includeLedger: false),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
ChangeNotifierProvider<WalletController>.value(
|
||||
value: controller,
|
||||
child: MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: const WalletPage(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('No coin activity yet.'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
class _FakeCommerceRepository implements CommerceRepository {
|
||||
_FakeCommerceRepository({this.includeLedger = true});
|
||||
|
||||
final bool includeLedger;
|
||||
|
||||
@override
|
||||
Future<WalletSnapshot> fetchWallet() async => WalletSnapshot(
|
||||
wallet: const CoinWallet(
|
||||
coinBalance: 320,
|
||||
totalRechargedCoin: 500,
|
||||
totalConsumedCoin: 180,
|
||||
totalRefundedCoin: 0,
|
||||
),
|
||||
ledger: includeLedger
|
||||
? [
|
||||
CoinLedgerEntry(
|
||||
id: '11',
|
||||
changeAmount: -50,
|
||||
balanceAfter: 320,
|
||||
bizType: 'UNLOCK',
|
||||
remark: '',
|
||||
createdAt: DateTime(2026, 10, 19, 10),
|
||||
),
|
||||
]
|
||||
: const [],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<UnlockResult> unlock(String episodeId) async =>
|
||||
const UnlockResult(
|
||||
unlocked: true,
|
||||
accessType: 'UNLOCKED',
|
||||
coinCost: 50,
|
||||
coinBalance: 270,
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user