Skip to content

Commit e05fc95

Browse files
test: Use TransitionDurationObserver in compose_box_test
Added TransitionDurationObserver initialization inside prepareComposeBox setup,every test that calls prepareComposeBox now automatically attaches an observer to the widget tree.Replaced hardcoded transition delays with dynamic duration handling via transitionDurationObserver.pumpPastTransition(tester). This ensures test stability when transition timings change.
1 parent cf6be3e commit e05fc95

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/widgets/compose_box_test.dart

Lines changed: 6 additions & 3 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();
@@ -1719,7 +1722,7 @@ void main() {
17191722
await tester.longPress(find.byWidgetPredicate((widget) =>
17201723
widget is MessageWithPossibleSender && widget.item.message.id == messageId));
17211724
// sheet appears onscreen; default duration of bottom-sheet enter animation
1722-
await tester.pump(const Duration(milliseconds: 250));
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)