Improve share intake diagnostics

This commit is contained in:
Rijad Zuzo
2026-05-19 11:26:23 +02:00
parent 0bfe67b1bf
commit 9d2da0c600
4 changed files with 120 additions and 7 deletions
@@ -0,0 +1,40 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:relationship_saver/features/share_intake/application/share_intake_debug_log.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() {
setUp(() {
SharedPreferences.setMockInitialValues(<String, Object>{});
});
test('records optional share details for diagnostics', () async {
const ShareIntakeDebugLog log = ShareIntakeDebugLog();
await log.record(
'raw_share_text',
'Captured raw share text (18 chars).',
details: 'Alex: likes cycling',
);
final List<ShareIntakeDebugEvent> events = await log.read();
expect(events, hasLength(1));
expect(events.single.stage, 'raw_share_text');
expect(events.single.details, 'Alex: likes cycling');
});
test('trims very large details before storing', () async {
const ShareIntakeDebugLog log = ShareIntakeDebugLog();
await log.record(
'raw_share_text',
'large',
details: List<String>.filled(7000, 'x').join(),
);
final List<ShareIntakeDebugEvent> events = await log.read();
expect(events.single.details, endsWith('[truncated]'));
expect(events.single.details!.length, lessThan(7000));
});
}