- boxing_models.dart: add BoxingMode, BoxingPhase, BoxingPageArguments - boxing_box_mutations.dart: box item add/replace/remove operations - boxing_calculations.dart: pure calculation helpers (quantities, validation) - boxing_status_presenter.dart: status bar text/dot determination - dialogs/cross_paichan_dialog.dart: cross-paichan confirmation dialog - widgets/boxing_notice_banners.dart: notice banner widgets - Add unit tests for mutations, calculations, and status presenter Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
82 lines
2.8 KiB
Dart
82 lines
2.8 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pad_scanner/pages/boxing/boxing_models.dart';
|
|
import 'package:pad_scanner/pages/boxing/boxing_status_presenter.dart';
|
|
import 'package:pad_scanner/widgets/status_bar.dart';
|
|
|
|
void main() {
|
|
BoxingStatusPresentation status({
|
|
bool isAutoProcessing = false,
|
|
bool isSubmitting = false,
|
|
bool isDuplicateBoxNo = false,
|
|
bool quantityTooHigh = false,
|
|
bool isEditingAssigned = false,
|
|
bool isDeletingAssigned = false,
|
|
bool hasPaichanSwitchNotice = false,
|
|
BoxingPhase phase = BoxingPhase.waiting,
|
|
bool isMultiCode = false,
|
|
bool hasVisibleManyToOneItems = false,
|
|
int remainingQuantity = 1,
|
|
String boxNoText = '1',
|
|
}) {
|
|
return boxingStatusFor(
|
|
isAutoProcessing: isAutoProcessing,
|
|
isSubmitting: isSubmitting,
|
|
isDuplicateBoxNo: isDuplicateBoxNo,
|
|
quantityTooHigh: quantityTooHigh,
|
|
isEditingAssigned: isEditingAssigned,
|
|
isDeletingAssigned: isDeletingAssigned,
|
|
hasPaichanSwitchNotice: hasPaichanSwitchNotice,
|
|
phase: phase,
|
|
isMultiCode: isMultiCode,
|
|
hasVisibleManyToOneItems: hasVisibleManyToOneItems,
|
|
remainingQuantity: remainingQuantity,
|
|
boxNoText: boxNoText,
|
|
);
|
|
}
|
|
|
|
group('boxingStatusFor', () {
|
|
test('reports waiting and multi-code continuation states', () {
|
|
expect(status().text, '等待扫码');
|
|
final multi = status(isMultiCode: true, hasVisibleManyToOneItems: true);
|
|
expect(multi.text, '请继续扫码或完成本箱');
|
|
});
|
|
|
|
test('prioritizes transient and validation states', () {
|
|
expect(status(isSubmitting: true).text, '正在提交…');
|
|
expect(
|
|
status(isDuplicateBoxNo: true, phase: BoxingPhase.scanned).dot,
|
|
StatusDotColor.amber,
|
|
);
|
|
expect(
|
|
status(quantityTooHigh: true, phase: BoxingPhase.scanned).text,
|
|
'超出可装数量上限',
|
|
);
|
|
});
|
|
|
|
test('reports edit delete and switched paichan states', () {
|
|
expect(status(isEditingAssigned: true).text, '正在编辑已分配记录');
|
|
expect(status(isDeletingAssigned: true).dot, StatusDotColor.red);
|
|
expect(status(hasPaichanSwitchNotice: true).text, '排产号已切换,箱号已重置');
|
|
});
|
|
|
|
test('reports scanned completed and submitted states', () {
|
|
expect(
|
|
status(phase: BoxingPhase.scanned, remainingQuantity: 0).text,
|
|
'该总排号已全部装箱完毕',
|
|
);
|
|
expect(
|
|
status(phase: BoxingPhase.scanned, remainingQuantity: 2).text,
|
|
'数量已填入,请确认或修改',
|
|
);
|
|
expect(
|
|
status(phase: BoxingPhase.submitted, isMultiCode: false).text,
|
|
'装箱成功,可继续扫码',
|
|
);
|
|
expect(
|
|
status(phase: BoxingPhase.submitted, isMultiCode: true).text,
|
|
'请扫描下一个总排号',
|
|
);
|
|
});
|
|
});
|
|
}
|