Add Share Inbox flow for unresolved WhatsApp imports

This commit is contained in:
Rijad Zuzo
2026-02-19 00:26:18 +01:00
parent d2205bd3d9
commit d70edb4c4c
9 changed files with 1278 additions and 113 deletions
+113 -1
View File
@@ -107,7 +107,9 @@ void main() {
expect(first.createdProfile, isTrue);
expect(afterFirst.people.length, before.people.length + 1);
expect(
afterFirst.sourceLinks.any((link) => link.profileId == first.profileId),
afterFirst.sourceLinks.any(
(SourceProfileLink link) => link.profileId == first.profileId,
),
isTrue,
);
expect(
@@ -142,6 +144,116 @@ void main() {
},
);
test(
'queues ambiguous shared message into inbox for manual resolution',
() async {
final ProviderContainer container = _createContainer();
addTearDown(container.dispose);
final LocalDataState before = await container.read(
localRepositoryProvider.future,
);
await container
.read(localRepositoryProvider.notifier)
.addPerson(
name: 'Alex Morgan',
relationship: 'Friend',
notes: '',
tags: const <String>[],
);
await container
.read(localRepositoryProvider.notifier)
.addPerson(
name: 'Alex Morgan',
relationship: 'Cousin',
notes: '',
tags: const <String>[],
);
final SharedMessageIngestResult result = await container
.read(localRepositoryProvider.notifier)
.ingestSharedMessage(
const SharedMessageIngestInput(
sourceApp: 'whatsapp',
sourceDisplayName: 'Alex Morgan',
messageText: 'Can we sync up tomorrow?',
),
);
final LocalDataState after = await container.read(
localRepositoryProvider.future,
);
expect(result.isQueuedForResolution, isTrue);
expect(result.inboxEntryId, isNotNull);
expect(after.sharedInbox.length, 1);
expect(
after.sharedInbox.first.reason,
SharedInboxReason.ambiguousProfileMatch,
);
expect(after.moments.length, before.moments.length);
},
);
test('resolves inbox item to existing profile', () async {
final ProviderContainer container = _createContainer();
addTearDown(container.dispose);
await container.read(localRepositoryProvider.future);
await container
.read(localRepositoryProvider.notifier)
.addPerson(
name: 'Alex Morgan',
relationship: 'Friend',
notes: '',
tags: const <String>[],
);
await container
.read(localRepositoryProvider.notifier)
.addPerson(
name: 'Alex Morgan',
relationship: 'Cousin',
notes: '',
tags: const <String>[],
);
final SharedMessageIngestResult queued = await container
.read(localRepositoryProvider.notifier)
.ingestSharedMessage(
const SharedMessageIngestInput(
sourceApp: 'whatsapp',
sourceDisplayName: 'Alex Morgan',
messageText: 'Did you see the offer?',
),
);
final LocalDataState pending = await container.read(
localRepositoryProvider.future,
);
final String profileId = pending.people.first.id;
final SharedMessageIngestResult resolved = await container
.read(localRepositoryProvider.notifier)
.resolveSharedInboxToExistingProfile(
inboxEntryId: queued.inboxEntryId!,
profileId: profileId,
);
final LocalDataState after = await container.read(
localRepositoryProvider.future,
);
expect(resolved.isQueuedForResolution, isFalse);
expect(resolved.profileId, profileId);
expect(after.sharedInbox, isEmpty);
expect(
after.moments.any(
(RelationshipMoment moment) => moment.personId == profileId,
),
isTrue,
);
expect(after.sharedMessages.first.resolvedAutomatically, isFalse);
});
test('adds, archives, edits, and deletes ideas', () async {
final ProviderContainer container = _createContainer();
addTearDown(container.dispose);