Skip to content

Commit 6eee822

Browse files
committed
inbox test: Test that stream header changes color on color-change event
This will help verify the upcoming refactor, zulip#393 (storing stream-color variants in DesignVariables instead of Subscription model objects).
1 parent 8c630a7 commit 6eee822

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

test/widgets/inbox_test.dart

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ void main() {
9292
}
9393

9494
/// Set up an inbox view with lots of interesting content.
95-
Future<void> setupVarious(WidgetTester tester) async {
95+
Future<void> setupVarious(WidgetTester tester, {int? sub1Color}) async {
9696
final stream1 = eg.stream(streamId: 1, name: 'stream 1');
97-
final sub1 = eg.subscription(stream1);
97+
final sub1 = eg.subscription(stream1, color: sub1Color);
9898
final stream2 = eg.stream(streamId: 2, name: 'stream 2');
9999
final sub2 = eg.subscription(stream2);
100100

@@ -467,6 +467,24 @@ void main() {
467467
checkAppearsUncollapsed(tester, 1, findSectionContent);
468468
});
469469

470+
testWidgets('uncollapsed header changes background color when [subscription.color] changes', (tester) async {
471+
final initialColor = Colors.indigo.value;
472+
473+
await setupVarious(tester, sub1Color: initialColor);
474+
checkAppearsUncollapsed(tester, 1, find.text('specific topic'));
475+
476+
check(streamHeaderBackgroundColor(tester, 1))
477+
.equals(StreamColorSwatch.light(initialColor).barBackground);
478+
479+
final newColor = Colors.orange.value;
480+
store.handleEvent(SubscriptionUpdateEvent(id: 1, streamId: 1,
481+
property: SubscriptionProperty.color, value: newColor));
482+
await tester.pump();
483+
484+
check(streamHeaderBackgroundColor(tester, 1))
485+
.equals(StreamColorSwatch.light(newColor).barBackground);
486+
});
487+
470488
testWidgets('collapse stream section when partially offscreen: '
471489
'header remains sticky at top', (tester) async {
472490
await setupVarious(tester);

0 commit comments

Comments
 (0)