test(client): 整屏 golden 还原闸 + 可复用 golden 骨架(基建)
test/support/golden_harness.dart:pumpGolden(viewport=physical÷dpr/给足高度/ provider 覆盖)+ goldenAcrossThemes(A/B/C 三主题组)。 test/golden/inventory_list_golden_test.dart:库存列表整屏 × 三主题 golden (fake AsyncNotifier 喂 canned 数据 + isReadonly 覆盖 + SP mock),入库作回归闸。 保真目检:shoot 原型 + montage 与 goldens 并排(见 design-distill flutter-golden.md)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TSKEiHsvauyxYUW2itzUXX
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
@@ -0,0 +1,89 @@
|
||||
import 'package:flutter/material.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/inventory.dart';
|
||||
import 'package:jiu_client/models/product_option.dart';
|
||||
import 'package:jiu_client/providers/inventory_provider.dart';
|
||||
import 'package:jiu_client/providers/product_option_provider.dart';
|
||||
import 'package:jiu_client/screens/inventory/inventory_list_screen.dart';
|
||||
|
||||
import '../support/golden_harness.dart';
|
||||
|
||||
/// design-distill 阶段4:库存列表**整屏** golden × 三主题(回归闸)。
|
||||
/// 保真目检:另跑 shoot-prototype 截 screens/inventory.html,再用 montage.mjs
|
||||
/// 与 goldens/inventory_list_<theme>.png 并排比对。
|
||||
/// 更新基准:flutter test --update-goldens test/golden/inventory_list_golden_test.dart
|
||||
|
||||
const _items = [
|
||||
Inventory(
|
||||
id: 1, productId: 1, quantity: 128, productCode: 'MT-FT-500',
|
||||
productName: '茅台 飞天 53°', series: '飞天', spec: '500ml×6', unit: '件',
|
||||
warehouseName: '主仓', unitPrice: 2680, productionDate: '2024-07-11',
|
||||
batchNo: 'PZ240711', supplierName: '贵州茅台经销', minStock: 10,
|
||||
createdAt: '2026-06-14',
|
||||
),
|
||||
Inventory(
|
||||
id: 2, productId: 2, quantity: 8, productCode: 'JNC-SJ-500',
|
||||
productName: '剑南春 水晶剑', series: '水晶剑', spec: '500ml×6', unit: '件',
|
||||
warehouseName: '主仓', unitPrice: 438, productionDate: '2023-11-15',
|
||||
batchNo: 'PZ231115', supplierName: '绵竹剑南春', minStock: 10,
|
||||
createdAt: '2026-06-12',
|
||||
),
|
||||
Inventory(
|
||||
id: 3, productId: 3, quantity: 0, productCode: 'FJ-QH20-500',
|
||||
productName: '汾酒 青花 20', series: '青花20', spec: '500ml×6', unit: '件',
|
||||
warehouseName: '主仓', unitPrice: 420, productionDate: '2024-01-12',
|
||||
batchNo: 'PZ240112', supplierName: '山西杏花村', minStock: 10,
|
||||
createdAt: '2026-06-03',
|
||||
),
|
||||
];
|
||||
|
||||
class _FakeInvNotifier extends InventoryListNotifier {
|
||||
@override
|
||||
Future<PageResult<Inventory>> build() async =>
|
||||
const PageResult(data: _items, total: 3, page: 1, pageSize: 20);
|
||||
@override
|
||||
void setPage(int page) {}
|
||||
@override
|
||||
void setPageSize(int pageSize) {}
|
||||
@override
|
||||
void setWarehouseId(int? id) {}
|
||||
@override
|
||||
void setKeyword(String keyword) {}
|
||||
@override
|
||||
void setSeries(List<String> series) {}
|
||||
@override
|
||||
void setSpec(List<String> spec) {}
|
||||
@override
|
||||
void reload() {}
|
||||
}
|
||||
|
||||
class _FakeSeriesNotifier extends ProductSeriesListNotifier {
|
||||
@override
|
||||
Future<List<ProductSeriesOption>> build() async => const [];
|
||||
}
|
||||
|
||||
class _FakeSpecNotifier extends ProductSpecListNotifier {
|
||||
@override
|
||||
Future<List<ProductSpecOption>> build() async => const [];
|
||||
}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
|
||||
goldenAcrossThemes(
|
||||
'inventory list 整屏',
|
||||
goldenPrefix: 'inventory_list',
|
||||
child: () => const Scaffold(body: InventoryListScreen()),
|
||||
overrides: () => [
|
||||
inventoryListProvider.overrideWith(() => _FakeInvNotifier()),
|
||||
productSeriesListProvider.overrideWith(() => _FakeSeriesNotifier()),
|
||||
productSpecListProvider.overrideWith(() => _FakeSpecNotifier()),
|
||||
isReadonlyProvider.overrideWithValue(false),
|
||||
],
|
||||
logical: const Size(1280, 900),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user