-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start implementing Robot with auth flow tests + set optionURLReflects…
…ImperativeAPIs in tests
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
ecommerce_app/test/src/features/authentication/auth_flow_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../robot.dart'; | ||
|
||
void main() { | ||
testWidgets('Sign in and sign out flow', (tester) async { | ||
final r = Robot(tester); | ||
await r.pumpMyApp(); | ||
r.expectFindAllProductCards(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:ecommerce_app/src/app.dart'; | ||
import 'package:ecommerce_app/src/constants/test_products.dart'; | ||
import 'package:ecommerce_app/src/features/authentication/data/fake_auth_repository.dart'; | ||
import 'package:ecommerce_app/src/features/products/data/fake_products_repository.dart'; | ||
import 'package:ecommerce_app/src/features/products/presentation/products_list/product_card.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
class Robot { | ||
Robot(this.tester); | ||
final WidgetTester tester; | ||
|
||
Future<void> pumpMyApp() async { | ||
// Override repositories | ||
final productsRepository = FakeProductsRepository(addDelay: false); | ||
final authRepository = FakeAuthRepository(addDelay: false); | ||
await tester.pumpWidget( | ||
ProviderScope( | ||
overrides: [ | ||
productsRepositoryProvider.overrideWithValue(productsRepository), | ||
authRepositoryProvider.overrideWithValue(authRepository), | ||
], | ||
child: const MyApp(), | ||
), | ||
); | ||
await tester.pumpAndSettle(); | ||
} | ||
|
||
void expectFindAllProductCards() { | ||
final finder = find.byType(ProductCard); | ||
expect(finder, findsNWidgets(kTestProducts.length)); | ||
} | ||
} |