Skip to content

Commit

Permalink
inbox test: Test for all-DMs header and stream header background color
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chrisbobbe authored and gnprice committed Jun 21, 2024
1 parent f197242 commit 10ced60
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions test/widgets/inbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,32 @@ void main() {
return findRowByLabel(tester, 'Direct messages');
}

Color? allDmsHeaderBackgroundColor(WidgetTester tester) {
final row = findAllDmsHeaderRow(tester);
check(row).isNotNull();
final material = tester.firstWidget<Material>(
find.ancestor(
of: find.byWidget(row!),
matching: find.byType(Material)));
return material.color;
}

/// For the given stream ID, find the stream header element.
Widget? findStreamHeaderRow(WidgetTester tester, int streamId) {
final stream = store.streams[streamId]!;
return findRowByLabel(tester, stream.name);
}

Color? streamHeaderBackgroundColor(WidgetTester tester, int streamId) {
final row = findStreamHeaderRow(tester, streamId);
check(row).isNotNull();
final material = tester.firstWidget<Material>(
find.ancestor(
of: find.byWidget(row!),
matching: find.byType(Material)));
return material.color;
}

IconData expectedStreamHeaderIcon(int streamId) {
final subscription = store.subscriptions[streamId]!;
return switch (subscription) {
Expand Down Expand Up @@ -310,7 +330,8 @@ void main() {
check(headerRow).isNotNull();
final icon = findHeaderCollapseIcon(tester, headerRow!);
check(icon).icon.equals(ZulipIcons.arrow_down);
// TODO check bar background color
check(allDmsHeaderBackgroundColor(tester))
.isNotNull().equals(const HSLColor.fromAHSL(1, 46, 0.35, 0.93).toColor());
check(tester.widgetList(findSectionContent)).isNotEmpty();
}

Expand All @@ -327,7 +348,8 @@ void main() {
check(headerRow).isNotNull();
final icon = findHeaderCollapseIcon(tester, headerRow!);
check(icon).icon.equals(ZulipIcons.arrow_right);
// TODO check bar background color
check(allDmsHeaderBackgroundColor(tester))
.isNotNull().equals(Colors.white);
check(tester.widgetList(findSectionContent)).isEmpty();
}

Expand Down Expand Up @@ -403,7 +425,8 @@ void main() {
check(collapseIcon).icon.equals(ZulipIcons.arrow_down);
final streamIcon = findStreamHeaderIcon(tester, streamId);
check(streamIcon).color.equals(subscription.colorSwatch().iconOnBarBackground);
// TODO check bar background color
check(streamHeaderBackgroundColor(tester, streamId))
.isNotNull().equals(subscription.colorSwatch().barBackground);
check(tester.widgetList(findSectionContent)).isNotEmpty();
}

Expand All @@ -424,7 +447,8 @@ void main() {
check(collapseIcon).icon.equals(ZulipIcons.arrow_right);
final streamIcon = findStreamHeaderIcon(tester, streamId);
check(streamIcon).color.equals(subscription.colorSwatch().iconOnPlainBackground);
// TODO check bar background color
check(streamHeaderBackgroundColor(tester, streamId))
.isNotNull().equals(Colors.white);
check(tester.widgetList(findSectionContent)).isEmpty();
}

Expand Down

0 comments on commit 10ced60

Please sign in to comment.