wake-alarm/phone_app/test/services/session_publisher_log_test.dart
Krzysztof kuhy Rudnicki 7a3b767075 Fix E2E unlock dialog and log publish errors
Since the material_ui bump the app supplied no framework
MaterialLocalizations, so crdt_sync_flutter's E2ePassphraseButton
showDialog crashed and the phone stayed locked. Nothing synced and the
PC fallback rang on 2026-11-16. The app now provides the localization
delegates. Publish failures now reach logcat in release builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 08:30:35 +01:00

29 lines
962 B
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:wake_alarm_sync/services/session_publisher.dart';
import '../fake_secure_storage.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
test('a failed publish reaches debugPrint, not only developer.log', () async {
SharedPreferences.setMockInitialValues({});
installFakeSecureStorage(initial: {'github_token': 'tok'});
final lines = <String>[];
final saved = debugPrint;
debugPrint = (message, {wrapWidth}) => lines.add('$message');
addTearDown(() => debugPrint = saved);
final status = await SessionPublisher(
open: () async => throw Exception('boom'),
).publish();
expect(status, 'Session kept locally (sync failed)');
expect(
lines.join('\n'),
contains('session publish failed: Exception: boom'),
);
});
}