44c985e6b5
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
115 lines
4.1 KiB
Dart
115 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:jiu_client/core/theme/themes.dart';
|
|
import 'package:jiu_client/widgets/order_detail_drawer.dart';
|
|
|
|
/// 2026-07 定价重设计:出库详情按角色两种形态——
|
|
/// 管理员(行带 cost/profit)= 成本价/售价/利润 三数值列 + 合计利润;
|
|
/// operator(不带)= 售价/小计两列,无成本无利润。
|
|
///
|
|
/// 2026-07-14:明细新增「生产日期 / 批次号」双行列(入库 5→6 列 / 出库管理员
|
|
/// 7→8 列),两种形态下都固定渲染,与成本/利润的角色可见性无关。
|
|
void main() {
|
|
Widget host(OrderDetailDrawer drawer) => MaterialApp(
|
|
theme: buildTheme('a'),
|
|
home: Scaffold(body: drawer),
|
|
);
|
|
|
|
const line6 = OrderLine(
|
|
name: '汾酒青花20年',
|
|
code: 'ZXZ027232',
|
|
series: '普通/53度',
|
|
spec: '500ml*6/件',
|
|
qty: '2',
|
|
price: '¥400.00',
|
|
amount: '¥800.00',
|
|
cost: '¥355.00',
|
|
profit: '¥90.00',
|
|
productionDate: '2021-01-27',
|
|
batchNo: '20260506',
|
|
);
|
|
|
|
const line4 = OrderLine(
|
|
name: '汾酒青花20年',
|
|
code: 'ZXZ027232',
|
|
series: '普通/53度',
|
|
spec: '500ml*6/件',
|
|
qty: '2',
|
|
price: '¥400.00',
|
|
amount: '¥800.00',
|
|
productionDate: '2021-01-27',
|
|
batchNo: '20260506',
|
|
);
|
|
|
|
testWidgets('管理员形态:成本价/售价/利润列 + 生产日期/批次号列 + 合计利润', (tester) async {
|
|
await tester.pumpWidget(host(OrderDetailDrawer(
|
|
title: 'CK001',
|
|
infoRows: const [],
|
|
linesLabel: '出库明细',
|
|
lines: const [line6],
|
|
totalText: '¥800.00',
|
|
profitText: '¥90.00',
|
|
priceLabel: '售价',
|
|
amountLabel: '小计',
|
|
actionGroups: const [],
|
|
)));
|
|
expect(find.text('成本价'), findsOneWidget);
|
|
expect(find.text('售价'), findsOneWidget);
|
|
expect(find.text('总售价'), findsOneWidget);
|
|
expect(find.text('¥800.00'), findsNWidgets(2)); // 行总售价 + 合计金额
|
|
expect(find.text('利润'), findsOneWidget);
|
|
expect(find.text('¥355.00'), findsOneWidget);
|
|
expect(find.text('¥90.00'), findsNWidgets(2)); // 行利润 + 合计利润
|
|
expect(find.text('合计利润 '), findsOneWidget);
|
|
expect(find.text('生产日期 / 批次号'), findsOneWidget);
|
|
expect(find.text('2021-01-27'), findsOneWidget);
|
|
expect(find.text('20260506'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('operator 形态:售价/小计 + 生产日期/批次号列,无成本无利润', (tester) async {
|
|
await tester.pumpWidget(host(OrderDetailDrawer(
|
|
title: 'CK001',
|
|
infoRows: const [],
|
|
linesLabel: '出库明细',
|
|
lines: const [line4],
|
|
totalText: '¥800.00',
|
|
priceLabel: '售价',
|
|
amountLabel: '小计',
|
|
actionGroups: const [],
|
|
)));
|
|
expect(find.text('售价'), findsOneWidget);
|
|
expect(find.text('小计'), findsOneWidget);
|
|
expect(find.text('成本价'), findsNothing);
|
|
expect(find.text('利润'), findsNothing);
|
|
expect(find.text('合计利润 '), findsNothing);
|
|
expect(find.text('¥800.00'), findsNWidgets(2)); // 行小计 + 合计金额
|
|
expect(find.text('生产日期 / 批次号'), findsOneWidget);
|
|
expect(find.text('2021-01-27'), findsOneWidget);
|
|
expect(find.text('20260506'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('生产日期/批次号两值都空时,桌面列仍渲染但单元格显示 —', (tester) async {
|
|
const lineEmpty = OrderLine(
|
|
name: '汾酒青花20年',
|
|
code: 'ZXZ027232',
|
|
series: '普通/53度',
|
|
spec: '500ml*6/件',
|
|
qty: '2',
|
|
price: '¥400.00',
|
|
amount: '¥800.00',
|
|
);
|
|
await tester.pumpWidget(host(OrderDetailDrawer(
|
|
title: 'RK001',
|
|
infoRows: const [],
|
|
linesLabel: '入库明细',
|
|
lines: const [lineEmpty],
|
|
totalText: '¥800.00',
|
|
priceLabel: '进价(单瓶)',
|
|
amountLabel: '总价',
|
|
actionGroups: const [],
|
|
)));
|
|
expect(find.text('生产日期 / 批次号'), findsOneWidget);
|
|
expect(find.text('—'), findsNWidgets(2)); // 生产日期 + 批次号均兜底
|
|
});
|
|
}
|