mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-10 19:27:14 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
92 lines
2.5 KiB
Dart
92 lines
2.5 KiB
Dart
/// The "Fill all with catering" row: label per state, Cancel only when armed.
|
|
library;
|
|
|
|
import 'package:diet_guard_app/widgets/fill_all_row.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
Future<void> _pump(
|
|
WidgetTester tester, {
|
|
bool canFetch = true,
|
|
bool busy = false,
|
|
int armed = 0,
|
|
Future<void> Function()? onFill,
|
|
VoidCallback? onCancel,
|
|
}) => tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: FillAllRow(
|
|
onFill: onFill ?? () async {},
|
|
onCancel: onCancel ?? () {},
|
|
busy: busy,
|
|
armedCount: armed,
|
|
canFetchDelivery: canFetch,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
void main() {
|
|
testWidgets('is hidden where delivery cannot be fetched (web)', (t) async {
|
|
await _pump(t, canFetch: false, armed: 3);
|
|
|
|
expect(find.byType(OutlinedButton), findsNothing);
|
|
expect(find.text(fillAllLabel), findsNothing);
|
|
expect(find.text('Cancel'), findsNothing);
|
|
});
|
|
|
|
testWidgets('resting: the fill label and no Cancel', (t) async {
|
|
await _pump(t);
|
|
|
|
expect(find.text('🍱 Fill all with catering'), findsOneWidget);
|
|
expect(find.text('Cancel'), findsNothing);
|
|
});
|
|
|
|
testWidgets('armed: Confirm (N) and a Cancel button', (t) async {
|
|
await _pump(t, armed: 3);
|
|
|
|
expect(find.text('✓ Confirm (3)'), findsOneWidget);
|
|
expect(find.text(fillAllLabel), findsNothing);
|
|
expect(find.text('Cancel'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('busy: Working… and both controls disabled', (t) async {
|
|
var fills = 0;
|
|
var cancels = 0;
|
|
await _pump(
|
|
t,
|
|
busy: true,
|
|
armed: 3,
|
|
onFill: () async => fills++,
|
|
onCancel: () => cancels++,
|
|
);
|
|
|
|
expect(find.text('Working…'), findsOneWidget);
|
|
expect(find.text('✓ Confirm (3)'), findsNothing);
|
|
expect(
|
|
t.widget<OutlinedButton>(find.byType(OutlinedButton)).onPressed,
|
|
isNull,
|
|
);
|
|
expect(t.widget<TextButton>(find.byType(TextButton)).onPressed, isNull);
|
|
await t.tap(find.byType(OutlinedButton), warnIfMissed: false);
|
|
await t.tap(find.byType(TextButton), warnIfMissed: false);
|
|
expect(fills + cancels, 0);
|
|
});
|
|
|
|
testWidgets('taps reach the callbacks when idle', (t) async {
|
|
var fills = 0;
|
|
var cancels = 0;
|
|
await _pump(
|
|
t,
|
|
armed: 2,
|
|
onFill: () async => fills++,
|
|
onCancel: () => cancels++,
|
|
);
|
|
|
|
await t.tap(find.text('✓ Confirm (2)'));
|
|
await t.tap(find.text('Cancel'));
|
|
|
|
expect([fills, cancels], [1, 1]);
|
|
});
|
|
}
|