fix(ui): deprecate exposed showReactionPickerTail in MessageWidget

`showReactionPickerTail` property is bind with `showReactionPicker` as it is the only one needed to couple the reaction modal with the tail

Closes #1759
This commit is contained in:
Efthymis Sarmpanis
2023-11-02 15:08:53 +02:00
parent 354ae323b2
commit 02d686cc75
4 changed files with 118 additions and 12 deletions
@@ -64,6 +64,101 @@ void main() {
},
);
testWidgets(
'it should show the reaction picker',
(WidgetTester tester) async {
final client = MockClient();
final clientState = MockClientState();
final channel = MockChannel(
ownCapabilities: ['send-message', 'send-reaction'],
);
when(() => client.state).thenReturn(clientState);
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
final themeData = ThemeData();
final streamTheme = StreamChatThemeData.fromTheme(themeData);
await tester.pumpWidget(
MaterialApp(
theme: themeData,
home: StreamChat(
streamChatThemeData: streamTheme,
client: client,
child: SizedBox(
child: StreamChannel(
channel: channel,
child: MessageActionsModal(
message: Message(
text: 'test',
user: User(
id: 'user-id',
),
state: MessageState.sent,
),
messageWidget: const Text(
'test',
key: Key('MessageWidget'),
),
messageTheme: streamTheme.ownMessageTheme,
),
),
),
),
),
);
await tester.pumpAndSettle();
expect(find.byType(StreamReactionPicker), findsOneWidget);
},
);
testWidgets(
'it should not show the reaction picker',
(WidgetTester tester) async {
final client = MockClient();
final clientState = MockClientState();
final channel = MockChannel();
when(() => client.state).thenReturn(clientState);
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
final themeData = ThemeData();
final streamTheme = StreamChatThemeData.fromTheme(themeData);
await tester.pumpWidget(
MaterialApp(
theme: themeData,
home: StreamChat(
streamChatThemeData: streamTheme,
client: client,
child: SizedBox(
child: StreamChannel(
channel: channel,
child: MessageActionsModal(
showReactionPicker: false,
message: Message(
text: 'test',
user: User(
id: 'user-id',
),
state: MessageState.sent,
),
messageWidget: const Text(
'test',
key: Key('MessageWidget'),
),
messageTheme: streamTheme.ownMessageTheme,
),
),
),
),
),
);
await tester.pumpAndSettle();
expect(find.byType(StreamReactionPicker), findsNothing);
},
);
testWidgets(
'it should show some actions',
(WidgetTester tester) async {
@@ -14,6 +14,13 @@ class MockClient extends Mock implements StreamChatClient {
class MockClientState extends Mock implements ClientState {}
class MockChannel extends Mock implements Channel {
MockChannel({
this.ownCapabilities = const ['send-message'],
});
@override
final List<String> ownCapabilities;
@override
Future<bool> get initialized async => true;
@@ -22,9 +29,6 @@ class MockChannel extends Mock implements Channel {
Future<void> keyStroke([String? parentId]) async {
return;
}
@override
List<String> get ownCapabilities => ['send-message'];
}
class MockChannelState extends Mock implements ChannelClientState {