[READ ONLY MIRROR] Open Source TikTok alternative built on AT Protocol github.com/sprksocial/client
flutter atproto video dart
Something went wrong. Try again.
4.3 kB · 139 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140import 'package:flutter_test/flutter_test.dart';import 'package:spark/src/core/notifications/notification_navigation.dart';
void main() { group('notificationRecordUri', () { test('uses canonical uri', () { expect( notificationRecordUri({ 'uri': 'at://did:plc:reply/so.sprk.feed.reply/123', 'recordUri': 'at://did:plc:root/so.sprk.feed.post/456', }), 'at://did:plc:reply/so.sprk.feed.reply/123', ); });
test('does not read legacy recordUri', () { expect( notificationRecordUri({ 'recordUri': 'at://did:plc:reply/so.sprk.feed.reply/123', }), isNull, ); });
test('ignores blank and non-string payload values', () { expect(notificationRecordUri({'uri': '', 'recordUri': 123}), isNull); }); });
group('notificationRecordAuthorDid', () { test('extracts the author did from a push uri', () { expect( notificationRecordAuthorDid( 'at://did:plc:author/app.bsky.graph.follow/123', ), 'did:plc:author', ); }); });
group('replyNotificationTarget', () { test('uses reasonSubject as the displayed post or parent thread', () { final target = replyNotificationTarget( replyUri: 'at://did:plc:reply/so.sprk.feed.reply/123', reasonSubject: 'at://did:plc:root/so.sprk.feed.post/456', );
expect(target.postUri, 'at://did:plc:root/so.sprk.feed.post/456'); expect( target.highlightedReplyUri, 'at://did:plc:reply/so.sprk.feed.reply/123', ); });
test('falls back to the reply uri when no subject is present', () { final target = replyNotificationTarget( replyUri: 'at://did:plc:reply/so.sprk.feed.reply/123', );
expect(target.postUri, 'at://did:plc:reply/so.sprk.feed.reply/123'); expect( target.highlightedReplyUri, 'at://did:plc:reply/so.sprk.feed.reply/123', ); }); });
group('replyNotificationTargetFromPayload', () { test('builds a target from push payload fields', () { final target = replyNotificationTargetFromPayload({ 'uri': 'at://did:plc:reply/so.sprk.feed.reply/123', 'subject': 'at://did:plc:root/so.sprk.feed.post/456', });
expect(target?.postUri, 'at://did:plc:root/so.sprk.feed.post/456'); expect( target?.highlightedReplyUri, 'at://did:plc:reply/so.sprk.feed.reply/123', ); }); });
group('notificationPostRouteUri', () { test('uses embedded subject post for via-repost notifications', () { expect( notificationPostRouteUri( reason: 'like-via-repost', reasonSubject: 'at://did:plc:user/so.sprk.feed.repost/123', record: { 'subject': {'uri': 'at://did:plc:author/so.sprk.feed.post/456'}, }, ), 'at://did:plc:author/so.sprk.feed.post/456', ); });
test('does not route via-repost notifications to the repost record', () { expect( notificationPostRouteUri( reason: 'repost-via-repost', reasonSubject: 'at://did:plc:user/so.sprk.feed.repost/123', recordUri: 'at://did:plc:actor/app.bsky.feed.like/456', ), isNull, ); });
test('uses push subject for via-repost payloads', () { expect( notificationPostRouteUri( reason: 'like-via-repost', reasonSubject: 'at://did:plc:user/so.sprk.feed.repost/123', payload: {'subject': 'at://did:plc:author/so.sprk.feed.post/456'}, ), 'at://did:plc:author/so.sprk.feed.post/456', ); });
test('keeps routing normal reactions by reasonSubject', () { expect( notificationPostRouteUri( reason: 'like', reasonSubject: 'at://did:plc:author/so.sprk.feed.post/456', ), 'at://did:plc:author/so.sprk.feed.post/456', ); });
test('falls back to routeable record uri for mentions', () { expect( notificationPostRouteUri( reason: 'mention', recordUri: 'at://did:plc:author/so.sprk.feed.post/456', ), 'at://did:plc:author/so.sprk.feed.post/456', ); }); });}