mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-11 12:07:42 +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
- lightImpact + 160 ms confirm cue on a validated log (audioplayers, no audio focus); device-local opt-out switch in Settings, on by default - post-log card: confirmation line (slot + the meal's kcal), entrance and kcal/streak count-up on motion tokens transcribed into ui/theme.dart; durations collapse to zero under disableAnimations - test/flutter_test_config.dart mutes the cue suite-wide Todo: 8e66c1b9 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWVHMLzeojNP4AaPoEj
73 lines
2.9 KiB
Dart
73 lines
2.9 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:diet_guard_app/screens/settings_screen.dart';
|
|
import 'package:diet_guard_app/services/app_settings_service.dart';
|
|
import 'package:diet_guard_app/services/budget_history_service.dart';
|
|
import 'package:diet_guard_app/services/document_store_io.dart';
|
|
import 'package:diet_guard_app/services/foodbank_service.dart';
|
|
import 'package:diet_guard_app/services/log_storage_service.dart';
|
|
import 'package:diet_guard_app/services/meal_schedule_service.dart';
|
|
import 'package:diet_guard_app/widgets/log_sound_tile.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import '../fake_secure_storage.dart';
|
|
|
|
void main() {
|
|
late Directory dir;
|
|
|
|
setUp(() async {
|
|
dir = await Directory.systemTemp.createTemp('diet_guard_sound_tile_');
|
|
LogStorageService.resetForTesting(store: FileDocumentStore(dir));
|
|
FoodBankService.resetForTesting(store: FileDocumentStore(dir));
|
|
BudgetHistoryService.resetForTesting(store: FileDocumentStore(dir));
|
|
await AppSettingsService.initForTesting(FileDocumentStore(dir));
|
|
await MealScheduleService.initForTesting(FileDocumentStore(dir));
|
|
SharedPreferences.setMockInitialValues({});
|
|
installFakeSecureStorage();
|
|
});
|
|
|
|
tearDown(() async {
|
|
LogStorageService.resetForTesting();
|
|
FoodBankService.resetForTesting();
|
|
AppSettingsService.resetForTesting();
|
|
BudgetHistoryService.resetForTesting();
|
|
MealScheduleService.resetForTesting();
|
|
await dir.delete(recursive: true);
|
|
});
|
|
|
|
testWidgets('the switch reflects and persists the setting', (tester) async {
|
|
await tester.runAsync(() async {
|
|
await tester.pumpWidget(
|
|
const MaterialApp(home: Scaffold(body: LogSoundTile())),
|
|
);
|
|
final tile = find.byType(SwitchListTile);
|
|
expect(find.bySemanticsLabel('Sound on log'), findsOneWidget);
|
|
expect(tester.widget<SwitchListTile>(tile).value, isTrue);
|
|
|
|
await tester.tap(tile);
|
|
await Future<void>.delayed(const Duration(milliseconds: 100));
|
|
await tester.pump();
|
|
expect(tester.widget<SwitchListTile>(tile).value, isFalse);
|
|
|
|
AppSettingsService.resetForTesting();
|
|
await AppSettingsService.initForTesting(FileDocumentStore(dir));
|
|
expect(AppSettingsService.soundOnLog, isFalse);
|
|
});
|
|
});
|
|
|
|
testWidgets('settings screen carries the toggle', (tester) async {
|
|
await tester.runAsync(() async {
|
|
tester.view.physicalSize = const Size(800, 1400);
|
|
tester.view.devicePixelRatio = 1.0;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
await tester.pumpWidget(const MaterialApp(home: SettingsScreen()));
|
|
await Future<void>.delayed(const Duration(milliseconds: 200));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(LogSoundTile), findsOneWidget);
|
|
});
|
|
});
|
|
}
|