Improve share intake diagnostics
This commit is contained in:
@@ -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));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user