From d7b94c7182cd10d7634d72441b8536aa4ed8f0ea Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Tue, 18 Jun 2024 12:19:35 -0700 Subject: [PATCH] inbox test: Test that stream header changes color on color-change event This will help verify the upcoming refactor, #393 (storing stream-color variants in DesignVariables instead of Subscription model objects). --- test/widgets/inbox_test.dart | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/test/widgets/inbox_test.dart b/test/widgets/inbox_test.dart index f5aab8b531..b68221945e 100644 --- a/test/widgets/inbox_test.dart +++ b/test/widgets/inbox_test.dart @@ -92,9 +92,9 @@ void main() { } /// Set up an inbox view with lots of interesting content. - Future setupVarious(WidgetTester tester) async { + Future setupVarious(WidgetTester tester, {int? sub1Color}) async { final stream1 = eg.stream(streamId: 1, name: 'stream 1'); - final sub1 = eg.subscription(stream1); + final sub1 = eg.subscription(stream1, color: sub1Color); final stream2 = eg.stream(streamId: 2, name: 'stream 2'); final sub2 = eg.subscription(stream2); @@ -467,6 +467,29 @@ void main() { checkAppearsUncollapsed(tester, 1, findSectionContent); }); + testWidgets('uncollapsed header changes background color when [subscription.color] changes', (tester) async { + final initialColor = Colors.indigo.value; + + final stream = eg.stream(streamId: 1); + await setupPage(tester, + streams: [stream], + subscriptions: [eg.subscription(stream, color: initialColor)], + unreadMessages: [eg.streamMessage(stream: stream, topic: 'specific topic', flags: [])]); + + checkAppearsUncollapsed(tester, stream.streamId, find.text('specific topic')); + + check(streamHeaderBackgroundColor(tester, 1)) + .equals(StreamColorSwatch.light(initialColor).barBackground); + + final newColor = Colors.orange.value; + store.handleEvent(SubscriptionUpdateEvent(id: 1, streamId: 1, + property: SubscriptionProperty.color, value: newColor)); + await tester.pump(); + + check(streamHeaderBackgroundColor(tester, 1)) + .equals(StreamColorSwatch.light(newColor).barBackground); + }); + testWidgets('collapse stream section when partially offscreen: ' 'header remains sticky at top', (tester) async { await setupVarious(tester);