Skip to content

Commit 5e59332

Browse files
committed
add passing success test, by disabling recent behavior
1 parent 7656570 commit 5e59332

File tree

2 files changed

+47
-35
lines changed

2 files changed

+47
-35
lines changed

lib/widgets/action_sheet.dart

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -102,41 +102,43 @@ class AddReactionButton extends MessageActionSheetMenuItemButton {
102102
// apply bottom padding to handle keyboard opening via https://github.com/flutter/flutter/issues/71418
103103
padding: EdgeInsets.only(bottom: MediaQuery.of(emojiPickerContext).viewInsets.bottom),
104104
child: EmojiPicker(
105-
config: Config(emojiSet: emojiSet),
106-
onEmojiSelected: (_, Emoji? emoji) async {
107-
if (emoji == null) {
108-
// dismiss emoji picker
109-
Navigator.of(emojiPickerContext).pop();
110-
return;
111-
}
112-
final emojiName = emoji.name;
113-
final emojiCode = getEmojiCode(emoji);
114-
String? errorMessage;
115-
try {
116-
await addReaction(PerAccountStoreWidget.of(messageListContext).connection,
117-
messageId: message.id,
118-
reactionType: ReactionType.unicodeEmoji,
119-
emojiCode: emojiCode,
120-
emojiName: emojiName,
121-
);
122-
if (!emojiPickerContext.mounted) return;
123-
Navigator.of(emojiPickerContext).pop();
124-
} catch (e) {
125-
debugPrint('Error adding reaction: $e');
126-
if (!emojiPickerContext.mounted) return;
127-
128-
switch (e) {
129-
case ZulipApiException():
130-
errorMessage = e.message;
131-
// TODO specific messages for common errors, like network errors
132-
// (support with reusable code)
133-
default:
105+
config: Config(
106+
emojiSet: emojiSet,
107+
categoryViewConfig: const CategoryViewConfig(recentTabBehavior: RecentTabBehavior.NONE)),
108+
onEmojiSelected: (_, Emoji? emoji) async {
109+
if (emoji == null) {
110+
// dismiss emoji picker
111+
Navigator.of(emojiPickerContext).pop();
112+
return;
134113
}
135-
136-
await showErrorDialog(context: emojiPickerContext,
137-
title: 'Adding reaction failed', message: errorMessage);
138-
}
139-
}));
114+
final emojiName = emoji.name;
115+
final emojiCode = getEmojiCode(emoji);
116+
String? errorMessage;
117+
try {
118+
await addReaction(PerAccountStoreWidget.of(messageListContext).connection,
119+
messageId: message.id,
120+
reactionType: ReactionType.unicodeEmoji,
121+
emojiCode: emojiCode,
122+
emojiName: emojiName,
123+
);
124+
if (!emojiPickerContext.mounted) return;
125+
Navigator.of(emojiPickerContext).pop();
126+
} catch (e) {
127+
debugPrint('Error adding reaction: $e');
128+
if (!emojiPickerContext.mounted) return;
129+
130+
switch (e) {
131+
case ZulipApiException():
132+
errorMessage = e.message;
133+
// TODO specific messages for common errors, like network errors
134+
// (support with reusable code)
135+
default:
136+
}
137+
138+
await showErrorDialog(context: emojiPickerContext,
139+
title: 'Adding reaction failed', message: errorMessage);
140+
}
141+
}));
140142
});
141143
};
142144
}

test/widgets/action_sheet_test.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void main() {
9898
(store.connection as FakeApiConnection).prepare(httpStatus: 400, json: fakeResponseJson);
9999
}
100100

101-
group('AddThumbsUpButton', () {
101+
group('AddReactionButton', () {
102102
Future<void> tapButton(WidgetTester tester) async {
103103
await tester.ensureVisible(find.byIcon(Icons.add_reaction_outlined, skipOffstage: false));
104104
await tester.tap(find.byIcon(Icons.add_reaction_outlined));
@@ -113,6 +113,16 @@ void main() {
113113
final connection = store.connection as FakeApiConnection;
114114
connection.prepare(json: {});
115115
await tapButton(tester);
116+
// Wait for bottom modal to appear
117+
await tester.pumpAndSettle();
118+
await tester.ensureVisible(find.byIcon(Icons.tag_faces, skipOffstage: false));
119+
await tester.tap(find.byIcon(Icons.tag_faces));
120+
await tester.dragUntilVisible(
121+
find.text('👍').hitTestable(),
122+
find.byKey(const Key('emojiScrollView')),
123+
const Offset(0, -300),
124+
);
125+
await tester.tap(find.text('👍'));
116126
await tester.pump(Duration.zero);
117127

118128
check(connection.lastRequest).isA<http.Request>()

0 commit comments

Comments
 (0)