Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgilder committed Sep 4, 2021
1 parent 06c209b commit 368431c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions example/book_store/test/navigation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void main() {

await tester.tap(find.text('Of Hummingbirds And Men'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/book/2');

Expand All @@ -37,6 +38,7 @@ void main() {
await tester.pumpWidget(BookStoreApp());
await setSystemUrl('/book/2');
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(
find.byWidgetPredicate(
Expand All @@ -55,6 +57,7 @@ void main() {

await tester.tap(find.text('Search'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/search?query=gone+with');

Expand All @@ -73,6 +76,7 @@ void main() {
await tester.pumpWidget(BookStoreApp());
await setSystemUrl('/search?query=gone+with');
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(
find.byWidgetPredicate(
Expand All @@ -88,6 +92,7 @@ void main() {
await tester.pumpWidget(BookStoreApp(username: 'dash'));
await setSystemUrl('/wishlist/shared/123');
await tester.pump();
await tester.pump(Duration(seconds: 1));

// Expect wishlist page is shown
expect(
Expand All @@ -108,6 +113,7 @@ void main() {

await setSystemUrl('/wishlist/shared/123');
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/login?redirectTo=%2Fwishlist%2Fshared%2F123');

Expand All @@ -117,6 +123,7 @@ void main() {

await tester.tap(find.byKey(LoginPage.loginButtonKey));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/wishlist/shared/123');

Expand All @@ -136,12 +143,14 @@ void main() {

await tester.pumpWidget(BookStoreApp(siteBlockedWithoutLogin: true));
await tester.pump();
await tester.pump(Duration(seconds: 1));

// User logs in
await tester.enterText(find.byKey(LoginPage.usernameFieldKey), 'dash');
await tester.pump();
await tester.tap(find.byKey(LoginPage.loginButtonKey));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(find.byType(ShopHome), findsOneWidget);
});
Expand Down Expand Up @@ -201,25 +210,29 @@ void main() {

await tester.pumpWidget(BookStoreApp(username: 'dash'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

// Go to wishlists page

await tester.tap(find.text('Wishlists'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/wishlist');

// Tap add wishlist

await tester.tap(find.text('Add a new wishlist'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/wishlist/add');

expect(find.byType(AddWishlistDialog), findsOneWidget);

await invokeSystemBack();
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/wishlist');
});
Expand All @@ -236,20 +249,23 @@ void main() {

await tester.tap(find.text('Search'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/search?query=non-fiction');

// Go to book page

await tester.tap(find.text('Hummingbirds for Dummies'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/category/nonfiction/book/1');

// Tap back button

await tester.tap(find.byType(BackButton));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/category/nonfiction');

Expand All @@ -271,18 +287,21 @@ void main() {

await tester.pumpWidget(BookStoreApp(username: 'dash'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

// Go to wishlists page

await tester.tap(find.text('Wishlists'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/wishlist');

// Tap add wishlist

await tester.tap(find.text('Add a new wishlist'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/wishlist/add');

Expand All @@ -295,6 +314,7 @@ void main() {
);
await tester.tap(find.text('Hummingbirds for Dummies'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

// Click add wishlist

Expand All @@ -309,6 +329,7 @@ void main() {

await tester.tap(find.text('Wishlist name'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/wishlist/shared/list-2');

Expand All @@ -330,23 +351,27 @@ void main() {

await tester.tap(find.text('Non-fiction'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/category/nonfiction');

await tester.tap(find.text('Fiction'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/category/fiction');

await tester.tap(find.text('Non-fiction'));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/category/nonfiction');

// Tap back button, expect to go back to home page

await tester.tap(find.byType(BackButton));
await tester.pump();
await tester.pump(Duration(seconds: 1));

expect(systemUrl.current, '/');
});
Expand Down

0 comments on commit 368431c

Please sign in to comment.