Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 32 additions & 16 deletions test/widgets/action_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Future<void> setupToMessageActionSheet(WidgetTester tester, {
// like if it's in padding around a Paragraph.
await tester.longPress(find.byType(MessageContent), warnIfMissed: false);
// sheet appears onscreen; default duration of bottom-sheet enter animation
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);
// Check the action sheet did in fact open, so we don't defeat any tests that
// use simple `find.byIcon`-style checks to test presence/absence of a button.
check(find.byType(BottomSheet)).findsOne();
Expand Down Expand Up @@ -199,19 +199,22 @@ void main() {
check(find.byType(InboxPageBody)).findsOne();

await tester.longPress(find.text(someChannel.name).hitTestable());
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);
}

Future<void> showFromSubscriptionList(WidgetTester tester) async {
final transitionDurationObserver = TransitionDurationObserver();

await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
navigatorObservers: [transitionDurationObserver],
child: const HomePage()));
await tester.pump();
await tester.tap(find.byIcon(ZulipIcons.hash_italic));
await tester.pump();
check(find.byType(SubscriptionListPageBody)).findsOne();

await tester.longPress(find.text(someChannel.name).hitTestable());
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);
}

Future<void> showFromMsglistAppBar(WidgetTester tester, {
Expand All @@ -220,6 +223,8 @@ void main() {
}) async {
channel ??= someChannel;

final transitionDurationObserver = TransitionDurationObserver();

connection.prepare(json: eg.newestGetMessagesResult(
foundOldest: true, messages: []).toJson());
if (narrow case ChannelNarrow()) {
Expand All @@ -229,31 +234,35 @@ void main() {
}
await tester.pumpWidget(TestZulipApp(
accountId: eg.selfAccount.id,
navigatorObservers: [transitionDurationObserver],
child: MessageListPage(
initNarrow: narrow)));
await tester.pumpAndSettle();

await tester.longPress(find.descendant(
of: find.byType(ZulipAppBar),
matching: find.text(channel.name)));
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);
}

Future<void> showFromRecipientHeader(WidgetTester tester, {
StreamMessage? message,
}) async {
message ??= someMessage;

final transitionDurationObserver = TransitionDurationObserver();

connection.prepare(json: eg.newestGetMessagesResult(
foundOldest: true, messages: [message]).toJson());
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
navigatorObservers: [transitionDurationObserver],
child: const MessageListPage(initNarrow: CombinedFeedNarrow())));
await tester.pumpAndSettle();

await tester.longPress(find.descendant(
of: find.byType(RecipientHeader),
matching: find.text(message.displayRecipient ?? '')));
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);
}

Future<void> showFromTopicListAppBar(WidgetTester tester, {int? streamId}) async {
Expand Down Expand Up @@ -739,7 +748,7 @@ void main() {

await tester.longPress(find.text(topic));
// sheet appears onscreen; default duration of bottom-sheet enter animation
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);
}

Future<void> showFromAppBar(WidgetTester tester, {
Expand All @@ -766,7 +775,7 @@ void main() {
effectiveTopic.displayName ?? eg.defaultRealmEmptyTopicDisplayName));
await tester.longPress(topicRow);
// sheet appears onscreen; default duration of bottom-sheet enter animation
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);
}

Future<void> showFromRecipientHeader(WidgetTester tester, {
Expand All @@ -785,7 +794,7 @@ void main() {
of: find.byType(RecipientHeader),
matching: find.text(effectiveMessage.topic.displayName!)));
// sheet appears onscreen; default duration of bottom-sheet enter animation
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);
}

final actionSheetFinder = find.byType(BottomSheet);
Expand Down Expand Up @@ -2037,21 +2046,28 @@ void main() {
check(await Clipboard.getData('text/plain')).isNotNull().text.equals('Hello world');
});

testWidgets('can show snackbar on success', (tester) async {
testWidgets('can show snackbar on success', (WidgetTester tester) async {
// Regression test for: https://github.com/zulip/zulip-flutter/issues/732
testBinding.deviceInfoResult = const IosDeviceInfo(systemVersion: '16.0');

final TransitionDurationObserver transitionDurationObserver = TransitionDurationObserver();
await tester.pumpWidget(
MaterialApp(
navigatorObservers: <NavigatorObserver>[transitionDurationObserver],
home: Scaffold(
body: Builder(builder: (context) {
testBinding.deviceInfoResult = const IosDeviceInfo(systemVersion: '16.0');
final message = eg.streamMessage();
setupToMessageActionSheet(tester,message: message,narrow: TopicNarrow.ofMessage(message));
return const SizedBox.shrink();}
))));
final message = eg.streamMessage();
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));

// Make the request take a bit of time to complete…
prepareRawContentResponseSuccess(message: message, rawContent: 'Hello world',
delay: const Duration(milliseconds: 500));
await tapCopyMessageTextButton(tester);
// … and pump a frame to finish the NavigationState.pop animation…
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);
// … before the request finishes. This is the repro condition for #732.
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);

final snackbar = tester.widget<SnackBar>(find.byType(SnackBar));
check(snackbar.behavior).equals(SnackBarBehavior.floating);
Expand Down Expand Up @@ -2283,7 +2299,7 @@ void main() {
// See comment in setupToMessageActionSheet about warnIfMissed: false
await tester.longPress(find.byType(MessageContent), warnIfMissed: false);
// sheet appears onscreen; default duration of bottom-sheet enter animation
await tester.pump(const Duration(milliseconds: 250));
await transitionDurationObserver.pumpPastTransition(tester);
check(find.byType(BottomSheet)).findsOne();
checkButtonIsPresent(expected);

Expand Down
40 changes: 27 additions & 13 deletions test/widgets/compose_box_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ void main() {
await tester.longPress(find.byWidgetPredicate((widget) =>
widget is MessageWithPossibleSender && widget.item.message.id == messageId));
// sheet appears onscreen; default duration of bottom-sheet enter animation
await tester.pump(const Duration(milliseconds: 250));
await tester.pumpAndSettle();
final findEditButton = find.descendant(
of: find.byType(BottomSheet),
matching: find.byIcon(ZulipIcons.edit, skipOffstage: false));
Expand Down Expand Up @@ -1862,10 +1862,17 @@ void main() {
await tester.pump();
check(state).controller.content.text.equals('composing something');
});

testWidgets('interrupting message edit: proceed through confirmation dialog', (tester) async {
await prepareMessageNotSent(tester, narrow: topicNarrow);

testWidgets('interrupting message edit: proceed through confirmation dialog', (WidgetTester tester) async {
final TransitionDurationObserver transitionDurationObserver = TransitionDurationObserver();

await tester.pumpWidget(
MaterialApp(
navigatorObservers: <NavigatorObserver>[transitionDurationObserver],
home: Scaffold(
body: Builder(builder: (context) {
prepareMessageNotSent(tester, narrow: topicNarrow);
return const SizedBox.shrink();},
))));
final messageToEdit = eg.streamMessage(
sender: eg.selfUser, stream: channel, topic: topic,
content: 'message to edit');
Expand All @@ -1875,21 +1882,28 @@ void main() {
await startEditInteractionFromActionSheet(tester, messageId: messageToEdit.id,
originalRawContent: 'message to edit',
delay: Duration.zero);
await tester.pump(const Duration(milliseconds: 250)); // bottom-sheet animation
await transitionDurationObserver.pumpPastTransition(tester);// bottom-sheet animation

await tester.tap(failedMessageFinder);
await tester.pump();
check(state).controller.content.text.equals('message to edit');

await expectAndHandleDiscardForMessageNotSentConfirmation(tester,
shouldContinue: true);
await expectAndHandleDiscardForMessageNotSentConfirmation(tester, shouldContinue: true);
await tester.pump();
check(state).controller.content.text.equals(failedMessageContent);
});

testWidgets('interrupting message edit: cancel confirmation dialog', (tester) async {
await prepareMessageNotSent(tester, narrow: topicNarrow);

testWidgets('interrupting message edit: cancel confirmation dialog', (WidgetTester tester) async {
final TransitionDurationObserver transitionDurationObserver = TransitionDurationObserver();

await tester.pumpWidget(
MaterialApp(
navigatorObservers: <NavigatorObserver>[transitionDurationObserver],
home: Scaffold(
body: Builder(builder: (context) {
prepareMessageNotSent(tester, narrow: topicNarrow);
return const SizedBox.shrink();},
))));
final messageToEdit = eg.streamMessage(
sender: eg.selfUser, stream: channel, topic: topic,
content: 'message to edit');
Expand All @@ -1899,7 +1913,7 @@ void main() {
await startEditInteractionFromActionSheet(tester, messageId: messageToEdit.id,
originalRawContent: 'message to edit',
delay: Duration.zero);
await tester.pump(const Duration(milliseconds: 250)); // bottom-sheet animation
await transitionDurationObserver.pumpPastTransition(tester); // bottom-sheet animation

await tester.tap(failedMessageFinder);
await tester.pump();
Expand Down Expand Up @@ -2352,4 +2366,4 @@ enum _EditInteractionStart {
_EditInteractionStart.restoreFailedEdit => 'from restoring a failed edit',
};
}
}
}
3 changes: 1 addition & 2 deletions test/widgets/emoji_reaction_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,7 @@ void main() {
// request the message action sheet
await tester.longPress(find.byType(MessageContent));
// sheet appears onscreen; default duration of bottom-sheet enter animation
await tester.pump(const Duration(milliseconds: 250));

await transitionDurationObserver.pumpPastTransition(tester);
await store.handleEvent(RealmEmojiUpdateEvent(id: 1, realmEmoji: {
'1': eg.realmEmojiItem(emojiCode: '1', emojiName: 'buzzing'),
}));
Expand Down