From 3573f015c30a4c282e93274f5c345dfe2d0d6687 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Mon, 6 Jul 2026 08:11:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(client):=20=E5=87=BA=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=BD=95=E5=8D=95=20golden=20=E9=9A=8F=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=BC=82=E7=A7=BB=E2=80=94=E2=80=94=E8=A1=A8=E5=8D=95=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=92=89=E6=AD=BB=E5=8D=95=E6=8D=AE=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:表单 _orderDate 默认 DateTime.now(),golden 07-04 录制后每天必挂 (整屏 diff 只有日期格一个数字)。表单加 initialDate 测试注入口, golden 测试钉死 2026-07-04,基准图零重录、永不随日期漂移。 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o --- client/lib/screens/stock_in/stock_in_form_screen.dart | 7 +++++-- client/lib/screens/stock_out/stock_out_form_screen.dart | 7 +++++-- client/test/golden/stock_in_form_golden_test.dart | 4 ++-- client/test/golden/stock_out_form_golden_test.dart | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/client/lib/screens/stock_in/stock_in_form_screen.dart b/client/lib/screens/stock_in/stock_in_form_screen.dart index 82789de..57bf413 100644 --- a/client/lib/screens/stock_in/stock_in_form_screen.dart +++ b/client/lib/screens/stock_in/stock_in_form_screen.dart @@ -27,7 +27,10 @@ import '../../widgets/ds/ds_toast.dart'; /// 明细为可键盘操作的内联网格(名称/系列/规格可搜索+新增,生产日期/批次/数量/单价/售价内联编辑)。 class StockInFormScreen extends ConsumerStatefulWidget { final int? editOrderId; - const StockInFormScreen({super.key, this.editOrderId}); + + /// 仅供 golden 测试钉死单据日期(默认 DateTime.now() 会让 golden 随日期漂移)。 + final DateTime? initialDate; + const StockInFormScreen({super.key, this.editOrderId, this.initialDate}); @override ConsumerState createState() => _StockInFormScreenState(); @@ -39,7 +42,7 @@ class _StockInFormScreenState extends ConsumerState { final _warehouseFocus = FocusNode(); int? _warehouseId; int? _partnerId; - DateTime _orderDate = DateTime.now(); + late DateTime _orderDate = widget.initialDate ?? DateTime.now(); bool _submitting = false; bool _loadingEdit = false; StockInOrder? _loadedOrder; diff --git a/client/lib/screens/stock_out/stock_out_form_screen.dart b/client/lib/screens/stock_out/stock_out_form_screen.dart index 2bf55cc..b53bdf4 100644 --- a/client/lib/screens/stock_out/stock_out_form_screen.dart +++ b/client/lib/screens/stock_out/stock_out_form_screen.dart @@ -142,7 +142,10 @@ class _ItemRow { /// 明细行经「从库存批量选择」添加,商品/系列/规格/可用只读,仅数量、售价可内联编辑。 class StockOutFormScreen extends ConsumerStatefulWidget { final int? editOrderId; - const StockOutFormScreen({super.key, this.editOrderId}); + + /// 仅供 golden 测试钉死单据日期(默认 DateTime.now() 会让 golden 随日期漂移)。 + final DateTime? initialDate; + const StockOutFormScreen({super.key, this.editOrderId, this.initialDate}); @override ConsumerState createState() => _StockOutFormScreenState(); @@ -154,7 +157,7 @@ class _StockOutFormScreenState extends ConsumerState { final _warehouseFocus = FocusNode(); int? _warehouseId; int? _partnerId; - DateTime _orderDate = DateTime.now(); + late DateTime _orderDate = widget.initialDate ?? DateTime.now(); bool _submitting = false; bool _loadingEdit = false; Map _inventoryMap = {}; diff --git a/client/test/golden/stock_in_form_golden_test.dart b/client/test/golden/stock_in_form_golden_test.dart index 3af73a0..b5579db 100644 --- a/client/test/golden/stock_in_form_golden_test.dart +++ b/client/test/golden/stock_in_form_golden_test.dart @@ -73,7 +73,7 @@ void main() { goldenAcrossThemes( 'stock-in form 录单(桌面)', goldenPrefix: 'stock_in_form', - child: () => const Scaffold(body: StockInFormScreen()), + child: () => Scaffold(body: StockInFormScreen(initialDate: DateTime(2026, 7, 4))), overrides: _overrides, logical: const Size(1280, 920), ); @@ -81,7 +81,7 @@ void main() { goldenAcrossThemes( 'stock-in form 录单(移动)', goldenPrefix: 'stock_in_form_mobile', - child: () => const Scaffold(body: StockInFormScreen()), + child: () => Scaffold(body: StockInFormScreen(initialDate: DateTime(2026, 7, 4))), overrides: _overrides, logical: const Size(390, 1400), ); diff --git a/client/test/golden/stock_out_form_golden_test.dart b/client/test/golden/stock_out_form_golden_test.dart index 12e199a..434641c 100644 --- a/client/test/golden/stock_out_form_golden_test.dart +++ b/client/test/golden/stock_out_form_golden_test.dart @@ -53,7 +53,7 @@ void main() { goldenAcrossThemes( 'stock-out form 录单(桌面)', goldenPrefix: 'stock_out_form', - child: () => const Scaffold(body: StockOutFormScreen()), + child: () => Scaffold(body: StockOutFormScreen(initialDate: DateTime(2026, 7, 4))), overrides: _overrides, logical: const Size(1280, 920), ); @@ -61,7 +61,7 @@ void main() { goldenAcrossThemes( 'stock-out form 录单(移动)', goldenPrefix: 'stock_out_form_mobile', - child: () => const Scaffold(body: StockOutFormScreen()), + child: () => Scaffold(body: StockOutFormScreen(initialDate: DateTime(2026, 7, 4))), overrides: _overrides, logical: const Size(390, 1400), );