From 508f86fcbe857c6cca0f90bf1c143cd5e9a14527 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Wed, 25 Oct 2023 13:53:43 +0100 Subject: [PATCH] msglist test [nfc]: Deduplicate getAnimation helper --- test/widgets/message_list_test.dart | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/test/widgets/message_list_test.dart b/test/widgets/message_list_test.dart index a8cb7507c5..ee6703d84f 100644 --- a/test/widgets/message_list_test.dart +++ b/test/widgets/message_list_test.dart @@ -302,9 +302,9 @@ void main() { }); group('_UnreadMarker animations', () { - Animation getAnimation(WidgetTester tester) { + Animation getAnimation(WidgetTester tester, int messageId) { final widget = tester.widget(find.descendant( - of: find.byType(MessageItem), + of: find.byKey(ValueKey(messageId)), matching: find.byType(FadeTransition))); return widget.opacity; } @@ -313,23 +313,23 @@ void main() { final message = eg.streamMessage(flags: [MessageFlag.read]); await setupMessageListPage(tester, messages: [message]); - check(getAnimation(tester).value).equals(0); + check(getAnimation(tester, message.id).value).equals(0); store.handleEvent(eg.updateMessageFlagsRemoveEvent( MessageFlag.read, [message])); await tester.pump(); // process handleEvent - check(getAnimation(tester).status).equals(AnimationStatus.forward); + check(getAnimation(tester, message.id).status).equals(AnimationStatus.forward); await tester.pumpAndSettle(); - check(getAnimation(tester).value).equals(1.0); + check(getAnimation(tester, message.id).value).equals(1.0); }); testWidgets('from unread to read', (WidgetTester tester) async { final message = eg.streamMessage(flags: []); await setupMessageListPage(tester, messages: [message]); - check(getAnimation(tester).value).equals(1.0); + check(getAnimation(tester, message.id).value).equals(1.0); store.handleEvent(UpdateMessageFlagsAddEvent( id: 1, @@ -338,25 +338,16 @@ void main() { all: false, )); await tester.pump(); // process handleEvent - check(getAnimation(tester).status).equals(AnimationStatus.forward); + check(getAnimation(tester, message.id).status).equals(AnimationStatus.forward); await tester.pumpAndSettle(); - check(getAnimation(tester).value).equals(0); + check(getAnimation(tester, message.id).value).equals(0); }); testWidgets('animation state persistence', (WidgetTester tester) async { // Check that _UnreadMarker maintains its in-progress animation // as the number of items change in MessageList. - - // TODO: pull this out into group - Animation getAnimation(WidgetTester tester, int messageId) { - final widget = tester.widget(find.descendant( - of: find.byKey(ValueKey(messageId)), - matching: find.byType(FadeTransition))); - return widget.opacity; - } - final message = eg.streamMessage(id: 1, flags: []); await setupMessageListPage(tester, messages: [message]);