From 80966f8cfc484a6116ad378960dafb1fa1320142 Mon Sep 17 00:00:00 2001 From: Camille Lannoye <101193378+camillelnne@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:48:21 +0200 Subject: [PATCH 01/10] feat(end-to-end-test): flow from login to homepage --- integration_test/app_test.dart | 70 ++++++++++++++++++++++++++++++++++ pubspec.yaml | 2 + 2 files changed, 72 insertions(+) create mode 100644 integration_test/app_test.dart diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart new file mode 100644 index 00000000..a705850e --- /dev/null +++ b/integration_test/app_test.dart @@ -0,0 +1,70 @@ +import "package:fake_cloud_firestore/fake_cloud_firestore.dart"; +import "package:firebase_core/firebase_core.dart"; +import "package:flutter_test/flutter_test.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; +import "package:integration_test/integration_test.dart"; +import "package:proxima/main.dart"; +import "package:proxima/services/database/user_repository_service.dart"; +import "package:proxima/viewmodels/home_view_model.dart"; +import "package:proxima/views/pages/create_account_page.dart"; +import "package:proxima/views/pages/home/home_page.dart"; +import "package:proxima/views/pages/login/login_button.dart"; + +import "../test/services/firebase/setup_firebase_mocks.dart"; +import "../test/services/firebase/testing_auth_providers.dart"; +import "../test/viewmodels/mock_home_view_model.dart"; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + late FakeFirebaseFirestore fakeFireStore; + late UserRepositoryService userRepo; + + setUpAll(() async { + setupFirebaseAuthMocks(); + await Firebase.initializeApp(); + fakeFireStore = FakeFirebaseFirestore(); + userRepo = UserRepositoryService(firestore: fakeFireStore); + }); + + testWidgets("E2E: Login Page -> Create Account -> Home Page", + (WidgetTester tester) async { + // Set up the app with mocked providers + await tester.pumpWidget( + ProviderScope( + overrides: [ + ...firebaseAuthMocksOverrides, + userRepositoryProvider.overrideWithValue(userRepo), + postOverviewProvider.overrideWith( + () => MockHomeViewModel(), + ), + ], + child: const ProximaApp(), + ), + ); + + await tester.pumpAndSettle(); + + /* Login Page */ + final Finder loginButtonFinder = find.byType(LoginButton); + await tester.tap(loginButtonFinder); + await tester.pumpAndSettle(); // Wait for page navigation + + /* Create Account Page */ + expect(find.byType(CreateAccountPage), findsOneWidget); + + // Enter details in the Create Account Page + await tester.enterText( + find.byKey(CreateAccountPage.uniqueUsernameFieldKey), "newUsername"); + await tester.enterText( + find.byKey(CreateAccountPage.pseudoFieldKey), "newPseudo"); + await tester.pumpAndSettle(); + + // Submit the create account form + await tester.tap(find.byKey(CreateAccountPage.confirmButtonKey)); + await tester.pumpAndSettle(); // Wait for navigation + + /* Home Page */ + expect(find.byType(HomePage), findsOneWidget); + }); +} diff --git a/pubspec.yaml b/pubspec.yaml index 50c0d146..ff532a18 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,6 +31,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + integration_test: + sdk: flutter flutter_lints: ^3.0.0 riverpod_lint: ^2.3.9 From ed35bbd572e8b3f9ee3483197a509556e4f40cd6 Mon Sep 17 00:00:00 2001 From: Camille Lannoye <101193378+camillelnne@users.noreply.github.com> Date: Fri, 12 Apr 2024 16:21:50 +0200 Subject: [PATCH 02/10] feat(end-to-end-test): test navigation to profile page and in bottom bar --- integration_test/app_test.dart | 56 ++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index a705850e..59b2bfbf 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -6,9 +6,12 @@ import "package:integration_test/integration_test.dart"; import "package:proxima/main.dart"; import "package:proxima/services/database/user_repository_service.dart"; import "package:proxima/viewmodels/home_view_model.dart"; +import "package:proxima/views/navigation/leading_back_button/leading_back_button.dart"; import "package:proxima/views/pages/create_account_page.dart"; import "package:proxima/views/pages/home/home_page.dart"; +import "package:proxima/views/pages/home/top_bar/app_top_bar.dart"; import "package:proxima/views/pages/login/login_button.dart"; +import "package:proxima/views/pages/profile/profile_page.dart"; import "../test/services/firebase/setup_firebase_mocks.dart"; import "../test/services/firebase/testing_auth_providers.dart"; @@ -55,9 +58,9 @@ void main() { // Enter details in the Create Account Page await tester.enterText( - find.byKey(CreateAccountPage.uniqueUsernameFieldKey), "newUsername"); + find.byKey(CreateAccountPage.uniqueUsernameFieldKey), "newUsername",); await tester.enterText( - find.byKey(CreateAccountPage.pseudoFieldKey), "newPseudo"); + find.byKey(CreateAccountPage.pseudoFieldKey), "newPseudo",); await tester.pumpAndSettle(); // Submit the create account form @@ -66,5 +69,54 @@ void main() { /* Home Page */ expect(find.byType(HomePage), findsOneWidget); + + /* Profile Page */ + + final profilePicture = find.byKey(AppTopBar.profilePictureKey); + expect(profilePicture, findsOneWidget); + await tester.tap(profilePicture); + await tester.pumpAndSettle(); + // Check that the profile page is displayed + final profilePage = find.byType(ProfilePage); + expect(profilePage, findsOneWidget); + // Check that the post tab is displayed + final postTab = find.byKey(ProfilePage.postTabKey); + expect(postTab, findsOneWidget); + // Check that the comment tab is displayed + final commentTab = find.byKey(ProfilePage.commentTabKey); + expect(commentTab, findsOneWidget); + //Check that post column is displayed + final postColumn = find.byKey(ProfilePage.postColumnKey); + expect(postColumn, findsOneWidget); + // Tap on the comment tab + await tester.tap(commentTab); + await tester.pumpAndSettle(); + // Check that the comment column is displayed + final commentColumn = find.byKey(ProfilePage.commentColumnKey); + expect(commentColumn, findsOneWidget); + + // Find arrow back button + final backButton = find.byType(LeadingBackButton); + expect(backButton, findsOneWidget); + await tester.tap(backButton); + await tester.pumpAndSettle(); + expect(find.byType(HomePage), findsOneWidget); + + + /* Challenges */ + await tester.tap(find.text("Challenge")); + await tester.pumpAndSettle(); + expect(find.text("Challenges"), findsOneWidget); + + /* Group */ + await tester.tap(find.text("Group")); + await tester.pumpAndSettle(); + expect(find.text("Proxima"), findsOneWidget); + + /* Map */ + await tester.tap(find.text("Map")); + await tester.pumpAndSettle(); + expect(find.text("Proxima"), findsOneWidget); + }); } From 8fac494be5cb590e871ccc06c17a8883c12bb94e Mon Sep 17 00:00:00 2001 From: Camille Lannoye <101193378+camillelnne@users.noreply.github.com> Date: Fri, 12 Apr 2024 16:46:10 +0200 Subject: [PATCH 03/10] refactor(end-to-end-test): create one method per page tested --- integration_test/app_test.dart | 148 +++++++++++++++++++-------------- 1 file changed, 85 insertions(+), 63 deletions(-) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index 59b2bfbf..ed42398a 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -11,6 +11,7 @@ import "package:proxima/views/pages/create_account_page.dart"; import "package:proxima/views/pages/home/home_page.dart"; import "package:proxima/views/pages/home/top_bar/app_top_bar.dart"; import "package:proxima/views/pages/login/login_button.dart"; +import "package:proxima/views/pages/login/login_page.dart"; import "package:proxima/views/pages/profile/profile_page.dart"; import "../test/services/firebase/setup_firebase_mocks.dart"; @@ -48,75 +49,96 @@ void main() { await tester.pumpAndSettle(); - /* Login Page */ - final Finder loginButtonFinder = find.byType(LoginButton); - await tester.tap(loginButtonFinder); - await tester.pumpAndSettle(); // Wait for page navigation - - /* Create Account Page */ - expect(find.byType(CreateAccountPage), findsOneWidget); - - // Enter details in the Create Account Page - await tester.enterText( - find.byKey(CreateAccountPage.uniqueUsernameFieldKey), "newUsername",); - await tester.enterText( - find.byKey(CreateAccountPage.pseudoFieldKey), "newPseudo",); - await tester.pumpAndSettle(); - - // Submit the create account form - await tester.tap(find.byKey(CreateAccountPage.confirmButtonKey)); - await tester.pumpAndSettle(); // Wait for navigation + await loginToCreateAccount(tester); + await createAccountToHome(tester); + await homeToProfilePage(tester); + await bottomNavigation(tester); + }); +} - /* Home Page */ - expect(find.byType(HomePage), findsOneWidget); +/// Navigate to the login page and login +Future loginToCreateAccount(WidgetTester tester) async { + expect(find.byType(LoginPage), findsOneWidget); - /* Profile Page */ + final loginButton = find.byKey(LoginButton.loginButtonKey); + await tester.tap(loginButton); + await tester.pumpAndSettle(); +} - final profilePicture = find.byKey(AppTopBar.profilePictureKey); - expect(profilePicture, findsOneWidget); - await tester.tap(profilePicture); - await tester.pumpAndSettle(); - // Check that the profile page is displayed - final profilePage = find.byType(ProfilePage); - expect(profilePage, findsOneWidget); - // Check that the post tab is displayed - final postTab = find.byKey(ProfilePage.postTabKey); - expect(postTab, findsOneWidget); - // Check that the comment tab is displayed - final commentTab = find.byKey(ProfilePage.commentTabKey); - expect(commentTab, findsOneWidget); - //Check that post column is displayed - final postColumn = find.byKey(ProfilePage.postColumnKey); - expect(postColumn, findsOneWidget); - // Tap on the comment tab - await tester.tap(commentTab); - await tester.pumpAndSettle(); - // Check that the comment column is displayed - final commentColumn = find.byKey(ProfilePage.commentColumnKey); - expect(commentColumn, findsOneWidget); - - // Find arrow back button - final backButton = find.byType(LeadingBackButton); - expect(backButton, findsOneWidget); - await tester.tap(backButton); - await tester.pumpAndSettle(); - expect(find.byType(HomePage), findsOneWidget); +/// Create an account and navigate to the home page +Future createAccountToHome(WidgetTester tester) async { + expect(find.byType(CreateAccountPage), findsOneWidget); + + // Enter details in the Create Account Page + await tester.enterText( + find.byKey(CreateAccountPage.uniqueUsernameFieldKey), + "newUsername", + ); + await tester.enterText( + find.byKey(CreateAccountPage.pseudoFieldKey), + "newPseudo", + ); + await tester.pumpAndSettle(); + + // Submit the create account form + await tester.tap(find.byKey(CreateAccountPage.confirmButtonKey)); + await tester.pumpAndSettle(); // Wait for navigation + + expect(find.byType(HomePage), findsOneWidget); +} +/// Navigate to profile page from home page and go back +Future homeToProfilePage(WidgetTester tester) async { + expect(find.byType(HomePage), findsOneWidget); + + final profilePicture = find.byKey(AppTopBar.profilePictureKey); + expect(profilePicture, findsOneWidget); + await tester.tap(profilePicture); + await tester.pumpAndSettle(); + + // Check that the profile page is displayed + final profilePage = find.byType(ProfilePage); + expect(profilePage, findsOneWidget); + // Check that the post tab is displayed + final postTab = find.byKey(ProfilePage.postTabKey); + expect(postTab, findsOneWidget); + // Check that the comment tab is displayed + final commentTab = find.byKey(ProfilePage.commentTabKey); + expect(commentTab, findsOneWidget); + //Check that post column is displayed + final postColumn = find.byKey(ProfilePage.postColumnKey); + expect(postColumn, findsOneWidget); + // Tap on the comment tab + await tester.tap(commentTab); + await tester.pumpAndSettle(); + // Check that the comment column is displayed + final commentColumn = find.byKey(ProfilePage.commentColumnKey); + expect(commentColumn, findsOneWidget); + + // Find arrow back button and go back to home page + final backButton = find.byType(LeadingBackButton); + expect(backButton, findsOneWidget); + await tester.tap(backButton); + await tester.pumpAndSettle(); + expect(find.byType(HomePage), findsOneWidget); +} - /* Challenges */ - await tester.tap(find.text("Challenge")); - await tester.pumpAndSettle(); - expect(find.text("Challenges"), findsOneWidget); +/// Navigate to the other pages using bottom navigation bar +Future bottomNavigation(WidgetTester tester) async { + expect(find.byType(HomePage), findsOneWidget); - /* Group */ - await tester.tap(find.text("Group")); - await tester.pumpAndSettle(); - expect(find.text("Proxima"), findsOneWidget); + // Challenges + await tester.tap(find.text("Challenge")); + await tester.pumpAndSettle(); + expect(find.text("Challenges"), findsOneWidget); - /* Map */ - await tester.tap(find.text("Map")); - await tester.pumpAndSettle(); - expect(find.text("Proxima"), findsOneWidget); + // Group + await tester.tap(find.text("Group")); + await tester.pumpAndSettle(); + expect(find.text("Proxima"), findsOneWidget); - }); + // Map + await tester.tap(find.text("Map")); + await tester.pumpAndSettle(); + expect(find.text("Proxima"), findsOneWidget); } From 001f4b5272ba18eb6d46e33919f36f6c123a12f7 Mon Sep 17 00:00:00 2001 From: Camille Lannoye <101193378+camillelnne@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:36:17 +0200 Subject: [PATCH 04/10] feat(end-to-end-test): navigate to new post form and fill it --- integration_test/app_test.dart | 58 +++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index ed42398a..b3e10530 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -6,12 +6,14 @@ import "package:integration_test/integration_test.dart"; import "package:proxima/main.dart"; import "package:proxima/services/database/user_repository_service.dart"; import "package:proxima/viewmodels/home_view_model.dart"; +import "package:proxima/views/home_content/feed/post_feed.dart"; import "package:proxima/views/navigation/leading_back_button/leading_back_button.dart"; import "package:proxima/views/pages/create_account_page.dart"; import "package:proxima/views/pages/home/home_page.dart"; import "package:proxima/views/pages/home/top_bar/app_top_bar.dart"; import "package:proxima/views/pages/login/login_button.dart"; import "package:proxima/views/pages/login/login_page.dart"; +import "package:proxima/views/pages/new_post/new_post_form.dart"; import "package:proxima/views/pages/profile/profile_page.dart"; import "../test/services/firebase/setup_firebase_mocks.dart"; @@ -31,7 +33,7 @@ void main() { userRepo = UserRepositoryService(firestore: fakeFireStore); }); - testWidgets("E2E: Login Page -> Create Account -> Home Page", + testWidgets("End-to-end test of the app navigation flow", (WidgetTester tester) async { // Set up the app with mocked providers await tester.pumpWidget( @@ -53,6 +55,7 @@ void main() { await createAccountToHome(tester); await homeToProfilePage(tester); await bottomNavigation(tester); + await createPost(tester); }); } @@ -99,18 +102,23 @@ Future homeToProfilePage(WidgetTester tester) async { // Check that the profile page is displayed final profilePage = find.byType(ProfilePage); expect(profilePage, findsOneWidget); + // Check that the post tab is displayed final postTab = find.byKey(ProfilePage.postTabKey); expect(postTab, findsOneWidget); + // Check that the comment tab is displayed final commentTab = find.byKey(ProfilePage.commentTabKey); expect(commentTab, findsOneWidget); + //Check that post column is displayed final postColumn = find.byKey(ProfilePage.postColumnKey); expect(postColumn, findsOneWidget); + // Tap on the comment tab await tester.tap(commentTab); await tester.pumpAndSettle(); + // Check that the comment column is displayed final commentColumn = find.byKey(ProfilePage.commentColumnKey); expect(commentColumn, findsOneWidget); @@ -141,4 +149,52 @@ Future bottomNavigation(WidgetTester tester) async { await tester.tap(find.text("Map")); await tester.pumpAndSettle(); expect(find.text("Proxima"), findsOneWidget); + + // Home (Feed) + await tester.tap(find.text("Feed")); + await tester.pumpAndSettle(); + expect(find.byType(HomePage), findsOneWidget); +} + +/// Create a post +Future createPost(WidgetTester tester) async { + expect(find.byType(HomePage), findsOneWidget); + + // Tap on the new post button + await tester.tap(find.byKey(PostFeed.newPostButtonTextKey)); + await tester.pumpAndSettle(); + + // Check that the new post page is displayed + expect(find.byType(NewPostForm), findsOneWidget); + + // Enter post details + const postTitle = "I like turtles"; + const postDescription = "Look at them go!"; + + await tester.enterText( + find.byKey(NewPostForm.titleFieldKey), + postTitle, + ); + + await tester.enterText( + find.byKey(NewPostForm.bodyFieldKey), + postDescription, + ); + + await tester.pumpAndSettle(); + +/* + // Submit the post + await tester.tap(find.byKey(NewPostForm.postButtonKey)); + await tester.pumpAndSettle(); + + // refresh the page by pulling down + await tester.drag(find.byType(PostFeed), const Offset(0, 500)); + await tester.pumpAndSettle(); + + // Check that the post is displayed + + expect(find.text(postTitle), findsOneWidget); + expect(find.text(postDescription), findsOneWidget); + */ } From f41003d741f77b5fa5e75a475a3fd0a712a5dd51 Mon Sep 17 00:00:00 2001 From: Alberts Reisons Date: Fri, 12 Apr 2024 18:02:20 +0200 Subject: [PATCH 05/10] fix(integration test): mock the geopos service and post repo Post is still not displayed in the end. --- integration_test/app_test.dart | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index b3e10530..08602ec9 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -1,10 +1,14 @@ +import "package:cloud_firestore/cloud_firestore.dart"; import "package:fake_cloud_firestore/fake_cloud_firestore.dart"; import "package:firebase_core/firebase_core.dart"; import "package:flutter_test/flutter_test.dart"; import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:integration_test/integration_test.dart"; +import "package:mockito/mockito.dart"; import "package:proxima/main.dart"; +import "package:proxima/services/database/post_repository_service.dart"; import "package:proxima/services/database/user_repository_service.dart"; +import "package:proxima/services/geolocation_service.dart"; import "package:proxima/viewmodels/home_view_model.dart"; import "package:proxima/views/home_content/feed/post_feed.dart"; import "package:proxima/views/navigation/leading_back_button/leading_back_button.dart"; @@ -18,6 +22,7 @@ import "package:proxima/views/pages/profile/profile_page.dart"; import "../test/services/firebase/setup_firebase_mocks.dart"; import "../test/services/firebase/testing_auth_providers.dart"; +import "../test/services/mock_geo_location_service.dart"; import "../test/viewmodels/mock_home_view_model.dart"; void main() { @@ -25,12 +30,21 @@ void main() { late FakeFirebaseFirestore fakeFireStore; late UserRepositoryService userRepo; + late PostRepositoryService postRepo; + + MockGeoLocationService geoLocationService = MockGeoLocationService(); + const GeoPoint testLocation = GeoPoint(0, 0); setUpAll(() async { setupFirebaseAuthMocks(); await Firebase.initializeApp(); fakeFireStore = FakeFirebaseFirestore(); userRepo = UserRepositoryService(firestore: fakeFireStore); + postRepo = PostRepositoryService(firestore: fakeFireStore); + + when(geoLocationService.getCurrentPosition()).thenAnswer( + (_) => Future.value(testLocation), + ); }); testWidgets("End-to-end test of the app navigation flow", @@ -44,6 +58,8 @@ void main() { postOverviewProvider.overrideWith( () => MockHomeViewModel(), ), + geoLocationServiceProvider.overrideWithValue(geoLocationService), + postRepositoryProvider.overrideWithValue(postRepo), ], child: const ProximaApp(), ), @@ -183,7 +199,6 @@ Future createPost(WidgetTester tester) async { await tester.pumpAndSettle(); -/* // Submit the post await tester.tap(find.byKey(NewPostForm.postButtonKey)); await tester.pumpAndSettle(); @@ -193,8 +208,6 @@ Future createPost(WidgetTester tester) async { await tester.pumpAndSettle(); // Check that the post is displayed - expect(find.text(postTitle), findsOneWidget); expect(find.text(postDescription), findsOneWidget); - */ } From 72e6c13729f4e2f8dccd1e6b3847d51d61814b63 Mon Sep 17 00:00:00 2001 From: Alberts Reisons Date: Fri, 12 Apr 2024 18:07:46 +0200 Subject: [PATCH 06/10] fix(integration test): remove home view model override We are using a fake database and not a mock home view that does not change. --- integration_test/app_test.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index 08602ec9..c573e338 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -9,7 +9,6 @@ import "package:proxima/main.dart"; import "package:proxima/services/database/post_repository_service.dart"; import "package:proxima/services/database/user_repository_service.dart"; import "package:proxima/services/geolocation_service.dart"; -import "package:proxima/viewmodels/home_view_model.dart"; import "package:proxima/views/home_content/feed/post_feed.dart"; import "package:proxima/views/navigation/leading_back_button/leading_back_button.dart"; import "package:proxima/views/pages/create_account_page.dart"; @@ -23,7 +22,6 @@ import "package:proxima/views/pages/profile/profile_page.dart"; import "../test/services/firebase/setup_firebase_mocks.dart"; import "../test/services/firebase/testing_auth_providers.dart"; import "../test/services/mock_geo_location_service.dart"; -import "../test/viewmodels/mock_home_view_model.dart"; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); @@ -55,9 +53,6 @@ void main() { overrides: [ ...firebaseAuthMocksOverrides, userRepositoryProvider.overrideWithValue(userRepo), - postOverviewProvider.overrideWith( - () => MockHomeViewModel(), - ), geoLocationServiceProvider.overrideWithValue(geoLocationService), postRepositoryProvider.overrideWithValue(postRepo), ], @@ -207,6 +202,8 @@ Future createPost(WidgetTester tester) async { await tester.drag(find.byType(PostFeed), const Offset(0, 500)); await tester.pumpAndSettle(); + await Future.delayed(const Duration(seconds: 2)); + // Check that the post is displayed expect(find.text(postTitle), findsOneWidget); expect(find.text(postDescription), findsOneWidget); From c0e88ba099cd207cff549371e81637d3754bd268 Mon Sep 17 00:00:00 2001 From: Alberts Reisons Date: Fri, 12 Apr 2024 18:15:25 +0200 Subject: [PATCH 07/10] fix(integration test): use refresh button instead of swipe Now refresh works --- integration_test/app_test.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index c573e338..8720c554 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -64,8 +64,8 @@ void main() { await loginToCreateAccount(tester); await createAccountToHome(tester); - await homeToProfilePage(tester); - await bottomNavigation(tester); + //await homeToProfilePage(tester); + //await bottomNavigation(tester); await createPost(tester); }); } @@ -202,7 +202,9 @@ Future createPost(WidgetTester tester) async { await tester.drag(find.byType(PostFeed), const Offset(0, 500)); await tester.pumpAndSettle(); - await Future.delayed(const Duration(seconds: 2)); + final refreshButton = find.byKey(PostFeed.refreshButtonKey); + await tester.tap(refreshButton); + await tester.pumpAndSettle(); // Check that the post is displayed expect(find.text(postTitle), findsOneWidget); From e810936bd6e537079ba5fea40fa5d1360c1effa1 Mon Sep 17 00:00:00 2001 From: Alberts Reisons Date: Fri, 12 Apr 2024 18:15:38 +0200 Subject: [PATCH 08/10] fix(integration test): restore full tests --- integration_test/app_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index 8720c554..2767864e 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -64,8 +64,8 @@ void main() { await loginToCreateAccount(tester); await createAccountToHome(tester); - //await homeToProfilePage(tester); - //await bottomNavigation(tester); + await homeToProfilePage(tester); + await bottomNavigation(tester); await createPost(tester); }); } From e62d38604542afe75c7122cff92e90d5b5f9a4e0 Mon Sep 17 00:00:00 2001 From: Alberts Reisons Date: Fri, 12 Apr 2024 18:20:12 +0200 Subject: [PATCH 09/10] format(integration test) --- integration_test/app_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index 2767864e..2b7715ec 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -41,7 +41,7 @@ void main() { postRepo = PostRepositoryService(firestore: fakeFireStore); when(geoLocationService.getCurrentPosition()).thenAnswer( - (_) => Future.value(testLocation), + (_) => Future.value(testLocation), ); }); From 85bbe26231ead36205e21b18261610702967a2b1 Mon Sep 17 00:00:00 2001 From: Alberts Reisons Date: Fri, 12 Apr 2024 22:47:34 +0200 Subject: [PATCH 10/10] feat(integration test): bottom bar navigation to new post --- integration_test/app_test.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index 2b7715ec..1a10cde6 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -161,6 +161,13 @@ Future bottomNavigation(WidgetTester tester) async { await tester.pumpAndSettle(); expect(find.text("Proxima"), findsOneWidget); + // New Post + await tester.tap(find.text("New post")); + await tester.pumpAndSettle(); + expect(find.text("Create a new post"), findsOneWidget); + await tester.tap(find.byKey(LeadingBackButton.leadingBackButtonKey)); + await tester.pumpAndSettle(); + // Home (Feed) await tester.tap(find.text("Feed")); await tester.pumpAndSettle();