Add LLM digest setup and share timestamp context

This commit is contained in:
Rijad Zuzo
2026-05-19 19:17:35 +02:00
parent 9d2da0c600
commit 5d80af375e
42 changed files with 2878 additions and 39 deletions
@@ -39,6 +39,33 @@ void main() {
expect(payload.rawText, 'loves cozy Italian restaurants');
});
test('stores source message datetime when WhatsApp text includes one', () {
final SharedPayload payload = SharePayloadParser.parse(
rawText: '[19/05/2026, 14:30] Ava Hart: ginger tea helped',
sourceApp: 'whatsapp',
platform: 'ios',
);
expect(payload.sourceDisplayName, 'Ava Hart');
expect(payload.rawText, 'ginger tea helped');
expect(payload.sharedMessageDateTime, DateTime(2026, 5, 19, 14, 30));
expect(payload.parsingHints, contains('shared_message_datetime_detected'));
expect(payload.metadata, contains('shared_message_datetime'));
});
test(
'does not store source message datetime for arbitrary content dates',
() {
final SharedPayload payload = SharePayloadParser.parse(
rawText: 'Ava birthday is on May 20 and she likes ginger tea.',
sourceApp: 'share_sheet',
platform: 'ios',
);
expect(payload.sharedMessageDateTime, isNull);
},
);
test('uses explicit signal source app hint and extracts sender', () {
final SharedPayload payload = SharePayloadParser.parse(
rawText: 'Marek: this concert looks promising',
@@ -0,0 +1,58 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:relationship_saver/features/share_intake/domain/shared_message_datetime_extractor.dart';
void main() {
group('SharedMessageDateTimeExtractor', () {
test('extracts WhatsApp bracketed European timestamp', () {
final DateTime? value = SharedMessageDateTimeExtractor.extract(
'[19/05/2026, 14:30] Ava Hart: I was sick but ginger tea helped',
);
expect(value, DateTime(2026, 5, 19, 14, 30));
});
test('extracts exported chat prefix with US meridiem timestamp', () {
final DateTime? value = SharedMessageDateTimeExtractor.extract(
'5/19/26, 2:30 PM - Ava Hart: ginger tea helped',
);
expect(value, DateTime(2026, 5, 19, 14, 30));
});
test('extracts labelled month-name timestamp', () {
final DateTime? value = SharedMessageDateTimeExtractor.extract(
'Received at: 19 May 2026 at 14:30\nAva: ginger tea helped',
);
expect(value, DateTime(2026, 5, 19, 14, 30));
});
test(
'extracts relative labelled timestamp using provided reference date',
() {
final DateTime? value = SharedMessageDateTimeExtractor.extract(
'Yesterday at 21:05 - Ava Hart: ginger tea helped',
now: DateTime(2026, 5, 19, 9),
);
expect(value, DateTime(2026, 5, 18, 21, 5));
},
);
test('does not treat arbitrary content date as message timestamp', () {
final DateTime? value = SharedMessageDateTimeExtractor.extract(
'Ava birthday is on May 20 and she likes ginger tea.',
);
expect(value, isNull);
});
test('returns null instead of throwing for invalid dates', () {
final DateTime? value = SharedMessageDateTimeExtractor.extract(
'[99/99/2026, 25:99] Ava: impossible',
);
expect(value, isNull);
});
});
}