已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
This commit is contained in:
93
apps/user_app/test/data/wallet_account_test.dart
Normal file
93
apps/user_app/test/data/wallet_account_test.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
// 功能描述:银行卡与提现接口契约、金额精度和会话隔离测试;版本:1.0.0。
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:user_app/data/repositories/client_repository.dart';
|
||||
import 'package:user_app/data/services/api_client.dart';
|
||||
import 'package:user_app/domain/models/wallet_account.dart';
|
||||
|
||||
void main() {
|
||||
test('提现金额按整数分解析,不接受超两位小数和指数', () {
|
||||
expect(parseWithdrawalAmount('300'), 30000);
|
||||
expect(parseWithdrawalAmount('10.08'), 1008);
|
||||
expect(parseWithdrawalAmount('1.001'), isNull);
|
||||
expect(parseWithdrawalAmount('1e3'), isNull);
|
||||
});
|
||||
|
||||
test('银行卡列表只读取服务端脱敏字段', () async {
|
||||
var requestedPath = '';
|
||||
final repo = ClientRepository(
|
||||
ApiClient(
|
||||
() => 'token',
|
||||
client: MockClient((request) async {
|
||||
requestedPath = request.url.path;
|
||||
return http.Response.bytes(
|
||||
utf8.encode(
|
||||
jsonEncode({
|
||||
'code': 0,
|
||||
'details': [
|
||||
{
|
||||
'identity': 'b1',
|
||||
'card_no_masked': '**** **** **** 2868',
|
||||
'bank_name': '中国建设银行',
|
||||
'card_owner': '张先生',
|
||||
'bank_type': 'debit',
|
||||
'is_default': true,
|
||||
},
|
||||
],
|
||||
}),
|
||||
),
|
||||
200,
|
||||
headers: {'content-type': 'application/json; charset=utf-8'},
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
final bank = (await repo.walletBanks()).single;
|
||||
expect(requestedPath, '/heqi/client/v1/user/wallet/banks');
|
||||
expect(bank.maskedNumber, endsWith('2868'));
|
||||
expect(bank.typeName, '储蓄卡');
|
||||
expect(bank.isDefault, isTrue);
|
||||
});
|
||||
|
||||
test('提现请求使用公开银行卡标识、整数分和幂等号', () async {
|
||||
final repo = ClientRepository(
|
||||
ApiClient(
|
||||
() => 'token',
|
||||
client: MockClient((request) async {
|
||||
expect(request.method, 'POST');
|
||||
expect(request.url.path, '/heqi/client/v1/user/wallet/withdrawals');
|
||||
expect(jsonDecode(request.body), {
|
||||
'bank_identity': 'b1',
|
||||
'amount': 30000,
|
||||
'request_no': 'request-1',
|
||||
'payment_password': '123456',
|
||||
});
|
||||
return http.Response(
|
||||
jsonEncode({
|
||||
'code': 0,
|
||||
'details': {
|
||||
'identity': 'w1',
|
||||
'cash_no': 'WD1',
|
||||
'amount': 30000,
|
||||
'fee': 0,
|
||||
'apply_status': 10,
|
||||
'created_at': '2026-09-11T12:00:00+08:00',
|
||||
},
|
||||
}),
|
||||
200,
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
final result = await repo.createWalletWithdrawal(
|
||||
bankIdentity: 'b1',
|
||||
amount: 30000,
|
||||
requestNo: 'request-1',
|
||||
paymentPassword: '123456',
|
||||
);
|
||||
expect(result.statusName, '待审核');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user