Skip to content

Commit

Permalink
inbox test [nfc]: Pull out findRowByLabel
Browse files Browse the repository at this point in the history
This will be used later to match other types
of rows.
  • Loading branch information
sirpengi committed Feb 9, 2024
1 parent 96ee005 commit d72a0a6
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions test/widgets/inbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,10 @@ void main() {
]);
}

/// Find an all-DMs header element.
// Why "an" all-DMs header element? Because there might be two: one that
// floats at the top of the screen to give the "sticky header" effect, and one
// that scrolls normally, the way it would in a regular [ListView].
// TODO we'll need to find both and run checks on them, knowing which is which.
Widget? findAllDmsHeaderRow(WidgetTester tester) {
/// Find a row with the given label.
Widget? findRowByLabel(WidgetTester tester, String label) {
final rowLabel = tester.widgetList(
find.text('Direct messages'),
find.text(label),
).firstOrNull;
if (rowLabel == null) {
return null;
Expand All @@ -89,22 +85,23 @@ void main() {
matching: find.byType(Row)));
}

/// Find an all-DMs header element.
// Why "an" all-DMs header element? Because there might be two: one that
// floats at the top of the screen to give the "sticky header" effect, and one
// that scrolls normally, the way it would in a regular [ListView].
// TODO we'll need to find both and run checks on them, knowing which is which.
Widget? findAllDmsHeaderRow(WidgetTester tester) {
return findRowByLabel(tester, 'Direct messages');
}

/// For the given stream ID, find a stream header element.
// Why "an" all-DMs header element? Because there might be two: one that
// floats at the top of the screen to give the "sticky header" effect, and one
// that scrolls normally, the way it would in a regular [ListView].
// TODO we'll need to find both and run checks on them, knowing which is which.
Widget? findStreamHeaderRow(WidgetTester tester, int streamId) {
final stream = store.streams[streamId]!;
final rowLabel = tester.widgetList(find.text(stream.name)).firstOrNull;
if (rowLabel == null) {
return null;
}

return tester.widget(
find.ancestor(
of: find.byWidget(rowLabel),
matching: find.byType(Row)));
return findRowByLabel(tester, stream.name);
}

IconData expectedStreamHeaderIcon(int streamId) {
Expand Down

0 comments on commit d72a0a6

Please sign in to comment.