mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-21 17:42:17 +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
91 lines
2.9 KiB
Dart
91 lines
2.9 KiB
Dart
// Guard: the Body screen, every tile sheet and the activity-method chooser
|
|
// paint no words (only numbers, unit symbols, MET and workout labels).
|
|
// Workout labels are content only for manual workouts (source == 'manual').
|
|
|
|
import 'package:material_ui/material_ui.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'label_finders.dart';
|
|
import 'no_words_support.dart';
|
|
import 'screens/body_screen_support.dart';
|
|
|
|
/// Workout labels the PC published (content, see `seedPerson`), plus the
|
|
/// proper names of the BMI / ideal-weight / BMR formulas that label their
|
|
/// figures (DOUBT rows in keep.md: kept from the first pilot, outside the
|
|
/// activity sheet). Activity formulas (ACSM, Per-km) are NOT here: that sheet
|
|
/// and its chooser show glyphs only. Only manual workouts carry human content.
|
|
const Set<String> _workouts = {
|
|
'walk to the shop',
|
|
'Harris-Benedict (revised 1984)',
|
|
'Peterson (BMI 22)',
|
|
'Mifflin-St Jeor',
|
|
'Katch-McArdle',
|
|
'Cunningham',
|
|
'BMI Prime',
|
|
'Trefethen',
|
|
'Devine',
|
|
'Robinson',
|
|
'Miller',
|
|
};
|
|
|
|
void main() {
|
|
late MemoryDocStore store;
|
|
|
|
setUp(() async {
|
|
store = MemoryDocStore();
|
|
await setUpBodyServices(store);
|
|
});
|
|
tearDown(tearDownBodyServices);
|
|
|
|
test('the checker flags an injected word (canary)', () {
|
|
expect(wordsIn('70.0 kg'), isEmpty);
|
|
expect(wordsIn('265 MET'), isEmpty);
|
|
expect(wordsIn('Measured (ACSM)'), isNotEmpty);
|
|
expect(wordsIn('walk to the shop 4 km', content: _workouts), ['km']);
|
|
expect(wordsIn('walk to the shop', content: _workouts), isEmpty);
|
|
});
|
|
|
|
testWidgets('canary: a painted word fails the guard', (tester) async {
|
|
await tester.pumpWidget(const MaterialApp(home: Text('Activity')));
|
|
expect(() => expectNoWords(tester), throwsA(isA<TestFailure>()));
|
|
});
|
|
|
|
for (final seeded in [false, true]) {
|
|
testWidgets('body tiles and sheets paint no words (seeded: $seeded)', (
|
|
tester,
|
|
) async {
|
|
if (seeded) await seedPerson(store);
|
|
await pumpBody(tester);
|
|
final found = wordyStrings(
|
|
tester,
|
|
content: _workouts,
|
|
minStrings: 5,
|
|
where: 'tiles',
|
|
);
|
|
for (final title in tileTitles(tester)) {
|
|
await openTile(tester, title);
|
|
found.addAll(wordyStrings(tester, content: _workouts, where: title));
|
|
await closeSheet(tester);
|
|
}
|
|
expect(found, isEmpty);
|
|
});
|
|
}
|
|
|
|
testWidgets('the activity-method chooser paints no words', (tester) async {
|
|
await seedPerson(store);
|
|
await pumpBody(tester);
|
|
await openTile(tester, 'Daily calorie target');
|
|
await tester.tap(bySemLabel('Moderate').first);
|
|
await tester.pumpAndSettle();
|
|
expectNoWords(
|
|
tester,
|
|
content: _workouts,
|
|
minStrings: 8,
|
|
where: 'activity chooser',
|
|
);
|
|
await tester.tap(bySemLabel('Measured (ACSM)').last);
|
|
await tester.pumpAndSettle();
|
|
expectNoWords(tester, content: _workouts, where: 'measured goal');
|
|
});
|
|
}
|