|
1 | 1 | import 'dart:ui' as ui; |
2 | 2 |
|
| 3 | +import 'package:buzz/features/channels/channel_management_provider.dart'; |
3 | 4 | import 'package:buzz/features/channels/message_actions.dart'; |
4 | 5 | import 'package:buzz/features/channels/message_long_press_region.dart'; |
5 | 6 | import 'package:buzz/shared/read_state/read_state_provider.dart'; |
@@ -219,6 +220,7 @@ Future<_MessageActionsPopoverHarness> _pumpMessageActionsPopover( |
219 | 220 | FocusNode? composerFocusNode, |
220 | 221 | bool composerInitiallyFocused = false, |
221 | 222 | bool launcherOnNestedRoute = false, |
| 223 | + ChannelActions Function(Ref ref)? createChannelActions, |
222 | 224 | Rect anchorRect = const Rect.fromLTWH(32, 260, 300, 72), |
223 | 225 | }) async { |
224 | 226 | final sourceHidden = ValueNotifier(false); |
@@ -268,6 +270,8 @@ Future<_MessageActionsPopoverHarness> _pumpMessageActionsPopover( |
268 | 270 | ), |
269 | 271 | ), |
270 | 272 | reminderServiceProvider.overrideWithValue(reminderService), |
| 273 | + if (createChannelActions != null) |
| 274 | + channelActionsProvider.overrideWith(createChannelActions), |
271 | 275 | ], |
272 | 276 | child: MaterialApp( |
273 | 277 | theme: AppTheme.light(), |
@@ -324,6 +328,26 @@ Future<void> _dismissMessageActionsPopover(WidgetTester tester) async { |
324 | 328 | await tester.pumpAndSettle(); |
325 | 329 | } |
326 | 330 |
|
| 331 | +class _FakeChannelActions extends ChannelActions { |
| 332 | + final reactions = <({String eventId, String emoji})>[]; |
| 333 | + |
| 334 | + _FakeChannelActions(Ref ref) |
| 335 | + : super( |
| 336 | + ref: ref, |
| 337 | + session: ref.read(relaySessionProvider.notifier), |
| 338 | + signedEventRelay: SignedEventRelay( |
| 339 | + session: ref.read(relaySessionProvider.notifier), |
| 340 | + nsec: null, |
| 341 | + ), |
| 342 | + currentPubkey: 'self', |
| 343 | + ); |
| 344 | + |
| 345 | + @override |
| 346 | + Future<void> addReaction(String eventId, String emoji) async { |
| 347 | + reactions.add((eventId: eventId, emoji: emoji)); |
| 348 | + } |
| 349 | +} |
| 350 | + |
327 | 351 | void main() { |
328 | 352 | testWidgets( |
329 | 353 | 'message long press keeps taps and scrolling while repeated holds win', |
@@ -889,6 +913,68 @@ void main() { |
889 | 913 | expect(tester.takeException(), isNull); |
890 | 914 | }); |
891 | 915 |
|
| 916 | + testWidgets('ignores repeat backdrop taps once dismissal starts', ( |
| 917 | + tester, |
| 918 | + ) async { |
| 919 | + final prefs = await _mockPrefs(); |
| 920 | + await _pumpMessageActionsPopover( |
| 921 | + tester, |
| 922 | + message: _message(), |
| 923 | + prefs: prefs, |
| 924 | + launcherOnNestedRoute: true, |
| 925 | + ); |
| 926 | + final backdrop = tester.widget<GestureDetector>( |
| 927 | + find.byKey(const ValueKey('message-actions-backdrop')), |
| 928 | + ); |
| 929 | + |
| 930 | + backdrop.onTap!.call(); |
| 931 | + backdrop.onTap!.call(); |
| 932 | + await tester.pumpAndSettle(); |
| 933 | + |
| 934 | + expect( |
| 935 | + find.byKey(const ValueKey('message-actions-underlying-page')), |
| 936 | + findsOneWidget, |
| 937 | + ); |
| 938 | + expect( |
| 939 | + find.byKey(const ValueKey('message-actions-root-page')), |
| 940 | + findsNothing, |
| 941 | + ); |
| 942 | + expect(tester.takeException(), isNull); |
| 943 | + }); |
| 944 | + |
| 945 | + testWidgets('ignores repeat quick reactions once dismissal starts', ( |
| 946 | + tester, |
| 947 | + ) async { |
| 948 | + final prefs = await _mockPrefs(); |
| 949 | + late _FakeChannelActions actions; |
| 950 | + await _pumpMessageActionsPopover( |
| 951 | + tester, |
| 952 | + message: _message(), |
| 953 | + prefs: prefs, |
| 954 | + launcherOnNestedRoute: true, |
| 955 | + createChannelActions: (ref) => actions = _FakeChannelActions(ref), |
| 956 | + ); |
| 957 | + final reaction = find.byKey(const ValueKey('quick-reaction-\u{1F44D}')); |
| 958 | + final detector = tester.widget<GestureDetector>( |
| 959 | + find.descendant(of: reaction, matching: find.byType(GestureDetector)), |
| 960 | + ); |
| 961 | + |
| 962 | + detector.onTap!.call(); |
| 963 | + detector.onTap!.call(); |
| 964 | + await tester.pumpAndSettle(); |
| 965 | + |
| 966 | + expect( |
| 967 | + find.byKey(const ValueKey('message-actions-underlying-page')), |
| 968 | + findsOneWidget, |
| 969 | + ); |
| 970 | + expect( |
| 971 | + find.byKey(const ValueKey('message-actions-root-page')), |
| 972 | + findsNothing, |
| 973 | + ); |
| 974 | + expect(actions.reactions, [(eventId: 'msg-1', emoji: '\u{1F44D}')]); |
| 975 | + expect(tester.takeException(), isNull); |
| 976 | + }); |
| 977 | + |
892 | 978 | testWidgets('fallback action rows grow with accessibility text', ( |
893 | 979 | tester, |
894 | 980 | ) async { |
|
0 commit comments