Skip to content

Commit

Permalink
inbox test: Test that stream header changes color on color-change event
Browse files Browse the repository at this point in the history
This will help verify the upcoming refactor, zulip#393 (storing
stream-color variants in DesignVariables instead of Subscription
model objects).
  • Loading branch information
chrisbobbe authored and gnprice committed Jun 21, 2024
1 parent 10ced60 commit a9cd5ba
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions test/widgets/inbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ void main() {
}

/// Set up an inbox view with lots of interesting content.
Future<void> setupVarious(WidgetTester tester) async {
Future<void> 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);

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a9cd5ba

Please sign in to comment.