Files
jiu/client/test/golden/finance_golden_test.dart
T
wangjia 6238b86dcb feat(client): 登录/注册页照原型重建,ds 真相源组件族统一全部屏
- 登录/注册(login.html/register.html 1:1):两栏卡片+品牌渐变面板+主题小衣服
  pill(onSurface 变体)+记住我(记录并预填最近账号)+原型式 toast 校验;
  登录 fidelity 1.4–2.1% 三主题全绿;注册暂不入闸(少 门店编号/兑换券 字段,
  已记 CONTRACT,screens.mjs 留存根)
- ds 原子补齐:DsToast(.toast 单例)/DsCheck(.check/.agree)/DsButton lg 档/
  DsSelect 替换全部旧 DropdownButton/DsField label 在上/DsInput 后缀与密码形态
- 全屏统一:对话框按钮全 DsButton、盒式输入主题钉死(visualDensity.standard、
  h38、InputDecorationTheme 渗漏修复)、图标全 lucide、JetBrains Mono 三端同源、
  BrandMark 真相源 logo、只读模式写操作全量守卫(WriteGuard+DsToast)
- 出入库列表:版式对齐原型(卡片对齐+搜索框居中)、KPI 近30天滚动、结清后
  失效财务应收应付表;商品编辑抽屉介绍库改搜索下拉、图片双击全屏预览
- 删除旧 UI 死代码:DataTableCard/FormDialog/PageScaffold/SearchChip/
  SelectProductDialog/tabStateProvider
- golden/fidelity:stock-in/out 补注册(9%)、login 入册(8%)、goldens 全量重打;
  修复 pubspec flutter_web_plugins 非法声明(CI pub get 阻断)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o
2026-07-03 09:58:14 +08:00

197 lines
6.5 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/auth/auth_state.dart';
import 'package:jiu_client/core/models/page_result.dart';
import 'package:jiu_client/core/utils/clock.dart';
import 'package:jiu_client/models/finance.dart';
import 'package:jiu_client/models/stock_summary.dart';
import 'package:jiu_client/providers/finance_provider.dart';
import 'package:jiu_client/providers/stock_in_provider.dart';
import 'package:jiu_client/providers/stock_out_provider.dart';
import 'package:jiu_client/screens/finance/finance_screen.dart';
import '../support/golden_harness.dart';
import '../support/shell_harness.dart';
/// design-distill 阶段4:财务管理 golden × 三主题(回归闸 + 保真基准)。
/// 桌面版挂进真 AppShell,数据照抄原型 screens/finance.html 的
/// TREND6 月)/ SUMMARY8 单位)/ FLOWS10 条);KPI 环比经 stock summary
/// 假数据凑成 ▲8.4% / ▼3.1%
/// node tools/fidelity.mjs finance
/// 更新基准:flutter test --update-goldens test/golden/finance_golden_test.dart
// 原型 TREND(万元 → 元)
const _trend = [
TrendPoint(month: '2026-01', inAmount: 1420000, outAmount: 1180000),
TrendPoint(month: '2026-02', inAmount: 960000, outAmount: 880000),
TrendPoint(month: '2026-03', inAmount: 1680000, outAmount: 1210000),
TrendPoint(month: '2026-04', inAmount: 1540000, outAmount: 1090000),
TrendPoint(month: '2026-05', inAmount: 1720000, outAmount: 1360000),
TrendPoint(month: '2026-06', inAmount: 1860000, outAmount: 1320000),
];
// 原型 SUMMARY 8 行
const _rows = [
PartnerFinanceRow(partnerId: 1, name: '华东酒类批发', recv: 128400, openCount: 2),
PartnerFinanceRow(partnerId: 2, name: '金樽商贸', recv: 86200, openCount: 1),
PartnerFinanceRow(partnerId: 3, name: '茅台华南经销', pay: 142800, openCount: 1),
PartnerFinanceRow(partnerId: 4, name: '鸿运餐饮连锁', recv: 74600, openCount: 1),
PartnerFinanceRow(partnerId: 5, name: '五粮液省级代理', pay: 96400, openCount: 1),
PartnerFinanceRow(
partnerId: 6, name: '盛世名酒城', recv: 52300, pay: 18600, openCount: 2),
PartnerFinanceRow(partnerId: 7, name: '御品烟酒行', recv: 31800, openCount: 1),
PartnerFinanceRow(partnerId: 8, name: '川渝糖酒集团', pay: 60400, openCount: 1),
];
// 原型 FLOWS 10 条(收款→receipt / 付款→payment;原型 SK/FK 单号无对应
// ref 模型 → 关联单号列显 —,属已知差异)
const _flows = [
FinanceRecord(
id: 1,
type: 'receipt',
amount: 68000,
balance: 0,
status: 'closed',
partnerName: '华东酒类批发',
recordDate: '2026-06-20',
remark: '飞天茅台货款'),
FinanceRecord(
id: 2,
type: 'payment',
amount: 142800,
balance: 0,
status: 'closed',
partnerName: '茅台华南经销',
recordDate: '2026-06-19',
remark: '6月采购结算'),
FinanceRecord(
id: 3,
type: 'receipt',
amount: 42600,
balance: 0,
status: 'closed',
partnerName: '金樽商贸',
recordDate: '2026-06-18',
remark: '五粮液尾款'),
FinanceRecord(
id: 4,
type: 'receipt',
amount: 31500,
balance: 0,
status: 'closed',
partnerName: '鸿运餐饮连锁',
recordDate: '2026-06-17',
remark: '宴会用酒'),
FinanceRecord(
id: 5,
type: 'payment',
amount: 96400,
balance: 0,
status: 'closed',
partnerName: '五粮液省级代理',
recordDate: '2026-06-16',
remark: '普五补货'),
FinanceRecord(
id: 6,
type: 'receipt',
amount: 23800,
balance: 0,
status: 'closed',
partnerName: '盛世名酒城',
recordDate: '2026-06-15',
remark: '国窖1573'),
FinanceRecord(
id: 7,
type: 'payment',
amount: 60400,
balance: 0,
status: 'closed',
partnerName: '川渝糖酒集团',
recordDate: '2026-06-14',
remark: '剑南春进货'),
FinanceRecord(
id: 8,
type: 'receipt',
amount: 18900,
balance: 0,
status: 'closed',
partnerName: '御品烟酒行',
recordDate: '2026-06-13',
remark: '习酒窖藏'),
FinanceRecord(
id: 9,
type: 'payment',
amount: 18600,
balance: 0,
status: 'closed',
partnerName: '盛世名酒城',
recordDate: '2026-06-12',
remark: '退换货补差'),
FinanceRecord(
id: 10,
type: 'receipt',
amount: 55200,
balance: 0,
status: 'closed',
partnerName: '华东酒类批发',
recordDate: '2026-06-11',
remark: '梦之蓝M6'),
];
class _FakeFinanceList extends FinanceListNotifier {
@override
Future<PageResult<FinanceRecord>> build() async =>
const PageResult(data: _flows, total: 10, page: 1, pageSize: 50);
@override
void setType(String type) {}
@override
void setMonth(String month) {}
@override
void setRange(String startDate, String endDate) {}
@override
void setPage(int page) {}
@override
void setPageSize(int pageSize) {}
@override
void reload() {}
}
List<Override> _overrides() => [
financeListProvider.overrideWith(() => _FakeFinanceList()),
financeTrendProvider.overrideWith((ref) async => _trend),
financePartnerRowsProvider.overrideWith((ref) async => _rows),
// 环比凑成原型 ▲8.4% / ▼3.1%
stockOutSummaryProvider.overrideWith((ref) async =>
const StockSummary(monthAmount: 1860000, lastMonthAmount: 1715867)),
stockInSummaryProvider.overrideWith((ref) async =>
const StockSummary(monthAmount: 1320000, lastMonthAmount: 1362229)),
isReadonlyProvider.overrideWithValue(false),
];
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
SharedPreferences.setMockInitialValues({});
appClock = () => DateTime(2026, 7, 13, 9, 30, 15);
// 桌面:外壳挂载整框,与原型整页同构
shellGoldenAcrossThemes(
'finance 整框(桌面)',
path: '/finance',
screen: (_) => const FinanceScreen(),
goldenPrefix: 'finance',
overrides: _overrides,
logical: const Size(1280, 900),
);
// 移动:窄屏单列(KPI 横滚 + 卡片流)
goldenAcrossThemes(
'finance 整屏(移动)',
goldenPrefix: 'finance_mobile',
child: () => const Scaffold(body: FinanceScreen()),
overrides: _overrides,
logical: const Size(390, 1600),
);
}