mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
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.
This commit is contained in:
committed by
Andrew Brogdon
parent
ad25e9cfb9
commit
2d64bf2957
@@ -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<AppStateModel>(
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user