Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: added tests for lib/views/after_auth_screens/feed/organization_feed.dart #2652

Closed
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,45 @@ void main() {
verify(mockViewModel.nextPage()).called(1);
verify(mockViewModel.previousPage()).called(1);
});

testWidgets('check if FloatingActionButton click works fine',
(tester) async {
// Arrange
final model = locator<MainScreenViewModel>();
await tester.pumpWidget(createOrganizationFeedScreen(homeModel: model));
await tester.pumpAndSettle();

// Simulate Tap
final fabFinder = find.byKey(const Key('floating_action_btn'));
expect(fabFinder, findsOneWidget);
await tester.tap(fabFinder);

// Verify the /addpostscreen is pushed
await tester.pump();
verify(locator<NavigationService>().pushScreen('/addpostscreen'));
});

testWidgets(
'check if counters reset when scrolling occurs anywhere other than at the edge',
(tester) async {
// Arrange
when(mockViewModel.posts)
.thenReturn([post, post, post, post, post, post]);
final model = locator<MainScreenViewModel>();
await tester.pumpWidget(createOrganizationFeedScreen(homeModel: model));
await tester.pumpAndSettle();

// Simulate Scroll within content (not at edge)
await tester.drag(
find.byKey(const Key('listView')),
const Offset(0, -200),
);
await tester.pumpAndSettle();

// Verify that counters are reset and loading state
expect(find.byType(CircularProgressIndicator), findsNothing);
verifyNever(mockViewModel.nextPage());
verifyNever(mockViewModel.previousPage());
});
});
}