feat:餐段设置

This commit is contained in:
dzc committed 2026-09-07 12:53:05 +08:00
1 parent 67950343a7
commit 07a3141934
14 files changed
+285 -18

No files matched your search

@@ -236,6 +236,81 @@ void main() {
expect(find.textContaining('当前选择的餐段可能有问题'), findsNothing);
expect(controller.value, {'2'});
});
testWidgets('禁止主动修改餐段时初始化静默切换为配置餐段且不弹框', (tester) async {
final controller = FRadioSelectGroupController<String>(value: '1');
addTearDown(controller.dispose);
await tester.pumpWidget(
_testApp(
Builder(
builder: (context) => appRadioHourTypeDialog(
context,
controller,
checkConfiguredTime: true,
allowManualChange: false,
ready: Future.value(),
currentHourTypeLoader: () async => ProductHourType.NOON,
),
),
),
);
await tester.pumpAndSettle();
expect(find.textContaining('当前选择的餐段可能有问题'), findsNothing);
expect(controller.value, {'2'});
});
testWidgets('禁止主动修改餐段时选择器禁用且无法打开餐段菜单', (tester) async {
final controller = FRadioSelectGroupController<String>(value: '2');
addTearDown(controller.dispose);
await tester.pumpWidget(
_testApp(
Builder(
builder: (context) => appRadioHourTypeDialog(
context,
controller,
checkConfiguredTime: true,
allowManualChange: false,
ready: Future.value(),
currentHourTypeLoader: () async => ProductHourType.NOON,
),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.byType(FSelectMenuTile<String>));
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('meal-slot-option-1')), findsNothing);
expect(controller.value, {'2'});
});
testWidgets('禁止主动修改餐段时当前时间未命中餐段配置则保持原选择', (tester) async {
final controller = FRadioSelectGroupController<String>(value: '1');
addTearDown(controller.dispose);
await tester.pumpWidget(
_testApp(
Builder(
builder: (context) => appRadioHourTypeDialog(
context,
controller,
checkConfiguredTime: true,
allowManualChange: false,
ready: Future.value(),
currentHourTypeLoader: () async => null,
),
),
),
);
await tester.pumpAndSettle();
expect(find.textContaining('当前选择的餐段可能有问题'), findsNothing);
expect(controller.value, {'1'});
});
}
Widget _testApp(Widget child) {
@@ -153,6 +153,10 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('库存 2'), findsOneWidget);
// 套餐组成默认收起,点击套餐主行展开后才能看到组成明细。
expect(find.text('时令青菜'), findsNothing);
await tester.tap(find.byKey(const ValueKey('checkout-combo-canteen-1')));
await tester.pumpAndSettle();
expect(find.text('时令青菜'), findsOneWidget);
expect(find.textContaining('可在支付前调整数量'), findsOneWidget);
expect(find.textContaining('确认支付').evaluate().single.widget, isA<Text>());
@@ -348,7 +352,8 @@ void main() {
tester.getTopLeft(cartPane).dy, tester.getTopLeft(paymentPane).dy);
expect(find.textContaining('x9999'), findsOneWidget);
expect(find.text('套餐'), findsOneWidget);
expect(find.text('清炒时蔬'), findsOneWidget);
// 套餐组成默认收起,首次进入不渲染组成行。
expect(find.text('清炒时蔬'), findsNothing);
expect(
find.byKey(
const ValueKey('checkout-product-image-long-name-product'),
@@ -357,7 +362,7 @@ void main() {
);
expect(
find.byKey(const ValueKey('checkout-combo-image-combo-child-1')),
findsOneWidget,
findsNothing,
);
expect(find.text('选择支付方式'), findsOneWidget);
final methodFinders = <Finder>[
@@ -385,10 +390,10 @@ void main() {
await tester.tap(find.text('营养套餐'));
await tester.pumpAndSettle();
expect(find.text('清炒时蔬').hitTestable(), findsNothing);
expect(find.text('清炒时蔬').hitTestable(), findsOneWidget);
await tester.tap(find.text('营养套餐'));
await tester.pumpAndSettle();
expect(find.text('清炒时蔬').hitTestable(), findsOneWidget);
expect(find.text('清炒时蔬').hitTestable(), findsNothing);
final wallet = ServiceWallet(
id: 'wallet-1',