Skip to content

Commit

Permalink
test: scroll widgets into view before testing
Browse files Browse the repository at this point in the history
  • Loading branch information
d-loose committed Dec 2, 2024
1 parent 8f315b2 commit d27047a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/app_center/test/manage_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ void main() {

await tester.pumpAndSettle();
final testTile = find.snapTile('Test Snap');

// Use the top-level scrollbar to ensure the tiles are visible before testing them.
final scrollable = find.byType(Scrollable).first;

await tester.scrollUntilVisible(
testTile,
kMinInteractiveDimension / 2,
scrollable: scrollable,
);
expect(testTile, findsOneWidget);
expect(
find.descendant(of: testTile, matching: find.text('1.0')),
Expand All @@ -142,6 +151,11 @@ void main() {
);

final testTile2 = find.snapTile('Another Test Snap');
await tester.scrollUntilVisible(
testTile2,
kMinInteractiveDimension / 2,
scrollable: scrollable,
);
expect(testTile2, findsOneWidget);
expect(
find.descendant(of: testTile2, matching: find.text('1.5')),
Expand Down Expand Up @@ -195,8 +209,22 @@ void main() {
)
.hitTestable();

// Use the top-level scrollbar to ensure the buttons are visible before testing them.
final scrollable = find.byType(Scrollable).first;

await tester.scrollUntilVisible(
openButton,
kMinInteractiveDimension / 2,
scrollable: scrollable,
);
expect(openButton, findsOneWidget);
expect(openButton, isEnabled);

await tester.scrollUntilVisible(
openButton2,
kMinInteractiveDimension / 2,
scrollable: scrollable,
);
expect(openButton2, findsOneWidget);
expect(openButton2, isDisabled);

Expand Down

0 comments on commit d27047a

Please sign in to comment.