mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-24 10:26:24 +01:00
Flutter 3.50 deprecates package:flutter/material.dart; 73 deprecation infos failed flutter analyze --fatal-infos, and four Dart pins were behind (crdt_sync_flutter 0.8.2, flutter_local_notifications 23.0.2, github_device_auth 0.5.0, sync_settings_ui 0.8.2). Those UI packages now sit on material_ui, so the app has to as well or their widgets lose MaterialLocalizations. Imports swap one-for-one and dart fix re-sorted the directives; no behaviour change. analyze is clean and all six test shards pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
78 lines
2.4 KiB
Dart
78 lines
2.4 KiB
Dart
// Guard: a catering fetch / fill reports with a glyph and a dish count; its
|
|
// sentence is only the spoken label.
|
|
|
|
import 'package:diet_guard_app/screens/log_meal_fill_mixin.dart';
|
|
import 'package:diet_guard_app/services/kuchnia_spread.dart';
|
|
import 'package:diet_guard_app/ui/cues.dart';
|
|
import 'package:material_ui/material_ui.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'label_finders.dart';
|
|
import 'no_words_support.dart';
|
|
|
|
void main() {
|
|
group('fillCue', () {
|
|
test('nothing to fill paints a warning and 0', () {
|
|
final cue = fillCue((
|
|
message: 'No catering delivery today.',
|
|
written: const <SlottedDish>[],
|
|
), armed: 0);
|
|
expect(cue.kind, CueKind.warn);
|
|
expect(cue.count, 0);
|
|
expect(cue.label, 'No catering delivery today.');
|
|
});
|
|
|
|
test('a proposal paints its armed count', () {
|
|
final cue = fillCue((
|
|
message: 'Will log 3',
|
|
written: const <SlottedDish>[],
|
|
), armed: 3);
|
|
expect((cue.kind, cue.count), (CueKind.info, 3));
|
|
});
|
|
});
|
|
|
|
testWidgets('a counted cue paints only the glyph and the number', (
|
|
tester,
|
|
) async {
|
|
final state = CueState.next(
|
|
null,
|
|
CueKind.ok,
|
|
'Logged 4 catering dishes.',
|
|
4,
|
|
);
|
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: state.widget)));
|
|
expect(find.text('4'), findsOneWidget);
|
|
expect(cueLabelled('Logged 4 catering dishes.'), findsOneWidget);
|
|
expectNoWords(tester, minStrings: 2, where: 'fill cue');
|
|
});
|
|
|
|
testWidgets('the delivery snackbar paints the dish glyph and 0', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: Builder(
|
|
builder: (context) => TextButton(
|
|
onPressed: () => showCueSnack(
|
|
context,
|
|
kind: CueKind.warn,
|
|
semanticLabel: 'No delivery today.',
|
|
icon: Icons.restaurant,
|
|
count: 0,
|
|
),
|
|
child: const Icon(Icons.local_shipping),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.tap(find.byType(TextButton));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 500));
|
|
expect(find.byIcon(Icons.restaurant), findsOneWidget);
|
|
expect(find.text('0'), findsOneWidget);
|
|
expectNoWords(tester, minStrings: 3, where: 'delivery snack');
|
|
});
|
|
}
|