Skip to content

Commit dc25d2d

Browse files
test: Use TransitionDurationObserver in compose_box_test
Adds TransitionDurationObserver initialization inside the prepareComposeBox setup. Every test that calls prepareComposeBox now automatically attaches an observer to the widget tree. Replaces hardcoded transition delays with dynamic duration handling via transitionDurationObserver.pumpPastTransition(tester).
1 parent da2088a commit dc25d2d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/widgets/compose_box_test.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void main() {
5050
late PerAccountStore store;
5151
late FakeApiConnection connection;
5252
late ComposeBoxState state;
53+
late TransitionDurationObserver transitionDurationObserver;
5354

5455
// Caution: when testing edit-message UI, this will often be stale;
5556
// read state.controller instead.
@@ -96,6 +97,7 @@ void main() {
9697
store = await testBinding.globalStore.perAccount(selfAccount.id);
9798

9899
connection = store.connection as FakeApiConnection;
100+
transitionDurationObserver = TransitionDurationObserver();
99101

100102
connection.prepare(json:
101103
eg.newestGetMessagesResult(foundOldest: true, messages: messages).toJson());
@@ -104,6 +106,7 @@ void main() {
104106
connection.prepare(json: GetStreamTopicsResult(topics: []).toJson());
105107
}
106108
await tester.pumpWidget(TestZulipApp(accountId: selfAccount.id,
109+
navigatorObservers: [transitionDurationObserver],
107110
child: MessageListPage(initNarrow: narrow)));
108111
await tester.pumpAndSettle();
109112
connection.takeRequests();
@@ -1718,8 +1721,8 @@ void main() {
17181721
}) async {
17191722
await tester.longPress(find.byWidgetPredicate((widget) =>
17201723
widget is MessageWithPossibleSender && widget.item.message.id == messageId));
1721-
// sheet appears onscreen; default duration of bottom-sheet enter animation
1722-
await tester.pump(const Duration(milliseconds: 250));
1724+
// sheet appears onscreen
1725+
await transitionDurationObserver.pumpPastTransition(tester);
17231726
final findEditButton = find.descendant(
17241727
of: find.byType(BottomSheet),
17251728
matching: find.byIcon(ZulipIcons.edit, skipOffstage: false));
@@ -1875,7 +1878,7 @@ void main() {
18751878
await startEditInteractionFromActionSheet(tester, messageId: messageToEdit.id,
18761879
originalRawContent: 'message to edit',
18771880
delay: Duration.zero);
1878-
await tester.pump(const Duration(milliseconds: 250)); // bottom-sheet animation
1881+
await transitionDurationObserver.pumpPastTransition(tester); // bottom-sheet animation
18791882

18801883
await tester.tap(failedMessageFinder);
18811884
await tester.pump();
@@ -1899,7 +1902,7 @@ void main() {
18991902
await startEditInteractionFromActionSheet(tester, messageId: messageToEdit.id,
19001903
originalRawContent: 'message to edit',
19011904
delay: Duration.zero);
1902-
await tester.pump(const Duration(milliseconds: 250)); // bottom-sheet animation
1905+
await transitionDurationObserver.pumpPastTransition(tester); // bottom-sheet animation
19031906

19041907
await tester.tap(failedMessageFinder);
19051908
await tester.pump();

0 commit comments

Comments
 (0)