Skip to content

Commit 8c630a7

Browse files
committed
inbox test: Test for all-DMs header and stream header background color
I started this by writing streamHeaderBackgroundColor just for an upcoming test (checking the stream header responds to update-stream-color events). But it was a nice opportunity to complete some existing TODOs.
1 parent 7711929 commit 8c630a7

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

test/widgets/inbox_test.dart

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,32 @@ void main() {
134134
return findRowByLabel(tester, 'Direct messages');
135135
}
136136

137+
Color? allDmsHeaderBackgroundColor(WidgetTester tester) {
138+
final row = findAllDmsHeaderRow(tester);
139+
check(row).isNotNull();
140+
final material = tester.firstWidget<Material>(
141+
find.ancestor(
142+
of: find.byWidget(row!),
143+
matching: find.byType(Material)));
144+
return material.color;
145+
}
146+
137147
/// For the given stream ID, find the stream header element.
138148
Widget? findStreamHeaderRow(WidgetTester tester, int streamId) {
139149
final stream = store.streams[streamId]!;
140150
return findRowByLabel(tester, stream.name);
141151
}
142152

153+
Color? streamHeaderBackgroundColor(WidgetTester tester, int streamId) {
154+
final row = findStreamHeaderRow(tester, streamId);
155+
check(row).isNotNull();
156+
final material = tester.firstWidget<Material>(
157+
find.ancestor(
158+
of: find.byWidget(row!),
159+
matching: find.byType(Material)));
160+
return material.color;
161+
}
162+
143163
IconData expectedStreamHeaderIcon(int streamId) {
144164
final subscription = store.subscriptions[streamId]!;
145165
return switch (subscription) {
@@ -310,7 +330,8 @@ void main() {
310330
check(headerRow).isNotNull();
311331
final icon = findHeaderCollapseIcon(tester, headerRow!);
312332
check(icon).icon.equals(ZulipIcons.arrow_down);
313-
// TODO check bar background color
333+
check(allDmsHeaderBackgroundColor(tester))
334+
.isNotNull().equals(const HSLColor.fromAHSL(1, 46, 0.35, 0.93).toColor());
314335
check(tester.widgetList(findSectionContent)).isNotEmpty();
315336
}
316337

@@ -327,7 +348,8 @@ void main() {
327348
check(headerRow).isNotNull();
328349
final icon = findHeaderCollapseIcon(tester, headerRow!);
329350
check(icon).icon.equals(ZulipIcons.arrow_right);
330-
// TODO check bar background color
351+
check(allDmsHeaderBackgroundColor(tester))
352+
.isNotNull().equals(Colors.white);
331353
check(tester.widgetList(findSectionContent)).isEmpty();
332354
}
333355

@@ -403,7 +425,8 @@ void main() {
403425
check(collapseIcon).icon.equals(ZulipIcons.arrow_down);
404426
final streamIcon = findStreamHeaderIcon(tester, streamId);
405427
check(streamIcon).color.equals(subscription.colorSwatch().iconOnBarBackground);
406-
// TODO check bar background color
428+
check(streamHeaderBackgroundColor(tester, streamId))
429+
.isNotNull().equals(subscription.colorSwatch().barBackground);
407430
check(tester.widgetList(findSectionContent)).isNotEmpty();
408431
}
409432

@@ -424,7 +447,8 @@ void main() {
424447
check(collapseIcon).icon.equals(ZulipIcons.arrow_right);
425448
final streamIcon = findStreamHeaderIcon(tester, streamId);
426449
check(streamIcon).color.equals(subscription.colorSwatch().iconOnPlainBackground);
427-
// TODO check bar background color
450+
check(streamHeaderBackgroundColor(tester, streamId))
451+
.isNotNull().equals(Colors.white);
428452
check(tester.widgetList(findSectionContent)).isEmpty();
429453
}
430454

0 commit comments

Comments
 (0)