From 2d64bf29575e78369e40f13b96a4e70f54c53ba4 Mon Sep 17 00:00:00 2001 From: Filip Hracek Date: Mon, 30 Jul 2018 16:19:12 -0700 Subject: [PATCH] Add smoke test for Shrine (#8) Tests a simple journey: log in, buy a product, see the total in the cart. This change also removes the empty unit test. --- shrine/test/main_test.dart | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/shrine/test/main_test.dart b/shrine/test/main_test.dart index f8fc729db..b0af11c4d 100644 --- a/shrine/test/main_test.dart +++ b/shrine/test/main_test.dart @@ -2,10 +2,40 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:Shrine/app.dart'; +import 'package:Shrine/model/app_state_model.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:scoped_model/scoped_model.dart'; void main() { - group('Unit tests', () { - test('This test always passes', () {}); + testWidgets("smoke test", (tester) async { + AppStateModel model = AppStateModel(); + model.loadProducts(); + + await tester.pumpWidget(ScopedModel( + model: model, + child: ShrineApp(), + )); + + // Click through from the login screen. + await tester.tap(find.text("NEXT")); + await tester.pump(); + + // Ensure we populate the catalog page. + expect(find.text("Stella sunglasses"), findsOneWidget); + expect(find.text(r"$58"), findsOneWidget); + + // Buy a product. + await tester.tap(find.text("Stella sunglasses")); + await tester.pump(); + + // Go to the shopping cart. + await tester.tap(find.byIcon(Icons.shopping_cart)); + await tester.pumpAndSettle(); + + // Ensure that it appears, and that it computes total with tax and shipping. + expect(find.text("Subtotal:"), findsOneWidget); + expect(find.text(r"$68.48"), findsOneWidget); }); }