Files
jiu/client/test/golden/finance_golden_test.dart
T
wangjia ae447f61e3 feat(client): 财务屏设计语言重建(KpiCard + StatusPill 徽章 + token 清扫)
- 3 张汇总卡 _SummaryCard → KpiCard(合计/未结清/已结清,info/warn/ok)
- _StatusBadge / _TypeBadge → StatusPill(结清状态 + 应收/应付/收款/付款,
  硬编码 E3F2FD/FFEBEE/E8F5E9/FFF3E0/F5F5F5 全清,走 token)
- _OfflineBanner 离线条 FFF8E1/F57F17 → warnBg/warn
- 整屏 golden ×三主题(桌面+移动)入回归闸;该屏 0 硬编码色残留

analyze 0 error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSKEiHsvauyxYUW2itzUXX
2026-06-25 13:38:41 +08:00

75 lines
2.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:jiu_client/core/models/page_result.dart';
import 'package:jiu_client/core/auth/auth_state.dart';
import 'package:jiu_client/models/finance.dart';
import 'package:jiu_client/providers/finance_provider.dart';
import 'package:jiu_client/repositories/finance_repository.dart';
import 'package:jiu_client/screens/finance/finance_screen.dart';
import '../support/golden_harness.dart';
/// design-distill 阶段4:财务整屏 golden × 三主题(桌面 + 移动)。
/// 验证类型徽章(应收/应付/收款/付款)+ 结清状态徽章 → StatusPill 随主题换色。
/// 更新基准:flutter test --update-goldens test/golden/finance_golden_test.dart
const _records = [
FinanceRecord(
id: 1, type: 'receivable', amount: 126800, balance: 126800,
status: 'open', partnerName: '鼎丰超市', recordDate: '2026-06-20'),
FinanceRecord(
id: 2, type: 'payable', amount: 152600, balance: 0,
status: 'closed', partnerName: '老窖酒水批发', recordDate: '2026-06-18'),
FinanceRecord(
id: 3, type: 'receipt', amount: 54200, balance: 0,
status: 'closed', partnerName: '金樽酒楼', recordDate: '2026-06-15'),
FinanceRecord(
id: 4, type: 'payment', amount: 88400, balance: 88400,
status: 'open', partnerName: '汾酒山西直营', recordDate: '2026-06-12'),
];
// 财务屏经 FutureBuilder 直读 repository,故覆盖 repoimplements + noSuchMethod
// 只实现 listRecords,其余方法 golden 静态渲染不会触达)。
class _FakeFinanceRepo implements FinanceRepository {
@override
Future<PageResult<FinanceRecord>> listRecords({
String? type,
String? month,
int page = 1,
int pageSize = 50,
}) async =>
const PageResult(data: _records, total: 4, page: 1, pageSize: 20);
@override
dynamic noSuchMethod(Invocation invocation) =>
super.noSuchMethod(invocation);
}
List<Override> _overrides() => [
financeRepositoryProvider.overrideWithValue(_FakeFinanceRepo()),
isReadonlyProvider.overrideWithValue(false),
];
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
SharedPreferences.setMockInitialValues({});
goldenAcrossThemes(
'finance 整屏(桌面)',
goldenPrefix: 'finance',
child: () => const Scaffold(body: FinanceScreen()),
overrides: _overrides,
logical: const Size(1280, 900),
);
goldenAcrossThemes(
'finance 整屏(移动)',
goldenPrefix: 'finance_mobile',
child: () => const Scaffold(body: FinanceScreen()),
overrides: _overrides,
logical: const Size(390, 1300),
);
}