6238b86dcb
- 登录/注册(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
118 lines
3.9 KiB
Dart
118 lines
3.9 KiB
Dart
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/models/product.dart';
|
||
import 'package:jiu_client/models/inventory.dart';
|
||
import 'package:jiu_client/providers/product_provider.dart';
|
||
import 'package:jiu_client/providers/inventory_provider.dart';
|
||
import 'package:jiu_client/repositories/product_repository.dart';
|
||
import 'package:jiu_client/repositories/inventory_repository.dart';
|
||
import 'package:jiu_client/screens/products/product_detail_screen.dart';
|
||
|
||
import '../support/golden_harness.dart';
|
||
|
||
/// design-distill 阶段4:商品详情「富数据版」golden × 三主题。
|
||
/// 验证 3 KPI(当前库存/货值/近30天出库)+ 各仓库分布 + 近期流水(接后端
|
||
/// /inventory?product_id + /inventory/logs?product_id 聚合)。
|
||
/// 更新基准:flutter test --update-goldens test/golden/product_detail_golden_test.dart
|
||
|
||
class _FakeProductRepo implements ProductRepository {
|
||
@override
|
||
Future<Product> getDetail(int id) async => const Product(
|
||
id: 1,
|
||
code: 'MT-FT-500',
|
||
name: '茅台 飞天 53°',
|
||
unit: '件',
|
||
series: '飞天',
|
||
spec: '500ml×6',
|
||
brand: '茅台',
|
||
purchasePrice: 2680,
|
||
categoryName: '酱香');
|
||
@override
|
||
Future<List<({String date, double price})>> getPriceHistory(int id) async =>
|
||
const [
|
||
(date: '2026-06-12', price: 2680),
|
||
(date: '2026-04-20', price: 2620),
|
||
(date: '2026-02-08', price: 2700),
|
||
(date: '2025-11-15', price: 2580),
|
||
];
|
||
@override
|
||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||
}
|
||
|
||
class _FakeInvRepo implements InventoryRepository {
|
||
@override
|
||
Future<PageResult<Inventory>> listInventory({
|
||
int? warehouseId,
|
||
int? productId,
|
||
String? keyword,
|
||
String? code,
|
||
List<String>? series,
|
||
List<String>? spec,
|
||
int page = 1,
|
||
int pageSize = 50,
|
||
}) async =>
|
||
const PageResult(data: [
|
||
Inventory(id: 1, productId: 1, quantity: 92, warehouseName: '主仓'),
|
||
Inventory(id: 2, productId: 1, quantity: 28, warehouseName: '二号仓'),
|
||
Inventory(id: 3, productId: 1, quantity: 8, warehouseName: '冷藏库'),
|
||
], total: 3, page: 1, pageSize: 1000);
|
||
|
||
@override
|
||
Future<PageResult<InventoryLog>> listLogs({
|
||
int? warehouseId,
|
||
int? productId,
|
||
int page = 1,
|
||
int pageSize = 50,
|
||
}) async =>
|
||
const PageResult(data: [
|
||
InventoryLog(
|
||
warehouseId: 1,
|
||
productId: 1,
|
||
direction: 'in',
|
||
quantity: 24,
|
||
createdAt: '2026-06-20T09:00:00'),
|
||
InventoryLog(
|
||
warehouseId: 1,
|
||
productId: 1,
|
||
direction: 'out',
|
||
quantity: 12,
|
||
createdAt: '2026-06-18T09:00:00'),
|
||
InventoryLog(
|
||
warehouseId: 2,
|
||
productId: 1,
|
||
direction: 'out',
|
||
quantity: 18,
|
||
createdAt: '2026-06-15T09:00:00'),
|
||
InventoryLog(
|
||
warehouseId: 1,
|
||
productId: 1,
|
||
direction: 'in',
|
||
quantity: 36,
|
||
createdAt: '2026-06-12T09:00:00'),
|
||
], total: 4, page: 1, pageSize: 100);
|
||
|
||
@override
|
||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||
}
|
||
|
||
List<Override> _overrides() => [
|
||
productRepositoryProvider.overrideWithValue(_FakeProductRepo()),
|
||
inventoryRepositoryProvider.overrideWithValue(_FakeInvRepo()),
|
||
];
|
||
|
||
void main() {
|
||
TestWidgetsFlutterBinding.ensureInitialized();
|
||
SharedPreferences.setMockInitialValues({});
|
||
|
||
goldenAcrossThemes(
|
||
'product detail 富数据(桌面)',
|
||
goldenPrefix: 'product_detail',
|
||
child: () => const Scaffold(body: ProductDetailScreen(productId: 1)),
|
||
overrides: _overrides,
|
||
logical: const Size(1100, 1300),
|
||
);
|
||
}
|